本文整理汇总了C++中Physics::addForce方法的典型用法代码示例。如果您正苦于以下问题:C++ Physics::addForce方法的具体用法?C++ Physics::addForce怎么用?C++ Physics::addForce使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Physics
的用法示例。
在下文中一共展示了Physics::addForce方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
const int dimension = 2;
Physics<dimension> physics;
Physics<dimension>::NodeIter iterN;
Physics<dimension>::NodeT *node, *prevNode = NULL, *tmpNode;
vector<Physics<dimension>::NodeT*> nodes;
// int i,j;
// for (i=0;i<10;i++)
// {
// node = physics.addNode();
// nodes.push_back(node);
// for (j=0;j<i/2;j++)
// physics.addLink(nodes[j], nodes[i]);
// }
// for (iterN = physics.initNodeIter() ; physics.getNode(node,iterN) ; iterN++)
// {
// cout << node << endl;
// }
// cout << "" << physics.toString() << "" << endl;
node = physics.addNode();
prevNode = physics.addNode();
physics.addLink(node,prevNode);
tmpNode = physics.addNode();
physics.addLink(node,tmpNode);
physics.addLink(prevNode,tmpNode);
node = physics.addNode();
physics.addLink(node,tmpNode);
node = physics.addNode();
Vector::set(node->location(),0.0,0.0);
Vector::set(node->speed(),0.0,0.0);
node->setCharge(0.0);
Force<2> *force = new Force<2>;
physics.addForce(force);
int r = 15;
PhysicsVisu physicsVisu(700,700,-r,-r,r,r,&physics);
physicsVisu.start();
return 0;
}