com.io7m.jtensors.parameterized

## Class PVectorI4I<T>

- java.lang.Object
- - com.io7m.jtensors.parameterized.PVectorI4I<T>

- Type Parameters:
    `T` - A phantom type parameter.
  All Implemented Interfaces:
    PVectorReadable2IType<T>, PVectorReadable3IType<T>, PVectorReadable4IType<T>, VectorReadable2IType, VectorReadable3IType, VectorReadable4IType

      @Immutable
      public final class PVectorI4I<T>
      extends Object
      implements PVectorReadable4IType<T>

  A four-dimensional immutable vector type with integer elements.

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

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PVectorI4I()` Default constructor, initializing the vector with values `[0, 0, 0, 1]`.
    `PVectorI4I(int in_x, int in_y, int in_z, int in_w)` Construct a vector initialized with the given values.
    `PVectorI4I(PVectorReadable4IType<T> 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 <T> PVectorI4I<T>` | `absolute(PVectorReadable4IType<T> v)` Calculate the absolute values of the elements in vector `v`.
    `static <T> PVectorI4I<T>` | `add(PVectorReadable4IType<T> v0, PVectorReadable4IType<T> v1)` Calculate the element-wise sum of the vectors `v0` and `v1`.
    `static <T> PVectorI4I<T>` | `addScaled(PVectorReadable4IType<T> v0, PVectorReadable4IType<T> v1, double r)` Calculate the element-wise sum of the vectors `v0` and the element-wise product of `v1` and `r`.
    `static <T> PVectorI4I<T>` | `clamp(PVectorReadable4IType<T> v, int minimum, int maximum)` Clamp the elements of the vector `v` to the range {@code [minimum ..
    `static <T> PVectorI4I<T>` | `clampByPVector(PVectorReadable4IType<T> v, PVectorReadable4IType<T> minimum, PVectorReadable4IType<T> maximum)` Clamp the elements of the vector `v` to the inclusive range given by the corresponding elements in `minimum` and `maximum`.
    `static <T> PVectorI4I<T>` | `clampMaximum(PVectorReadable4IType<T> v, int maximum)` Clamp the elements of the vector `v` to the range {@code [-Infinity ..
    `static <T> PVectorI4I<T>` | `clampMaximumByPVector(PVectorReadable4IType<T> v, PVectorReadable4IType<T> maximum)` Clamp the elements of the vector `v` to the inclusive range given by the corresponding elements in `maximum`.
    `static <T> PVectorI4I<T>` | `clampMinimum(PVectorReadable4IType<T> v, int minimum)` Clamp the elements of the vector `v` to the range {@code [minimum ..
    `static <T> PVectorI4I<T>` | `clampMinimumByPVector(PVectorReadable4IType<T> v, PVectorReadable4IType<T> minimum)` Clamp the elements of the vector `v` to the inclusive range given by the corresponding elements in `minimum`.
    `static <T> int` | `distance(PVectorReadable4IType<T> v0, PVectorReadable4IType<T> v1)` Calculate the distance between the two vectors `v0` and `v1`.
    `static <T> int` | `dotProduct(PVectorReadable4IType<T> v0, PVectorReadable4IType<T> v1)` Calculate the scalar product of the vectors `v0` and `v1`.
    `boolean` | `equals(Object obj)`
    `int` | `getWI()`
    `int` | `getXI()`
    `int` | `getYI()`
    `int` | `getZI()`
    `int` | `hashCode()`
    `static <T> PVectorI4I<T>` | `interpolateLinear(PVectorReadable4IType<T> v0, PVectorReadable4IType<T> v1, double alpha)` Linearly interpolate between `v0` and `v1` by the amount `alpha`.
    `static <T> int` | `magnitude(PVectorReadable4IType<T> v)` Calculate the magnitude of the vector `v`.
    `static <T> int` | `magnitudeSquared(PVectorReadable4IType<T> v)` Calculate the squared magnitude of the vector `v`.
    `static <T> PVectorI4I<T>` | `projection(PVectorReadable4IType<T> p, PVectorReadable4IType<T> q)` Calculate the projection of the vector `p` onto the vector `q`.
    `static <T> PVectorI4I<T>` | `scale(PVectorReadable4IType<T> v, double r)` Scale the vector `v` by the scalar `r`.
    `static <T> PVectorI4I<T>` | `subtract(PVectorReadable4IType<T> v0, PVectorReadable4IType<T> v1)` Subtract the vector `v1` from the vector `v0`.
    `String` | `toString()`
    `static <T> PVectorI4I<T>` | `zero()`

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

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

- - ### Constructor Detail

    - #### PVectorI4I

          public PVectorI4I()

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

    - #### PVectorI4I

          public PVectorI4I(int in_x,
                            int in_y,
                            int in_z,
                            int 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

    - #### PVectorI4I

          public PVectorI4I(PVectorReadable4IType<T> 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 <T> PVectorI4I<T> absolute(PVectorReadable4IType<T> v)
                                            throws ArithmeticException

      Calculate the absolute values of the elements in vector `v`.
      Type Parameters:
        `T` - A phantom type parameter.
      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:
        7.0.0

    - #### add

          public static <T> PVectorI4I<T> add(PVectorReadable4IType<T> v0,
                                              PVectorReadable4IType<T> v1)
                                       throws ArithmeticException

      Calculate the element-wise sum of the vectors `v0` and `v1`.
      Type Parameters:
        `T` - A phantom type parameter.
      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 <T> PVectorI4I<T> addScaled(PVectorReadable4IType<T> v0,
                                                    PVectorReadable4IType<T> v1,
                                                    double r)
                                             throws ArithmeticException

      Calculate the element-wise sum of the vectors `v0` and the element-wise product of `v1` and `r`.
      Type Parameters:
        `T` - A phantom type parameter.
      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 <T> PVectorI4I<T> clamp(PVectorReadable4IType<T> v,
                                                int minimum,
                                                int maximum)

      Clamp the elements of the vector `v` to the range `[minimum .. maximum]` inclusive.
      Type Parameters:
        `T` - A phantom type parameter.
      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:
        7.0.0

    - #### clampByPVector

          public static <T> PVectorI4I<T> clampByPVector(PVectorReadable4IType<T> v,
                                                         PVectorReadable4IType<T> minimum,
                                                         PVectorReadable4IType<T> maximum)

      Clamp the elements of the vector `v` to the inclusive range given by the corresponding elements in `minimum` and `maximum`.
      Type Parameters:
        `T` - A phantom type parameter.
      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:
        7.0.0

    - #### clampMaximum

          public static <T> PVectorI4I<T> clampMaximum(PVectorReadable4IType<T> v,
                                                       int maximum)

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

    - #### clampMaximumByPVector

          public static <T> PVectorI4I<T> clampMaximumByPVector(PVectorReadable4IType<T> v,
                                                                PVectorReadable4IType<T> maximum)

      Clamp the elements of the vector `v` to the inclusive range given by the corresponding elements in `maximum`.
      Type Parameters:
        `T` - A phantom type parameter.
      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:
        7.0.0

    - #### clampMinimum

          public static <T> PVectorI4I<T> clampMinimum(PVectorReadable4IType<T> v,
                                                       int minimum)

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

    - #### clampMinimumByPVector

          public static <T> PVectorI4I<T> clampMinimumByPVector(PVectorReadable4IType<T> v,
                                                                PVectorReadable4IType<T> minimum)

      Clamp the elements of the vector `v` to the inclusive range given by the corresponding elements in `minimum`.
      Type Parameters:
        `T` - A phantom type parameter.
      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:
        7.0.0

    - #### distance

          public static <T> int distance(PVectorReadable4IType<T> v0,
                                         PVectorReadable4IType<T> v1)
                                  throws ArithmeticException

      Calculate the distance between the two vectors `v0` and `v1`.
      Type Parameters:
        `T` - A phantom type parameter.
      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:
        7.0.0

    - #### dotProduct

          public static <T> int dotProduct(PVectorReadable4IType<T> v0,
                                           PVectorReadable4IType<T> v1)
                                    throws ArithmeticException

      Calculate the scalar product of the vectors `v0` and `v1`.
      Type Parameters:
        `T` - A phantom type parameter.
      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:
        7.0.0

    - #### interpolateLinear

          public static <T> PVectorI4I<T> interpolateLinear(PVectorReadable4IType<T> v0,
                                                            PVectorReadable4IType<T> 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`
      Type Parameters:
        `T` - A phantom type parameter.
      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:
        7.0.0

    - #### magnitude

          public static <T> int magnitude(PVectorReadable4IType<T> v)
                                   throws ArithmeticException

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

    - #### magnitudeSquared

          public static <T> int magnitudeSquared(PVectorReadable4IType<T> v)
                                          throws ArithmeticException

      Calculate the squared magnitude of the vector `v`.
      Type Parameters:
        `T` - A phantom type parameter.
      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:
        7.0.0

    - #### projection

          public static <T> PVectorI4I<T> projection(PVectorReadable4IType<T> p,
                                                     PVectorReadable4IType<T> q)
                                              throws ArithmeticException

      Calculate the projection of the vector `p` onto the vector `q`.
      Type Parameters:
        `T` - A phantom type parameter.
      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:
        7.0.0

    - #### scale

          public static <T> PVectorI4I<T> scale(PVectorReadable4IType<T> v,
                                                double r)
                                         throws ArithmeticException

      Scale the vector `v` by the scalar `r`.
      Type Parameters:
        `T` - A phantom type parameter.
      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 <T> PVectorI4I<T> subtract(PVectorReadable4IType<T> v0,
                                                   PVectorReadable4IType<T> v1)
                                            throws ArithmeticException

      Subtract the vector `v1` from the vector `v0`.
      Type Parameters:
        `T` - A phantom type parameter.
      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

    - #### zero

          public static <T> PVectorI4I<T> zero()

      Type Parameters:
        `T` - A phantom type parameter.
      Returns:
        The zero vector.

    - #### equals

          public boolean equals(@Nullable
                                Object obj)

      Overrides:
        `equals` in class `Object`

    - #### getWI

          public int getWI()

      Specified by:
        `getWI` in interface `VectorReadable4IType`
      Returns:
        The W value of the given vector.

    - #### getXI

          public int getXI()

      Specified by:
        `getXI` in interface `VectorReadable2IType`
      Returns:
        The X value of the given vector.

    - #### getYI

          public int getYI()

      Specified by:
        `getYI` in interface `VectorReadable2IType`
      Returns:
        The Y value of the given vector.

    - #### getZI

          public int getZI()

      Specified by:
        `getZI` in interface `VectorReadable3IType`
      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 © 2016 <code@io7m.com> http://io7m.com