本文整理汇总了C++中StateVector::setTime方法的典型用法代码示例。如果您正苦于以下问题:C++ StateVector::setTime方法的具体用法?C++ StateVector::setTime怎么用?C++ StateVector::setTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StateVector
的用法示例。
在下文中一共展示了StateVector::setTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addLoadToStorage
void addLoadToStorage(Storage &forceStore, SimTK::Vec3 force, SimTK::Vec3 point, SimTK::Vec3 torque)
{
int nLoads = forceStore.getColumnLabels().getSize()/9;
string labels[9] = { "forceX", "forceY", "forceZ", "pointX", "pointY", "pointZ","torqueX", "torqueY", "torqueZ"};
char suffix[2];
sprintf(suffix, "%d", nLoads);
Array<string> col_labels;
col_labels.append("time");
StateVector dataRow;
dataRow.setTime(0);
double data[9];
for(int i = 0; i<9; i++){
col_labels.append(labels[i]);
if(i<3){
data[i] = force[i]; continue;
}
else if(i<6){
data[i] = point[i-3]; continue;
}
else
data[i] = torque[i-6];
}
dataRow.setStates(0, 9, data);
Storage *forces = NULL;
Storage tempStore;
if(nLoads == 0)
forces = &forceStore;
else if (nLoads > 0)
forces = &tempStore;
else
throw OpenSim::Exception("addLoadToStorage: ERROR");
forces->setColumnLabels(col_labels);
forces->append(dataRow);
dataRow.setTime(1.0);
forces->append(dataRow);
dataRow.setTime(2.0);
forces->append(dataRow);
if (nLoads > 0)
forces->addToRdStorage(forceStore, 0.0, 1.0);
}