本文整理汇总了C++中Mover::getLocation方法的典型用法代码示例。如果您正苦于以下问题:C++ Mover::getLocation方法的具体用法?C++ Mover::getLocation怎么用?C++ Mover::getLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mover
的用法示例。
在下文中一共展示了Mover::getLocation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
const Vec2f Mover::attract( const Mover& m, const float g ) const
{
auto force = location - m.getLocation();
auto distance = force.lengthSquared();
distance = ( distance < 25.0f ) ? 25.0f : ( ( distance > 625.0f ) ? 625.0 : distance );
force.normalize();
force *= g * mass * m.getMass() / ( distance );
return force;
}
示例2: attract
ofVec2f Attractor::attract(Mover m){
ofVec2f force = location - m.getLocation(); // Calculate direction of force
float d = force.length(); // Distance between objects
d = ofClamp(d,5.0,25.0);
force.normalize(); // Normalize vector (distance doesn't matter here, we just want this vector for direction)
float strength = (G * mass * m.mass) / (d * d); // Calculate gravitional force magnitude
force *= strength; // Get force vector --> magnitude * direction
return force;
}