本文整理汇总了C++中Joint::numMembers方法的典型用法代码示例。如果您正苦于以下问题:C++ Joint::numMembers方法的具体用法?C++ Joint::numMembers怎么用?C++ Joint::numMembers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Joint
的用法示例。
在下文中一共展示了Joint::numMembers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: populateForces
void populateForces(vector<Member*> memberList, vector<Joint*> joints) {
Matrix forceMatrix(joints.size() * 2, memberList.size() + 1);
//Be sure that the members vector is sorted by id
if(joints.size()*2 < memberList.size() + 1) {
cout << "Bridge makes no sense, force calculations make no sense." << endl;
return;
}
for (int i=0; i<joints.size(); i++) {
Joint* curJoint = joints.at(i);
//cout << "Joint " << i << ": (" << curJoint->getX() << "," << curJoint->getY() << ")" << endl;
//cout << "Has " << curJoint->numMembers() << " members" << endl;
//cout << "Those members are: ";
/*
for (int a=0; a<curJoint->numMembers(); a++) {
//cout << curJoint->members[a]->id() << " ";
} //cout << endl;
*/
for (int j=0; j<curJoint->numMembers(); j++) {
Joint* otherJoint = curJoint->members[j]->leftJoint() == curJoint ? curJoint->members[j]->rightJoint() : curJoint->members[j]->leftJoint();
for (int k=0; k<joints.size(); k++) {
//if (otherJoint == joints[k])
//cout << "OtherJoint " << k << ": (" << otherJoint->getX() << "," << otherJoint->getY() << ")" << endl;
}
double angle = atan2(otherJoint->getY() - curJoint->getY(), otherJoint->getX() - curJoint->getX());
//cout << angle << endl;
forceMatrix.setElement(2*i, curJoint->members[j]->id(), cos(angle));
forceMatrix.setElement(2*i+1, curJoint->members[j]->id(), sin(angle));
//forceMatrix.print(cout);
}
forceMatrix.setElement(2*i, memberList.size(), -1 * curJoint->appliedX());
forceMatrix.setElement(2*i+1, memberList.size(), -1 * curJoint->appliedY());
}
//forceMatrix.print(cout);
forceMatrix = forceMatrix.rref();
//forceMatrix.print(cout);
for (int i=0; i<memberList.size(); i++) {
memberList.at(i)->force = forceMatrix.getElement(i, memberList.size());
}
}