本文整理汇总了C#中System.Vector2.Truncate方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2.Truncate方法的具体用法?C# Vector2.Truncate怎么用?C# Vector2.Truncate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Vector2
的用法示例。
在下文中一共展示了Vector2.Truncate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Vector2_Truncate_Test
public void Vector2_Truncate_Test()
{
var a = new Vector2(10, 10);
var b = a.Truncate(5);
Assert.AreEqual(5f, b.Length(), 0.001f);
}
示例2: Move
public void Move(GameTime time)
{
TimeElapsed = time.ElapsedGameTime;
Vector2 OldPos = Position;
Vector2 SteeringForce;
SteeringForce = m_Steering.Calculate(this);
//Acceleration = Force/Mass
Vector2 acceleration;
Vector2.Divide(ref SteeringForce, Mass, out acceleration);
//update velocity
Velocity += Vector2.Multiply(acceleration, (float)time.ElapsedGameTime.TotalSeconds);
//make sure vehicle does not exceed maximum velocity
Velocity = Velocity.Truncate(MaxSpeed);
//update the position
Position += Vector2.Multiply(Velocity, (float)time.ElapsedGameTime.TotalSeconds);
//update the heading if the vehicle has a non zero velocity
if (Velocity.LengthSquared() > 0.00000001)
{
Heading = Vector2.Normalize(Velocity);
Side = Heading.Perpendicular();
}
EntityUtils.EnforceNonPenetrationConstraint(this, World.GameEntities);
World.CheckBounds(this);
//update the vehicle's current cell if space partitioning is turned on
//if (Steering()->isSpacePartitioningOn())
//{
// World()->CellSpace()->UpdateEntity(this, OldPos);
//}
//if (isSmoothingOn())
//{
// m_vSmoothedHeading = m_pHeadingSmoother->Update(Heading());
//}
}