Documentation of 'vmm3d.core3D.Vector3D' Java class
Vector3D
vmm3d.core3D

Class Vector3D



  • public class Vector3D
    extends java.lang.Object
    A 3D vector with components of type double named x, y, and z.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static Vector3D ORIGIN
      The origin, (0,0,0).
      static Vector3D UNIT_X
      The unit vector in the x direction, (1,0,0).
      static Vector3D UNIT_Y
      The unit vector in the y direction, (0,1,0).
      static Vector3D UNIT_Z
      The uint vector in the z direction, (0,0,1).
      double x
      The first component of the vector.
      double y
      The second component of the vector.
      double z
      The third component of the vector.
    • Constructor Summary

      Constructors 
      Constructor and Description
      Vector3D()
      Construct a vector with all three components initially equal to zero.
      Vector3D(double x, double y, double z)
      Construct a vector that initially has coordinates (x,y,z).
      Vector3D(Vector3D v)
      Construct a vector that is initially a copy of a specified vector.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void assign(Vector3D v)
      this.assign(v) assigns to this the value v.
      void assignLinComb(double c, double d, Vector3D v)
      this.assignLinComb(c,d,v) assigns to this the value c*this + d*v.
      void assignLinComb(double c, Vector3D v, double d, Vector3D w)
      this.assignLinComb(c,v,d,w) assigns to this the value c*v + d*w.
      void assignMinus(Vector3D v)
      this.assignMinus(v) assigns to this the value this (- v).
      void assignMinus(Vector3D v, Vector3D w)
      this.assignMinus(v, w) assigns to this the value this (v - w).
      void assignPlus_SumTimes(Vector3D u, Vector3D v, Vector3D w, Vector3D ww, double d)
      this.assignPlus_SumTimes(u, v, w, ww, d) assigns to this the value: this + (u + v + w + ww)*d.
      void assignPlus(Vector3D v)
      this.assignPlus(v) assigns to this the value this + v.
      void assignSum(Vector3D v, Vector3D w)
      this.assignSum(v,w) assigns to this the value v + w.
      void assignSumTimes(Vector3D v, Vector3D w, double d)
      this.assignSumTimes(v, w, d) assigns to this the value (v + w)*d.
      void assignSumTimes(Vector3D v, Vector3D w, Vector3D vv, Vector3D ww, double d)
      this.assignSumTimes(v, w, vv, ww, d) assigns to this the value (v + w + vv + ww)*d.
      void assignTimes(double d)
      this.assignTimes(d) assigns to this the value d*this.
      void assignTimes(double d, Vector3D v)
      this.assignTimes(d, v) assigns to this the value d*v.
      Vector3D cross(Vector3D v)
      Returns the cross product of this vector and v.
      double dot(Vector3D v)
      Returns the dot product of this vector and v.
      boolean equals(java.lang.Object obj)
      Returns true obj is a non-null object whose class in Vector3D and such that the three corrdinates of the vector obj are the same as the coordinates of this vector.
      static Vector3D fromString(java.lang.String str)
      Attempts to convert a string into a value of type Vector3D.
      Vector3D linComb(double c, double d, Vector3D v)
      Returns the linear combination c*this + d*v.
      Vector3D minus(Vector3D v)
      Returns the vector difference of this vector and v.
      void negate()
      Multiplies each component of this vector by -1.
      Vector3D negated()
      Returns a new vector that is equal to -1 times this vector.
      double norm()
      Returns the length of this vector, computed as Math.sqrt(x*x+y*y+z*z)
      double norm2()
      Returns the length^2 of this vector, computed as (x*x+y*y+z*z)
      void normalize()
      Divides each component of the vector by the norm of the vector, giving a vector that has length 1.
      Vector3D normalized()
      Returns a new vector that is equal to this vector normalized.
      Vector3D plus(Vector3D v)
      Returns the vector sum of this vector and v.
      Vector3D reflectInAxis(Vector3D axis)
      Rotates this around the unit vector axis by 180 degrees: this to -this + 2*axis.
      Vector3D times(double d)
      Returns the scalar product of this vector times d.
      java.lang.String toString()
      Returns a string representation of this vector of the form "(x,y,z)" where x, y, and z are the numerical components of the vector.
      • Methods inherited from class java.lang.Object

        getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • x

        public double x
        The first component of the vector.
      • y

        public double y
        The second component of the vector.
      • z

        public double z
        The third component of the vector.
      • ORIGIN

        public static final Vector3D ORIGIN
        The origin, (0,0,0).
      • UNIT_X

        public static final Vector3D UNIT_X
        The unit vector in the x direction, (1,0,0).
      • UNIT_Y

        public static final Vector3D UNIT_Y
        The unit vector in the y direction, (0,1,0).
      • UNIT_Z

        public static final Vector3D UNIT_Z
        The uint vector in the z direction, (0,0,1).
    • Constructor Detail

      • Vector3D

        public Vector3D()
        Construct a vector with all three components initially equal to zero.
      • Vector3D

        public Vector3D(double x,
                        double y,
                        double z)
        Construct a vector that initially has coordinates (x,y,z).
      • Vector3D

        public Vector3D(Vector3D v)
        Construct a vector that is initially a copy of a specified vector.
        Parameters:
        v - the constructed vector is (v.x, v.y, v.z), or is (0,0,0) if v is null.
    • Method Detail

      • equals

        public boolean equals(java.lang.Object obj)
        Returns true obj is a non-null object whose class in Vector3D and such that the three corrdinates of the vector obj are the same as the coordinates of this vector.
        Overrides:
        equals in class java.lang.Object
      • norm

        public double norm()
        Returns the length of this vector, computed as Math.sqrt(x*x+y*y+z*z)
      • norm2

        public double norm2()
        Returns the length^2 of this vector, computed as (x*x+y*y+z*z)
      • normalize

        public void normalize()
        Divides each component of the vector by the norm of the vector, giving a vector that has length 1. However, if the vector is zero, or if any of its components are infinite or undefined, then the result of calling this method is to set all the components of the vector to Double.NaN. This method modifies the vector.
        See Also:
        normalized()
      • negate

        public void negate()
        Multiplies each component of this vector by -1. This method modifies the vector.
        See Also:
        negated()
      • normalized

        public Vector3D normalized()
        Returns a new vector that is equal to this vector normalized. This vector is not modified.
        See Also:
        normalize()
      • negated

        public Vector3D negated()
        Returns a new vector that is equal to -1 times this vector. This vector is not modified.
        See Also:
        negate()
      • plus

        public Vector3D plus(Vector3D v)
        Returns the vector sum of this vector and v. A new vector object is constructed to contain the result; neither input vector is modified.
        Parameters:
        v - a non-null vector
      • linComb

        public Vector3D linComb(double c,
                                double d,
                                Vector3D v)
        Returns the linear combination c*this + d*v. A new vector object contains the result.
      • assign

        public void assign(Vector3D v)
        this.assign(v) assigns to this the value v.
      • assignPlus

        public void assignPlus(Vector3D v)
        this.assignPlus(v) assigns to this the value this + v.
      • assignSum

        public void assignSum(Vector3D v,
                              Vector3D w)
        this.assignSum(v,w) assigns to this the value v + w.
      • assignLinComb

        public void assignLinComb(double c,
                                  double d,
                                  Vector3D v)
        this.assignLinComb(c,d,v) assigns to this the value c*this + d*v.
      • assignLinComb

        public void assignLinComb(double c,
                                  Vector3D v,
                                  double d,
                                  Vector3D w)
        this.assignLinComb(c,v,d,w) assigns to this the value c*v + d*w.
      • assignPlus_SumTimes

        public void assignPlus_SumTimes(Vector3D u,
                                        Vector3D v,
                                        Vector3D w,
                                        Vector3D ww,
                                        double d)
        this.assignPlus_SumTimes(u, v, w, ww, d) assigns to this the value: this + (u + v + w + ww)*d.
      • minus

        public Vector3D minus(Vector3D v)
        Returns the vector difference of this vector and v. A new vector object is constructed to contain the result; neither input vector is modified.
        Parameters:
        v - a non-null vector
      • assignMinus

        public void assignMinus(Vector3D v)
        this.assignMinus(v) assigns to this the value this (- v).
      • assignMinus

        public void assignMinus(Vector3D v,
                                Vector3D w)
        this.assignMinus(v, w) assigns to this the value this (v - w).
      • times

        public Vector3D times(double d)
        Returns the scalar product of this vector times d. A new vector object is constructed to contain the result; the vector is not modified.
        Parameters:
        d - the scalar that is to be multiplied times this vector
      • assignTimes

        public void assignTimes(double d)
        this.assignTimes(d) assigns to this the value d*this.
      • assignTimes

        public void assignTimes(double d,
                                Vector3D v)
        this.assignTimes(d, v) assigns to this the value d*v.
      • assignSumTimes

        public void assignSumTimes(Vector3D v,
                                   Vector3D w,
                                   double d)
        this.assignSumTimes(v, w, d) assigns to this the value (v + w)*d.
      • assignSumTimes

        public void assignSumTimes(Vector3D v,
                                   Vector3D w,
                                   Vector3D vv,
                                   Vector3D ww,
                                   double d)
        this.assignSumTimes(v, w, vv, ww, d) assigns to this the value (v + w + vv + ww)*d.
      • dot

        public double dot(Vector3D v)
        Returns the dot product of this vector and v. A new vector object is constructed to contain the result; neither input vector is modified.
        Parameters:
        v - a non-null vector
      • cross

        public Vector3D cross(Vector3D v)
        Returns the cross product of this vector and v. A new vector object is constructed to contain the result; neither input vector is modified.
        Parameters:
        v - a non-null vector
      • reflectInAxis

        public Vector3D reflectInAxis(Vector3D axis)
        Rotates this around the unit vector axis by 180 degrees: this to -this + 2*axis. Call as this.reflectInAxis(axis).
      • toString

        public java.lang.String toString()
        Returns a string representation of this vector of the form "(x,y,z)" where x, y, and z are the numerical components of the vector. The special strings NaN, INF and -INF are used to represent the values Double.NaN, Double.POSITIVE_INFINITY, and Double.NEGATIVE_INFINITY.
        Overrides:
        toString in class java.lang.Object
      • fromString

        public static Vector3D fromString(java.lang.String str)
                                   throws java.lang.NumberFormatException
        Attempts to convert a string into a value of type Vector3D. The string should be in the format produced by toString(), of the form "(x,y,z)". Will also accept strings that use a space as a separator and are not enclosed in parentheses, of the form "x y z".
        Parameters:
        str - the non-null string that is to be converted
        Throws:
        java.lang.NumberFormatException - if the string is not of the correct format (or is null)

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.