本文整理汇总了C++中Vector2D::Perp方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector2D::Perp方法的具体用法?C++ Vector2D::Perp怎么用?C++ Vector2D::Perp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector2D
的用法示例。
在下文中一共展示了Vector2D::Perp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FireRockets
void BaseTank::FireRockets()
{
if(mRocketDelay <= 0.0f)
{
mRocketDelay = kTimeBetweenRockets;
mFiringRocket = true;
//Get the direction of fire from the current heading.
Vector2D fireDirection = mHeading * -1;
//fireDirection.y *= -1;
//Set the projectile setup details.
ProjectileSetupDetails details;
details.Direction = fireDirection;
details.GameObjectType = GAMEOBJECT_ROCKET;
details.ImagePath = kRocketPath;
details.RotationAngle = mRotationAngle;
//Fire left rocket.
if( (mRockets > 0) && (mCannonAttachedLeft) )
{
details.StartPosition = GetCentralPosition();
details.StartPosition += fireDirection.Perp()*-14.0f;
ProjectileManager::Instance()->CreateProjectile(mRenderer, details, this);
}
//Fire right rocket.
if( (mRockets > 0) && (mCannonAttachedRight) )
{
details.StartPosition = GetCentralPosition();
details.StartPosition += fireDirection.Perp()*14.0f;
ProjectileManager::Instance()->CreateProjectile(mRenderer, details, this);
}
}
}
示例2: BaseGameEntity
MovingEntity::MovingEntity(int id,
Vector2D _position,
double _radius,
Vector2D _velocity,
double _max_speed,
Vector2D _heading,
double _mass,
Vector2D _scale,
double _turn_rate,
double _max_force) : BaseGameEntity(id, 0, _position, _radius),
heading(_heading),
velocity(_velocity),
mass(_mass),
side(_heading.Perp()),
maxSpeed(_max_speed),
maxTurnRate(_turn_rate),
maxForce(_max_force)
{
scale = _scale;
}
示例3: isPassSafeFromOpponent
//----------------------- isPassSafeFromOpponent -------------------------
//
// test if a pass from 'from' to 'to' can be intercepted by an opposing
// player
//------------------------------------------------------------------------
bool AbstSoccerTeam::isPassSafeFromOpponent(Vector2D from,
Vector2D target,
const PlayerBase* const receiver,
const PlayerBase* const opp,
double PassingForce)const
{
//move the opponent into local space.
Vector2D ToTarget = target - from;
Vector2D ToTargetNormalized = Vec2DNormalize(ToTarget);
Vector2D LocalPosOpp = PointToLocalSpace(opp->Pos(),
ToTargetNormalized,
ToTargetNormalized.Perp(),
from);
//if opponent is behind the kicker then pass is considered okay(this is
//based on the assumption that the ball is going to be kicked with a
//velocity greater than the opponent's max velocity)
if ( LocalPosOpp.x < 0 )
{
return true;
}
//if the opponent is further away than the target we need to consider if
//the opponent can reach the position before the receiver.
if (Vec2DDistanceSq(from, target) < Vec2DDistanceSq(opp->Pos(), from))
{
if (receiver)
{
if ( Vec2DDistanceSq(target, opp->Pos()) >
Vec2DDistanceSq(target, receiver->Pos()) )
{
return true;
}
else
{
return false;
}
}
else
{
return true;
}
}
//calculate how long it takes the ball to cover the distance to the
//position orthogonal to the opponents position
double TimeForBall =
Pitch()->Ball()->TimeToCoverDistance(Vector2D(0,0),
Vector2D(LocalPosOpp.x, 0),
PassingForce);
//now calculate how far the opponent can run in this time
double reach = opp->MaxSpeed() * TimeForBall +
Pitch()->Ball()->BRadius()+
opp->BRadius();
//if the distance to the opponent's y position is less than his running
//range plus the radius of the ball and the opponents radius then the
//ball can be intercepted
if ( fabs(LocalPosOpp.y) < reach )
{
return false;
}
return true;
}