Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CoordinateF"/> class by using the X, Y and Z terms of a FloatVector.
 /// </summary>
 /// <param name="floatVector">FloatVector used for initialization.</param>
 public CoordinateF(FloatVector3 floatVector)
 {
     _x = floatVector.X;
     _y = floatVector.Y;
     _z = floatVector.Z;
     _m = float.NaN;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the Cross Product of two vectors lhs and V
        /// </summary>
        /// <param name="lhs">Vector, the first input vector</param>
        /// <param name="rhs">Vector, the second input vector</param>
        /// <returns>A FloatVector3 containing the cross product of lhs and V</returns>
        public static FloatVector3 CrossProduct(FloatVector3 lhs, FloatVector3 rhs)
        {
            FloatVector3 result = new FloatVector3();

            result.X = (lhs.Y * rhs.Z - lhs.Z * rhs.Y);
            result.Y = (lhs.Z * rhs.X - lhs.X * rhs.Z);
            result.Z = (lhs.X * rhs.Y - lhs.Y * rhs.X);
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Tests to see if the specified object has the same X, Y and Z values.
        /// </summary>
        /// <param name="obj">object to test against.</param>
        /// <returns>True, if the X, Y, Z values of the two vectors are equal.</returns>
        public override bool Equals(object obj)
        {
            if (!(obj is FloatVector3))
            {
                return(false);
            }
            FloatVector3 fv = (FloatVector3)obj;

            return(fv.X == X && fv.Y == Y && fv.Z == Z);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns the Cross Product of two vectors lhs and V.
        /// </summary>
        /// <param name="lhs">Vector, the first input vector.</param>
        /// <param name="rhs">Vector, the second input vector.</param>
        /// <returns>A FloatVector3 containing the cross product of lhs and V.</returns>
        public static FloatVector3 CrossProduct(FloatVector3 lhs, FloatVector3 rhs)
        {
            FloatVector3 result = new FloatVector3
            {
                X = (lhs.Y * rhs.Z) - (lhs.Z * rhs.Y),
                Y = (lhs.Z * rhs.X) - (lhs.X * rhs.Z),
                Z = (lhs.X * rhs.Y) - (lhs.Y * rhs.X)
            };

            return(result);
        }
Exemplo n.º 5
0
 /// <summary>
 /// tests to see if the specified object has the same X, Y and Z values
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public override bool Equals(object obj)
 {
     if (obj is FloatVector3)
     {
         FloatVector3 fv = (FloatVector3)obj;
         if (fv.X == X && fv.Y == Y && fv.Z == Z)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Divides the components of vector lhs by the respective components
        /// ov vector V and returns the resulting vector.
        /// </summary>
        /// <param name="lhs">FloatVector3 Dividend (Numbers to be divided)</param>
        /// <param name="rhs">FloatVector3 Divisor (Numbers to divide by)</param>
        /// <returns>A FloatVector3 quotient of lhs and V</returns>
        /// <remarks>To prevent divide by 0, if a 0 is in V, it will return 0 in the result</remarks>
        public static FloatVector3 operator /(FloatVector3 lhs, FloatVector3 rhs)
        {
            FloatVector3 result = new FloatVector3();

            if (rhs.X > 0)
            {
                result.X = lhs.X / rhs.X;
            }
            if (rhs.Y > 0)
            {
                result.Y = lhs.Y / rhs.Y;
            }
            if (rhs.Z > 0)
            {
                result.Z = lhs.Z / rhs.Z;
            }
            return(result);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Subtracts the specified value
 /// </summary>
 /// <param name="vector">A FloatVector3</param>
 public void Subtract(FloatVector3 vector)
 {
     X -= vector.X;
     Y -= vector.Y;
     Z -= vector.Z;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Subtracts all the scalar members of the the two vectors
 /// </summary>
 /// <param name="lhs">Left hand side</param>
 /// <param name="rhs">Right hand side</param>
 /// <returns></returns>
 public static FloatVector3 Subtract(FloatVector3 lhs, FloatVector3 rhs)
 {
     return(new FloatVector3(lhs.X - rhs.X, lhs.Y - rhs.Y, lhs.Z - rhs.Z));
 }
Exemplo n.º 9
0
 /// <summary>
 /// Multiplies the source vector by a scalar.
 /// </summary>
 /// <param name="source"></param>
 /// <param name="scalar"></param>
 /// <returns></returns>
 public static FloatVector3 Multiply(FloatVector3 source, float scalar)
 {
     return(new FloatVector3(source.X * scalar, source.Y * scalar, source.Z * scalar));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Multiplies all the scalar members of the the two vectors
 /// </summary>
 /// <param name="lhs">Left hand side</param>
 /// <param name="rhs">Right hand side</param>
 /// <returns></returns>
 public static float Dot(FloatVector3 lhs, FloatVector3 rhs)
 {
     return(lhs.X * rhs.X + lhs.Y * rhs.Y + lhs.Z * rhs.Z);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Adds the specified v
 /// </summary>
 /// <param name="vector">A FloatVector3 to add to this vector</param>
 public void Add(FloatVector3 vector)
 {
     X += vector.X;
     Y += vector.Y;
     Z += vector.Z;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Adds all the scalar members of the the two vectors
 /// </summary>
 /// <param name="lhs">Left hand side</param>
 /// <param name="rhs">Right hand side</param>
 /// <returns></returns>
 public static FloatVector3 Add(FloatVector3 lhs, FloatVector3 rhs)
 {
     return(new FloatVector3(lhs.X + rhs.X, lhs.Y + rhs.Y, lhs.Z + rhs.Z));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Multiplies all the scalar members of the the two vectors.
 /// </summary>
 /// <param name="lhs">Left hand side.</param>
 /// <param name="rhs">Right hand side.</param>
 /// <returns>The resulting value.</returns>
 public static float Dot(FloatVector3 lhs, FloatVector3 rhs)
 {
     return((lhs.X * rhs.X) + (lhs.Y * rhs.Y) + (lhs.Z * rhs.Z));
 }