com.io7m.jtensors

## Class VectorI4L

- java.lang.Object
- - com.io7m.jtensors.VectorI4L

- All Implemented Interfaces:
    VectorReadable2LType, VectorReadable3LType, VectorReadable4LType

      @Immutable
      public final class VectorI4L
      extends Object
      implements VectorReadable4LType

  A four-dimensional immutable vector type with integer elements.

  Values of this type are immutable and can therefore be safely accessed from multiple threads.

  Since:
    5.3.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static VectorI4L` | `ZERO` The zero vector.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `VectorI4L()` Default constructor, initializing the vector with values `[0, 0, 0, 1]`.
    `VectorI4L(long in_x, long in_y, long in_z, long in_w)` Construct a vector initialized with the given values.
    `VectorI4L(VectorReadable4LType in_v)` Construct a vector initialized with the values given in the vector `in_v`.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static VectorI4L` | `absolute(VectorReadable4LType v)` Calculate the absolute values of the elements in vector `v`.
    `static VectorI4L` | `add(VectorReadable4LType v0, VectorReadable4LType v1)` Calculate the element-wise sum of the vectors `v0` and `v1`.
    `static VectorI4L` | `addScaled(VectorReadable4LType v0, VectorReadable4LType v1, double r)` Calculate the element-wise sum of the vectors `v0` and the element-wise product of `v1` and `r`.
    `static VectorI4L` | `clamp(VectorReadable4LType v, long minimum, long maximum)` Clamp the elements of the vector `v` to the range {@code [minimum ..
    `static VectorI4L` | `clampByVector(VectorReadable4LType v, VectorReadable4LType minimum, VectorReadable4LType maximum)` Clamp the elements of the vector `v` to the inclusive range given by the corresponding elements in `minimum` and `maximum`.
    `static VectorI4L` | `clampMaximum(VectorReadable4LType v, long maximum)` Clamp the elements of the vector `v` to the range {@code [-Infinity ..
    `static VectorI4L` | `clampMaximumByVector(VectorReadable4LType v, VectorReadable4LType maximum)` Clamp the elements of the vector `v` to the inclusive range given by the corresponding elements in `maximum`.
    `static VectorI4L` | `clampMinimum(VectorReadable4LType v, long minimum)` Clamp the elements of the vector `v` to the range {@code [minimum ..
    `static VectorI4L` | `clampMinimumByVector(VectorReadable4LType v, VectorReadable4LType minimum)` Clamp the elements of the vector `v` to the inclusive range given by the corresponding elements in `minimum`.
    `static long` | `distance(VectorReadable4LType v0, VectorReadable4LType v1)` Calculate the distance between the two vectors `v0` and `v1`.
    `static long` | `dotProduct(VectorReadable4LType v0, VectorReadable4LType v1)` Calculate the scalar product of the vectors `v0` and `v1`.
    `boolean` | `equals(Object obj)`
    `long` | `getWL()`
    `long` | `getXL()`
    `long` | `getYL()`
    `long` | `getZL()`
    `int` | `hashCode()`
    `static VectorI4L` | `interpolateLinear(VectorReadable4LType v0, VectorReadable4LType v1, double alpha)` Linearly interpolate between `v0` and `v1` by the amount `alpha`.
    `static long` | `magnitude(VectorReadable4LType v)` Calculate the magnitude of the vector `v`.
    `static long` | `magnitudeSquared(VectorReadable4LType v)` Calculate the squared magnitude of the vector `v`.
    `static VectorI4L` | `projection(VectorReadable4LType p, VectorReadable4LType q)` Calculate the projection of the vector `p` onto the vector `q`.
    `static VectorI4L` | `scale(VectorReadable4LType v, double r)` Scale the vector `v` by the scalar `r`.
    `static VectorI4L` | `subtract(VectorReadable4LType v0, VectorReadable4LType v1)` Subtract the vector `v1` from the vector `v0`.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### ZERO

          public static final VectorI4L ZERO

      The zero vector.

  - ### Constructor Detail

    - #### VectorI4L

          public VectorI4L()

      Default constructor, initializing the vector with values `[0, 0, 0, 1]`.

    - #### VectorI4L

          public VectorI4L(long in_x,
                           long in_y,
                           long in_z,
                           long in_w)

      Construct a vector initialized with the given values.
      Parameters:
        `in_x` - The `x` value
        `in_y` - The `y` value
        `in_z` - The `z` value
        `in_w` - The `w` value

    - #### VectorI4L

          public VectorI4L(VectorReadable4LType in_v)

      Construct a vector initialized with the values given in the vector `in_v`.
      Parameters:
        `in_v` - The source vector

  - ### Method Detail

    - #### absolute

          public static VectorI4L absolute(VectorReadable4LType v)
                                    throws ArithmeticException

      Calculate the absolute values of the elements in vector `v`.
      Parameters:
        `v` - The input vector
      Returns:
        `(abs v.x, abs v.y, abs v.z, abs.w)`
      Throws:
        `ArithmeticException` - Iff an internal arithmetic operation causes an integer overflow
      Since:
        5.0.0

    - #### add

          public static VectorI4L add(VectorReadable4LType v0,
                                      VectorReadable4LType v1)
                               throws ArithmeticException

      Calculate the element-wise sum of the vectors `v0` and `v1`.
      Parameters:
        `v0` - The left input vector
        `v1` - The right input vector
      Returns:
        `(v0.x + v1.x, v0.y + v1.y, v0.z + v1.z, v0.w + v1.w)`
      Throws:
        `ArithmeticException` - Iff an internal arithmetic operation causes an integer overflow

    - #### addScaled

          public static VectorI4L addScaled(VectorReadable4LType v0,
                                            VectorReadable4LType v1,
                                            double r)
                                     throws ArithmeticException

      Calculate the element-wise sum of the vectors `v0` and the element-wise product of `v1` and `r`.
      Parameters:
        `v0` - The left input vector
        `v1` - The right input vector
        `r` - The scaling value
      Returns:
        `(v0.x + (v1.x * r), v0.y + (v1.y * r), v0.z + (v1.z * r), v0.w + (v1.w * r))`
      Throws:
        `ArithmeticException` - Iff an internal arithmetic operation causes an integer overflow

    - #### clamp

          public static VectorI4L clamp(VectorReadable4LType v,
                                        long minimum,
                                        long maximum)

      Clamp the elements of the vector `v` to the range `[minimum .. maximum]` inclusive.
      Parameters:
        `v` - The input vector
        `minimum` - The minimum allowed value
        `maximum` - The maximum allowed value
      Returns:
        A vector with both elements equal to at most `maximum` and at least `minimum`
      Since:
        5.0.0

    - #### clampByVector

          public static VectorI4L clampByVector(VectorReadable4LType v,
                                                VectorReadable4LType minimum,
                                                VectorReadable4LType maximum)

      Clamp the elements of the vector `v` to the inclusive range given by the corresponding elements in `minimum` and `maximum`.
      Parameters:
        `v` - The input vector
        `minimum` - The vector containing the minimum acceptable values
        `maximum` - The vector containing the maximum acceptable values
      Returns:
        `(min(max(v.x, minimum.x), maximum.x), min(max(v.y, minimum.y), maximum.y), min(max(v.z, minimum.z), maximum.z), min(max(v.w, minimum.w), maximum.w))`
      Since:
        5.0.0

    - #### clampMaximum

          public static VectorI4L clampMaximum(VectorReadable4LType v,
                                               long maximum)

      Clamp the elements of the vector `v` to the range `[-Infinity .. maximum]` inclusive.
      Parameters:
        `v` - The input vector
        `maximum` - The maximum allowed value
      Returns:
        A vector with both elements equal to at most `maximum`
      Since:
        5.0.0

    - #### clampMaximumByVector

          public static VectorI4L clampMaximumByVector(VectorReadable4LType v,
                                                       VectorReadable4LType maximum)

      Clamp the elements of the vector `v` to the inclusive range given by the corresponding elements in `maximum`.
      Parameters:
        `v` - The input vector
        `maximum` - The vector containing the maximum acceptable values
      Returns:
        `(min(v.x, maximum.x), min(v.y, maximum.y), min(v.z, maximum.z), min(v.w, maximum.w))`
      Since:
        5.0.0

    - #### clampMinimum

          public static VectorI4L clampMinimum(VectorReadable4LType v,
                                               long minimum)

      Clamp the elements of the vector `v` to the range `[minimum .. Infinity]` inclusive.
      Parameters:
        `v` - The input vector
        `minimum` - The minimum allowed value
      Returns:
        A vector with both elements equal to at least `minimum`
      Since:
        5.0.0

    - #### clampMinimumByVector

          public static VectorI4L clampMinimumByVector(VectorReadable4LType v,
                                                       VectorReadable4LType minimum)

      Clamp the elements of the vector `v` to the inclusive range given by the corresponding elements in `minimum`.
      Parameters:
        `v` - The input vector
        `minimum` - The vector containing the minimum acceptable values
      Returns:
        `(max(v.x, minimum.x), max(v.y, minimum.y), max(v.z, minimum.z), max(v.w, minimum.w))`
      Since:
        5.0.0

    - #### distance

          public static long distance(VectorReadable4LType v0,
                                      VectorReadable4LType v1)
                               throws ArithmeticException

      Calculate the distance between the two vectors `v0` and `v1`.
      Parameters:
        `v0` - The left input vector
        `v1` - The right input vector
      Returns:
        The distance between the two vectors.
      Throws:
        `ArithmeticException` - Iff an internal arithmetic operation causes an integer overflow
      Since:
        5.0.0

    - #### dotProduct

          public static long dotProduct(VectorReadable4LType v0,
                                        VectorReadable4LType v1)
                                 throws ArithmeticException

      Calculate the scalar product of the vectors `v0` and `v1`.
      Parameters:
        `v0` - The left input vector
        `v1` - The right input vector
      Returns:
        The scalar product of the two vectors
      Throws:
        `ArithmeticException` - Iff an internal arithmetic operation causes an integer overflow
      Since:
        5.0.0

    - #### interpolateLinear

          public static VectorI4L interpolateLinear(VectorReadable4LType v0,
                                                    VectorReadable4LType v1,
                                                    double alpha)
                                             throws ArithmeticException

      Linearly interpolate between `v0` and `v1` by the amount `alpha`. The `alpha` parameter controls the degree of interpolation, such that:
      - `interpolateLinear(v0, v1, 0.0, r) -> r = v0`
      - `interpolateLinear(v0, v1, 1.0, r) -> r = v1`
      Parameters:
        `v0` - The left input vector.
        `v1` - The right input vector.
        `alpha` - The interpolation value, between `0.0` and `1.0`.
      Returns:
        `(1 - alpha) * v0 + alpha * v1`
      Throws:
        `ArithmeticException` - Iff an internal arithmetic operation causes an integer overflow.
      Since:
        5.0.0

    - #### magnitude

          public static long magnitude(VectorReadable4LType v)
                                throws ArithmeticException

      Calculate the magnitude of the vector `v`. Correspondingly, `magnitude(normalize(v)) == 1.0`.
      Parameters:
        `v` - The input vector
      Returns:
        The magnitude of the input vector
      Throws:
        `ArithmeticException` - Iff an internal arithmetic operation causes an integer overflow
      Since:
        5.0.0

    - #### magnitudeSquared

          public static long magnitudeSquared(VectorReadable4LType v)
                                       throws ArithmeticException

      Calculate the squared magnitude of the vector `v`.
      Parameters:
        `v` - The input vector
      Returns:
        The squared magnitude of the input vector
      Throws:
        `ArithmeticException` - Iff an internal arithmetic operation causes an integer overflow
      Since:
        5.0.0

    - #### projection

          public static VectorI4L projection(VectorReadable4LType p,
                                             VectorReadable4LType q)
                                      throws ArithmeticException

      Calculate the projection of the vector `p` onto the vector `q`.
      Parameters:
        `p` - The left vector
        `q` - The right vector
      Returns:
        `((dotProduct p q) / magnitudeSquared q) * q`
      Throws:
        `ArithmeticException` - Iff an internal arithmetic operation causes an integer overflow
      Since:
        5.0.0

    - #### scale

          public static VectorI4L scale(VectorReadable4LType v,
                                        double r)
                                 throws ArithmeticException

      Scale the vector `v` by the scalar `r`.
      Parameters:
        `v` - The input vector
        `r` - The scaling value
      Returns:
        `(v.x * r, v.y * r, v.z * r, vw * r)`
      Throws:
        `ArithmeticException` - Iff an internal arithmetic operation causes an integer overflow

    - #### subtract

          public static VectorI4L subtract(VectorReadable4LType v0,
                                           VectorReadable4LType v1)
                                    throws ArithmeticException

      Subtract the vector `v1` from the vector `v0`.
      Parameters:
        `v0` - The left input vector
        `v1` - The right input vector
      Returns:
        `(v0.x - v1.x, v0.y - v1.y, v0.z - v1.z, v0.w - v1.w)`
      Throws:
        `ArithmeticException` - Iff an internal arithmetic operation causes an integer overflow

    - #### equals

          public boolean equals(@Nullable
                                Object obj)

      Overrides:
        `equals` in class `Object`

    - #### getWL

          public long getWL()

      Specified by:
        `getWL` in interface `VectorReadable4LType`
      Returns:
        The W value of the given vector.

    - #### getXL

          public long getXL()

      Specified by:
        `getXL` in interface `VectorReadable2LType`
      Returns:
        The X value of the given vector.

    - #### getYL

          public long getYL()

      Specified by:
        `getYL` in interface `VectorReadable2LType`
      Returns:
        The Y value of the given vector.

    - #### getZL

          public long getZL()

      Specified by:
        `getZL` in interface `VectorReadable3LType`
      Returns:
        The Z value of the given vector.

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2015 <code@io7m.com> http://io7m.com