Exemple #1
0
 public static Vector Normalize(Vector vector)
 {
     float length = vector.Length();
       if (length != 0.0)
     return new Vector(
       vector.X / length,
       vector.Y / length,
       vector.Z / length);
       else
     return Vector.FactoryZero;
 }
 public static Quaternion FactoryFromAxisAngle(Vector axis, float angle)
 {
     if (axis.LengthSquared() == 0.0f)
     return FactoryIdentity;
       float sinAngleOverAxisLength = Calc.Sin(angle / 2) / axis.Length();
       return Quaternion.Normalize(new Quaternion(
     axis.X * sinAngleOverAxisLength,
     axis.Y * sinAngleOverAxisLength,
     axis.Z * sinAngleOverAxisLength,
     Calc.Cos(angle / 2)));
 }
Exemple #3
0
 public static float AngleBetween(Vector first, Vector second)
 {
     return Calc.ArcCos(Vector.DotProduct(first, second) / (first.Length() * second.Length()));
 }
Exemple #4
0
 public void MoveTowards(Vector vector)
 {
     //Vector v1 = new Vector(0, 0, -1);
       //Vector moveV = _staticModel.Position - vector;
       //Vector v2 = moveV.RotateBy(_staticModel.Orientation.W, 0, 1, 0);
       _staticModel.Position.X += (vector.X / vector.Length()) * _moveSpeed;
       _staticModel.Position.Y += (vector.Y / vector.Length()) * _moveSpeed;
       _staticModel.Position.Z += (vector.Z / vector.Length()) * _moveSpeed;
 }