Exemplo n.º 1
0
 /// <summary>
 /// Creates a new plane from the given normal vector and a distance.
 /// </summary>
 /// <param name="v">The vector normal to the plane.</param>
 /// <param name="d">The distance along the plane.</param>
 public Plane(Vector3D v, double d)
 {
     A = v.X;
     B = v.Y;
     C = v.Z;
     D = d;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new point from the given position vector.
 /// </summary>
 /// <param name="v">The position vector to create a point from.</param>
 public Point3D(Vector3D v)
 {
     X = v.X;
     Y = v.Y;
     Z = v.Z;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Sets new value from the given vector.
 /// </summary>
 /// <param name="v"></param>
 public void Set(Vector3D v)
 {
     X = v.X;
     Y = v.Y;
     Z = v.Z;
 }
Exemplo n.º 4
0
 public void add(Vector3D v)
 {
     x += v.x;
     y += v.y;
     z += v.z;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Creates a new vector that is equivalent to another vector.
 /// </summary>
 /// <param name="v">The vector to copy.</param>
 public Vector3D(Vector3D v)
 {
     X = v.X;
     Y = v.Y;
     Z = v.Z;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Returns the quotient between this vector and another co-directional vector.
 /// </summary>
 /// <returns></returns>
 public double scalarDivision(Vector3D v)
 {
     if (x > 0.0001f || x < -0.0001f)
     {
         return z / v.Z;
     }
     else if (y > 0.0001f || y < -0.0001f)
     {
         return y / v.Y;
     }
     else
     {
         return x / v.X;
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Returns true if the given vector is a scalar multiple of the other given vector.
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        public bool isScalarMultipleOf(Vector3D v)
        {
            double a = 1, b = 1, c = 1;

            if (x == 0)
                if (v.X == 0)
                    a = 1;
                else
                    a = 0;
            else
                a = v.X / x;

            if (y == 0)
                if (v.Y == 0)
                    b = 1;
                else
                    b = 0;
            else
                b = v.Y / y;

            if (a != b)
                return false;

            if (z == 0)
                if (v.Z == 0)
                    c = 1;
                else
                    c = 0;
            else
                c = v.Z / z;

            if (b != c)
                return false;

            if (a == 0)
                return false;

            return true;
        }
Exemplo n.º 8
0
 /// <summary>
 /// Returns true if the two vectors are equivalent.
 /// </summary>
 /// <param name="v">The other vector to compare against.</param>
 public bool equals(Vector3D v)
 {
     return v.X == x && v.Y == y && v.Z == z;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Returns the dot product of this vector and another.
 /// </summary>
 /// <param name="v">The vector to multiply by.</param>
 /// <returns>the dot product of this vector and another.</returns>
 public double dotProduct(Vector3D v)
 {
     return x * v.X + y * v.Y + z * v.Z;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Returns the cross product of this vector and another.
 /// </summary>
 /// <param name="v">The vector to multiply by.</param>
 /// <returns>the cross product of this vector and another.</returns>
 public Vector3D crossProduct(Vector3D v)
 {
     return new Vector3D(Y * v.z - Z * v.y, Z * v.x - X * v.z, X * v.y - Y * v.x);
 }