Documentation of 'mikera.vectorz.Vector3' Java class
Vector3
mikera.vectorz

Class Vector3

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<java.lang.Double>, INDArray, IVector


    public final class Vector3
    extends APrimitiveVector
    Specialised 3D vector Represents a point in 3D x,y,z space.
    See Also:
    Serialized Form
    • Field Detail

      • x

        public double x
      • y

        public double y
      • z

        public double z
    • Constructor Detail

      • Vector3

        public Vector3()
      • Vector3

        public Vector3(Vector3 source)
      • Vector3

        public Vector3(double x,
                       double y,
                       double z)
      • Vector3

        public Vector3(double... values)
      • Vector3

        public Vector3(AVector v)
    • Method Detail

      • applyOp

        public void applyOp(Op op)
        Description copied from interface: INDArray
        Applies a unary operator to all elements of the array (in-place)
        Specified by:
        applyOp in interface INDArray
        Overrides:
        applyOp in class AVector
      • reduce

        public double reduce(Op2 op,
                             double init)
        Description copied from interface: INDArray
        Reduces over all elements of the array in row-major order. Applies the operator to the initial/previous result at each step. Returns the final result.
        Specified by:
        reduce in interface INDArray
        Overrides:
        reduce in class AVector
      • reduce

        public double reduce(Op2 op)
        Description copied from interface: INDArray
        Reduces over all elements of the array in row-major order. Applies the operator to the previous result at each step. Returns the final result.
        Specified by:
        reduce in interface INDArray
        Overrides:
        reduce in class AVector
      • normalise

        public double normalise()
        Description copied from class: AVector
        Normalises this vector to a magnitude of 1.0 Has no effect on a zero-length vector (i.e. it will remain zero)
        Specified by:
        normalise in interface IVector
        Overrides:
        normalise in class AVector
        Returns:
        the magnitude of the original vector
      • of

        public static Vector3 of(double x,
                                 double y,
                                 double z)
      • of

        public static Vector3 of(double... values)
      • create

        public static Vector3 create(java.lang.Object o)
      • isZero

        public boolean isZero()
        Description copied from class: AVector
        Returns true if this vector is a zero vector (all components zero)
        Specified by:
        isZero in interface INDArray
        Overrides:
        isZero in class AVector
      • angle

        public double angle(AVector v)
        Description copied from class: AVector
        Returns the Euclidean angle between this vector and another vector
        Overrides:
        angle in class AVector
        Returns:
        angle in radians
      • angle

        public double angle(Vector3 v)
      • add

        public void add(double dx,
                        double dy,
                        double dz)
      • distanceSquared

        public double distanceSquared(Vector3 v)
      • distance

        public double distance(Vector3 v)
      • distance

        public double distance(AVector v)
        Description copied from class: AVector
        Returns the Euclidean distance to another vector.
        Overrides:
        distance in class AVector
        Returns:
      • magnitude

        public double magnitude()
        Description copied from class: AVector
        Returns the magnitude (Euclidean length) of the vector
        Overrides:
        magnitude in class AVector
        Returns:
      • set

        public void set(Vector3 a)
      • multiply

        public void multiply(double d)
        Description copied from class: AVector
        Multiplies the vector by a constant factor
        Specified by:
        multiply in interface INDArray
        Overrides:
        multiply in class AVector
        Parameters:
        d - Factor by which to multiply each component of the vector
      • multiplyCopy

        public Vector3 multiplyCopy(double d)
        Description copied from interface: INDArray
        Returns a copy of the array with all elements multiplied by a single constant value
        Specified by:
        multiplyCopy in interface INDArray
        Overrides:
        multiplyCopy in class AVector
        Parameters:
        d - A scalar factor
        Returns:
        A new array, with all element values scaled by the given factor
      • addMultiple

        public void addMultiple(double dx,
                                double dy,
                                double dz,
                                double factor)
      • addMultiple

        public void addMultiple(AVector v,
                                double factor)
        Description copied from class: AVector
        Adds a scaled multiple of another vector to this vector
        Overrides:
        addMultiple in class AVector
      • addMultiple

        public void addMultiple(Vector3 v,
                                double factor)
      • addProduct

        public void addProduct(Vector3 a,
                               Vector3 b,
                               double factor)
      • subtractMultiple

        public void subtractMultiple(Vector3 v,
                                     double factor)
      • add

        public void add(AVector v)
        Description copied from class: AVector
        Adds another vector to this one
        Overrides:
        add in class AVector
      • addCopy

        public Vector3 addCopy(AVector v)
        Description copied from interface: IVector
        Adds a vector element-wise to this vector, returning a new vector.
        Specified by:
        addCopy in interface IVector
        Overrides:
        addCopy in class AVector
        Returns:
      • add

        public void add(Vector3 v)
      • sub

        public void sub(Vector3 v)
      • subMultiple

        public void subMultiple(Vector3 v,
                                double factor)
      • dotProduct

        public double dotProduct(Vector3 a)
      • dotProduct

        public double dotProduct(AVector v)
        Description copied from class: AVector
        Returns the dot product of this vector with another vector The vectors must have the same length: if not the result is undefined
        Overrides:
        dotProduct in class AVector
        Returns:
      • dotProduct

        public double dotProduct(double[] data,
                                 int offset)
        Description copied from class: AVector
        Fast dot product with a double[] array. Performs no bounds checking. Likely to be faster than most other dot product operations
        Specified by:
        dotProduct in class AVector
      • crossProduct

        public void crossProduct(AVector a)
        Description copied from class: AVector
        Computes the crossProduct of this vector with another vector, and stores the result in this vector. Both vectors must have length 3.
        Overrides:
        crossProduct in class AVector
      • crossProduct

        public void crossProduct(Vector3 a)
        Description copied from class: AVector
        Computes the crossProduct of this vector with another vector, and stores the result in this vector. Both vectors must have length 3.
        Overrides:
        crossProduct in class AVector
      • projectToPlane

        public void projectToPlane(AVector normal,
                                   double distance)
        Description copied from class: AVector
        Projects the vector to the plane defined by: x.normal=distance
        Overrides:
        projectToPlane in class AVector
        Parameters:
        normal - A Vector of unit length
      • projectToPlane

        public void projectToPlane(Vector3 normal,
                                   double distance)
      • length

        public int length()
        Description copied from interface: IVector
        Returns the length of a vector, in terms of the number of elements. For Euclidean length, use magnitude() instead
        Specified by:
        length in interface IVector
        Specified by:
        length in class AVector
        Returns:
      • elementSum

        public double elementSum()
        Description copied from class: AVector
        Returns the sum of all elements in a vector
        Specified by:
        elementSum in interface INDArray
        Overrides:
        elementSum in class AVector
      • scaleAdd

        public void scaleAdd(double factor,
                             double constant)
        Description copied from class: AVector
        Scales this vector and adds a constant to every element
        Specified by:
        scaleAdd in interface INDArray
        Overrides:
        scaleAdd in class AVector
      • scaleAdd

        public void scaleAdd(double factor,
                             AVector constant)
        Description copied from class: AVector
        Scales this vector then adds another vector
        Overrides:
        scaleAdd in class AVector
      • scaleAdd

        public void scaleAdd(double factor,
                             Vector3 constant)
      • add

        public void add(double constant)
        Description copied from interface: INDArray
        Adds a double value to all elements in this array. Implementations may optimize the case of 0.0
        Specified by:
        add in interface INDArray
        Overrides:
        add in class AVector
      • get

        public double get(int i)
        Description copied from interface: INDArray
        Returns the double value at the specified position in a 1D vector
        Specified by:
        get in interface INDArray
        Specified by:
        get in interface IVector
        Specified by:
        get in class AVector
      • unsafeGet

        public double unsafeGet(int i)
        Description copied from class: AVector
        Like get, but performs no bounds checking. Results are undefined if the index is out of range
        Overrides:
        unsafeGet in class AVector
      • set

        public void set(AVector v)
        Description copied from class: AVector
        Sets the vector to equal the value of another vector
        Overrides:
        set in class AVector
      • fill

        public void fill(double v)
        Description copied from class: AVector
        Fills the entire vector with a given value
        Specified by:
        fill in interface INDArray
        Overrides:
        fill in class AVector
      • set

        public void set(int i,
                        double value)
        Description copied from interface: INDArray
        Sets a value at a given position in a mutable 1D array
        Specified by:
        set in interface INDArray
        Specified by:
        set in interface IVector
        Specified by:
        set in class AVector
      • unsafeSet

        public void unsafeSet(int i,
                              double value)
        Description copied from class: AVector
        Like set, but performs no bounds checking. Results are undefined if the index is out of range
        Overrides:
        unsafeSet in class AVector
      • addAt

        public void addAt(int i,
                          double value)
        Description copied from class: AVector
        Adds a value to a specific element of the vector This function does not perform bounds checking, i.e. is an unsafe operation
        Overrides:
        addAt in class AVector
      • setValues

        public void setValues(double x,
                              double y,
                              double z)
      • negate

        public void negate()
        Description copied from class: AVector
        Negates all emlements of this vector in place.
        Specified by:
        negate in interface INDArray
        Overrides:
        negate in class AVector
      • getElements

        public void getElements(double[] data,
                                int offset)
        Description copied from interface: INDArray
        Copies all elements of this array a double array at the specified offset
        Specified by:
        getElements in interface INDArray
        Overrides:
        getElements in class AVector
      • toDoubleBuffer

        public void toDoubleBuffer(java.nio.DoubleBuffer dest)
        Description copied from interface: INDArray
        Copies the elements of this INDArray to the specified double buffer.
        Specified by:
        toDoubleBuffer in interface INDArray
        Overrides:
        toDoubleBuffer in class AVector
      • toDoubleArray

        public double[] toDoubleArray()
        Description copied from interface: INDArray
        Copies the elements of this array to a new double[] array.
        Specified by:
        toDoubleArray in interface INDArray
        Overrides:
        toDoubleArray in class AVector
      • toNormal

        public Vector3 toNormal()
        Description copied from class: AVector
        Creates a new mutable vector representing the normalised value of this vector Returns null if the vector cannot be normalised (i.e. is a zero length vector)
        Overrides:
        toNormal in class APrimitiveVector
        Returns:
      • clone

        public Vector3 clone()
        Description copied from class: AVector
        Clones the vector, creating a new mutable copy of all data. The clone is: - not guaranteed to be of the same type. - guaranteed to be fully mutable - guaranteed not to contain a reference (i.e. is a full deep copy)
        Specified by:
        clone in interface INDArray
        Specified by:
        clone in interface IVector
        Specified by:
        clone in class APrimitiveVector
      • copy

        public Vector3 copy()
        Description copied from interface: INDArray
        Returns a defensive copy of the array data. Use this if the original array might change and you need a defensive copy. May return the same array if the original was immutable, otherwise will return a defensive copy.
        Specified by:
        copy in interface INDArray
        Overrides:
        copy in class AVector
      • equals

        public boolean equals(AVector v)
        Description copied from class: AbstractArray
        Returns true if this array is exactly equal to a vector.
        Overrides:
        equals in class AVector
        Returns:
      • equals

        public boolean equals(Vector3 v)
      • equalsArray

        public boolean equalsArray(double[] data,
                                   int offset)
        Description copied from class: AVector
        Returns true if this vector exactly matches the elements in double[] array, starting from the specified offset
        Specified by:
        equalsArray in interface INDArray
        Overrides:
        equalsArray in class AVector
        Parameters:
        data - Array of double element values to check for equality
        offset - Offset into the data array
        Returns:

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.