本文整理汇总了C++中AbstractVehicle::maxForce方法的典型用法代码示例。如果您正苦于以下问题:C++ AbstractVehicle::maxForce方法的具体用法?C++ AbstractVehicle::maxForce怎么用?C++ AbstractVehicle::maxForce使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AbstractVehicle
的用法示例。
在下文中一共展示了AbstractVehicle::maxForce方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clip
float3
OpenSteer::SteerLibrary::
steerForTargetSpeed (const AbstractVehicle& v,
const float targetSpeed)
{
const float mf = v.maxForce ();
const float speedError = targetSpeed - v.speed ();
return float3_scalar_multiply(make_float3(v.forward ()), clip (speedError, -mf, +mf));
}
示例2:
OpenSteer::Vec3
OpenSteer::Obstacle::PathIntersection::
steerToAvoidIfNeeded (const AbstractVehicle& vehicle,
const float minTimeToCollision) const
{
// if nearby intersection found, steer away from it, otherwise no steering
const float minDistanceToCollision = minTimeToCollision * vehicle.speed();
if (intersect && (distance < minDistanceToCollision))
{
// compute avoidance steering force: take the component of
// steerHint which is lateral (perpendicular to vehicle's
// forward direction), set its length to vehicle's maxForce
Vec3 lateral = steerHint.perpendicularComponent (vehicle.forward ());
if (lateral == Vec3::zero)
lateral = vehicle.side ();
return lateral.normalize () * vehicle.maxForce ();
}
else
{
return Vec3::zero;
}
}