Normalize() public static méthode

public static Normalize ( Vector3D v ) : Vector3D
v Vector3D
Résultat Vector3D
Exemple #1
0
 public Quaternion(Vector3D axis, float angle)
 {
     axis.Normalize();
     float num2 = angle * 0.5f;
     float num = MathUtility.Sin(num2);
     float num3 = MathUtility.Cos(num2);
     X = axis.X * num;
     Y = axis.Y * num;
     Z = axis.Z * num;
     W = num3;
 }
        /// <summary>
        /// Computes the tangent of a cubic bezier curve at the specified time,
        /// when given four Point3D control points. This is used for calculating
        /// normals (by crossing the horizontal and vertical tangent vectors).
        /// </summary>
        private static Vector3D BezierTangent(Point3D p1, Point3D p2,
			Point3D p3, Point3D p4, float t)
        {
            Vector3D result = new Vector3D();

            result.X = BezierTangent(p1.X, p2.X, p3.X, p4.X, t);
            result.Y = BezierTangent(p1.Y, p2.Y, p3.Y, p4.Y, t);
            result.Z = BezierTangent(p1.Z, p2.Z, p3.Z, p4.Z, t);

            result.Normalize();

            return result;
        }
Exemple #3
0
        public static float AngleBetween(Vector3D vector1, Vector3D vector2)
        {
            vector1.Normalize();
            vector2.Normalize();

            if (Dot(vector1, vector2) < 0.0f)
            {
                Vector3D vectord2 = -vector1 - vector2;
                return MathUtility.PI - (2.0f * MathUtility.Asin(vectord2.Length() / 2.0f));
            }

            Vector3D vectord = vector1 - vector2;
            return 2.0f * MathUtility.Asin(vectord.Length() / 2.0f);
        }
Exemple #4
0
        private void Rotate(Rotation rot)
        {
            var trans = new RotateTransform3D(rot);

            Up = trans.Transform(Up);
            Up.Normalize();

            Forward = trans.Transform(Forward);
            Forward.Normalize();
        }