Ejemplo n.º 1
0
        public static double DistanceSquared(Vector3Double value1, Vector3Double value2)
        {
            double differenceX = value1.X - value2.X;
            double differenceY = value1.Y - value2.Y;
            double differenceZ = value1.Z - value2.Z;

            return(differenceX * differenceX + differenceY * differenceY + differenceZ * differenceZ);
        }
Ejemplo n.º 2
0
        public Matrix GetWorldMatrix(Vector3Double targetPosition)
        {
            Matrix scaleMatrix, translationMatrix;

            Vector3Double targetRelativePosition = targetPosition - Position;
            double        targetRelativeDistance = targetRelativePosition.Length();

            if (targetRelativeDistance > UnscaledSpaceDistance)
            {
                float   scaledTargetRelativeDistance = (float)(UnscaledSpaceDistance + ScaledSpaceDistance * (1 - Math.Exp((ScaledSpaceDistance - targetRelativeDistance) / InvisibleDistance)));
                Vector3 scaledTargetRelativePosition = scaledTargetRelativeDistance * Vector3Double.Normalize(targetRelativePosition);

                scaleMatrix       = Matrix.CreateScale((float)(scaledTargetRelativeDistance / targetRelativeDistance));
                translationMatrix = Matrix.CreateTranslation(scaledTargetRelativePosition);
            }
            else
            {
                scaleMatrix       = Matrix.Identity;
                translationMatrix = Matrix.CreateTranslation(targetRelativePosition.ToVector3());
            }

            return(scaleMatrix * translationMatrix);
        }
Ejemplo n.º 3
0
 public static Vector3 Normalize(Vector3Double value)
 {
     return((value / value.Length()).ToVector3());
 }
Ejemplo n.º 4
0
 public static double Distance(Vector3Double value1, Vector3Double value2)
 {
     return(Math.Sqrt(DistanceSquared(value1, value2)));
 }