com.io7m.jtensors.parameterized

## Class PVectorI4F<T>

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

- Type Parameters:
    `T` - A phantom type parameter.
  All Implemented Interfaces:
    PVectorReadable2FType<T>, PVectorReadable3FType<T>, PVectorReadable4FType<T>, VectorReadable2FType, VectorReadable3FType, VectorReadable4FType

      @Immutable
      public final class PVectorI4F<T>
      extends Object
      implements PVectorReadable4FType<T>

  A four-dimensional immutable vector type with `float` elements.

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

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PVectorI4F()` Default constructor, initializing the vector with values `[0.0, 0.0, 0.0, 1.0]`.
    `PVectorI4F(float in_x, float in_y, float in_z, float in_w)` Construct a vector initialized with the given values.
    `PVectorI4F(PVectorReadable4FType<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> PVectorI4F<T>` | `absolute(PVectorReadable4FType<T> v)` Calculate the absolute value of the vector `v`.
    `static <T> PVectorI4F<T>` | `add(PVectorReadable4FType<T> v0, PVectorReadable4FType<T> v1)` Calculate the element-wise sum of the vectors `v0` and `v1`.
    `static <T> PVectorI4F<T>` | `addScaled(PVectorReadable4FType<T> v0, PVectorReadable4FType<T> v1, float r)` Calculate the element-wise sum of the vectors `v0` and the element-wise product of `v1` and `r`.
    `static <T> boolean` | `almostEqual(com.io7m.jequality.AlmostEqualFloat.ContextRelative context, PVectorReadable4FType<T> va, PVectorReadable4FType<T> vb)` Determine whether or not the vectors `va` and `vb` are equal to within the degree of error given in `context`.
    `static <T> PVectorI4F<T>` | `clamp(PVectorReadable4FType<T> v, float minimum, float maximum)` Clamp the elements of the vector `v` to the range {@code [minimum ..
    `static <T> PVectorI4F<T>` | `clampByPVector(PVectorReadable4FType<T> v, PVectorReadable4FType<T> minimum, PVectorReadable4FType<T> maximum)` Clamp the elements of the vector `v` to the inclusive range given by the corresponding elements in `minimum` and `maximum`.
    `static <T> PVectorI4F<T>` | `clampMaximum(PVectorReadable4FType<T> v, float maximum)` Clamp the elements of the vector `v` to the range {@code [-Infinity ..
    `static <T> PVectorI4F<T>` | `clampMaximumByPVector(PVectorReadable4FType<T> v, PVectorReadable4FType<T> maximum)` Clamp the elements of the vector `v` to the inclusive range given by the corresponding elements in `maximum`.
    `static <T> PVectorI4F<T>` | `clampMinimum(PVectorReadable4FType<T> v, float minimum)` Clamp the elements of the vector `v` to the range {@code [minimum ..
    `static <T> PVectorI4F<T>` | `clampMinimumByPVector(PVectorReadable4FType<T> v, PVectorReadable4FType<T> minimum)` Clamp the elements of the vector `v` to the inclusive range given by the corresponding elements in `minimum`.
    `static <T> float` | `distance(PVectorReadable4FType<T> v0, PVectorReadable4FType<T> v1)` Calculate the distance between the two vectors `v0` and `v1`.
    `static <T> float` | `dotProduct(PVectorReadable4FType<T> v0, PVectorReadable4FType<T> v1)` Calculate the scalar product of the vectors `v0` and `v1`.
    `boolean` | `equals(Object obj)`
    `float` | `getWF()`
    `float` | `getXF()`
    `float` | `getYF()`
    `float` | `getZF()`
    `int` | `hashCode()`
    `static <T> PVectorI4F<T>` | `interpolateLinear(PVectorReadable4FType<T> v0, PVectorReadable4FType<T> v1, float alpha)` Linearly interpolate between `v0` and `v1` by the amount `alpha`.
    `static <T> float` | `magnitude(PVectorReadable4FType<T> v)` Calculate the magnitude of the vector `v`.
    `static <T> float` | `magnitudeSquared(PVectorReadable4FType<T> v)` Calculate the squared magnitude of the vector `v`.
    `static <T> PVectorI4F<T>` | `normalize(PVectorReadable4FType<T> v)` Normalize the vector `v`, preserving its direction but reducing it to unit length.
    `static <T> com.io7m.jfunctional.Pair<PVectorI4F<T>,PVectorI4F<T>>` | `orthoNormalize(PVectorReadable4FType<T> v0, PVectorReadable4FType<T> v1)` Orthonormalize and return the vectors `v0` and `v1` .
    `static <T> PVectorI4F<T>` | `projection(PVectorReadable4FType<T> p, PVectorReadable4FType<T> q)` Calculate the projection of the vector `p` onto the vector `q`.
    `static <T> PVectorI4F<T>` | `scale(PVectorReadable4FType<T> v, float r)` Scale the vector `v` by the scalar `r`.
    `static <T> PVectorI4F<T>` | `subtract(PVectorReadable4FType<T> v0, PVectorReadable4FType<T> v1)` Subtract the vector `v1` from the vector `v0`.
    `String` | `toString()`
    `static <T> PVectorI4F<T>` | `zero()`

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

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

- - ### Constructor Detail

    - #### PVectorI4F

          public PVectorI4F()

      Default constructor, initializing the vector with values `[0.0, 0.0, 0.0, 1.0]`.

    - #### PVectorI4F

          public PVectorI4F(float in_x,
                            float in_y,
                            float in_z,
                            float 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

    - #### PVectorI4F

          public PVectorI4F(PVectorReadable4FType<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> PVectorI4F<T> absolute(PVectorReadable4FType<T> v)

      Calculate the absolute value of the vector `v`.
      Type Parameters:
        `T` - A phantom type parameter.
      Parameters:
        `v` - The input vector
      Returns:
        `(abs v.getXF(), abs v.getYF(), abs v.getZF(), abs v.getWF())`

    - #### add

          public static <T> PVectorI4F<T> add(PVectorReadable4FType<T> v0,
                                              PVectorReadable4FType<T> v1)

      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.getXF() + v1.getXF(), v0.getYF() + v1.getYF(), v0.getZF() + v1.getZF(), v0.getWF() + v1.getWF())`

    - #### addScaled

          public static <T> PVectorI4F<T> addScaled(PVectorReadable4FType<T> v0,
                                                    PVectorReadable4FType<T> v1,
                                                    float r)

      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.getXF() + (v1.getXF() * r), v0.getYF() + (v1.getYF() * r), v0.getZF() + (v1.getZF() * r), v0.getWF() + (v1.getWF() * r))`

    - #### almostEqual

          public static <T> boolean almostEqual(com.io7m.jequality.AlmostEqualFloat.ContextRelative context,
                                                PVectorReadable4FType<T> va,
                                                PVectorReadable4FType<T> vb)

      Determine whether or not the vectors `va` and `vb` are equal to within the degree of error given in `context`.
      Type Parameters:
        `T` - A phantom type parameter.
      Parameters:
        `context` - The equality context
        `va` - The left input vector
        `vb` - The right input vector
      Returns:
        `true` iff the vectors are almost equal.
      Since:
        7.0.0
      See Also:
        `AlmostEqualFloat.almostEqual(AlmostEqualFloat.ContextRelative, float, float)`

    - #### clamp

          public static <T> PVectorI4F<T> clamp(PVectorReadable4FType<T> v,
                                                float minimum,
                                                float 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`

    - #### clampByPVector

          public static <T> PVectorI4F<T> clampByPVector(PVectorReadable4FType<T> v,
                                                         PVectorReadable4FType<T> minimum,
                                                         PVectorReadable4FType<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.getXF(), minimum.getXF()), maximum.getXF()), min(max(v.getYF(), minimum.getYF()), maximum.getYF()), min(max(v.getZF(), minimum.getZF()), maximum.getZF()), min(max(v.getWF(), minimum.getWF()), maximum.getWF()) )`

    - #### clampMaximum

          public static <T> PVectorI4F<T> clampMaximum(PVectorReadable4FType<T> v,
                                                       float 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`

    - #### clampMaximumByPVector

          public static <T> PVectorI4F<T> clampMaximumByPVector(PVectorReadable4FType<T> v,
                                                                PVectorReadable4FType<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.getXF(), maximum.getXF()), min(v.getYF(), maximum.getYF()), min(v.getZF(), maximum.getZF()), min(v.getWF(), maximum.getWF()))`

    - #### clampMinimum

          public static <T> PVectorI4F<T> clampMinimum(PVectorReadable4FType<T> v,
                                                       float 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`.

    - #### clampMinimumByPVector

          public static <T> PVectorI4F<T> clampMinimumByPVector(PVectorReadable4FType<T> v,
                                                                PVectorReadable4FType<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.getXF(), minimum.getXF()), max(v.getYF(), minimum.getYF()), max(v.getZF(), minimum.getZF()), max(v.getWF(), minimum.getWF()))`

    - #### distance

          public static <T> float distance(PVectorReadable4FType<T> v0,
                                           PVectorReadable4FType<T> v1)

      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

    - #### dotProduct

          public static <T> float dotProduct(PVectorReadable4FType<T> v0,
                                             PVectorReadable4FType<T> v1)

      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

    - #### interpolateLinear

          public static <T> PVectorI4F<T> interpolateLinear(PVectorReadable4FType<T> v0,
                                                            PVectorReadable4FType<T> v1,
                                                            float alpha)

      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) = v0`
      - `interpolateLinear(v0, v1, 1.0) = 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`

    - #### magnitude

          public static <T> float magnitude(PVectorReadable4FType<T> v)

      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

    - #### magnitudeSquared

          public static <T> float magnitudeSquared(PVectorReadable4FType<T> v)

      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

    - #### normalize

          public static <T> PVectorI4F<T> normalize(PVectorReadable4FType<T> v)

      Normalize the vector `v`, preserving its direction but reducing it to unit length.
      Type Parameters:
        `T` - A phantom type parameter.
      Parameters:
        `v` - The input vector
      Returns:
        A vector with the same orientation as `v` but with magnitude equal to `1.0`

    - #### orthoNormalize

          public static <T> com.io7m.jfunctional.Pair<PVectorI4F<T>,PVectorI4F<T>> orthoNormalize(PVectorReadable4FType<T> v0,
                                                                                                  PVectorReadable4FType<T> v1)

      Orthonormalize and return the vectors `v0` and `v1` .

      See GSP

      Type Parameters:
        `T` - A phantom type parameter.
      Parameters:
        `v0` - The left vector
        `v1` - The right vector
      Returns:
        A pair `(v0, v1)`, orthonormalized.
      Since:
        7.0.0

    - #### projection

          public static <T> PVectorI4F<T> projection(PVectorReadable4FType<T> p,
                                                     PVectorReadable4FType<T> q)

      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`

    - #### scale

          public static <T> PVectorI4F<T> scale(PVectorReadable4FType<T> v,
                                                float r)

      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.getXF() * r, v.getYF() * r, v.getZF() * r, v.getWF() * r)`

    - #### subtract

          public static <T> PVectorI4F<T> subtract(PVectorReadable4FType<T> v0,
                                                   PVectorReadable4FType<T> v1)

      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.getXF() - v1.getXF(), v0.getYF() - v1.getYF(), v0.getZF() - v1.getZF())`

    - #### zero

          public static <T> PVectorI4F<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`

    - #### getWF

          public float getWF()

      Specified by:
        `getWF` in interface `VectorReadable4FType`
      Returns:
        The W value of the given vector.

    - #### getXF

          public float getXF()

      Specified by:
        `getXF` in interface `VectorReadable2FType`
      Returns:
        The X value of the given vector.

    - #### getYF

          public float getYF()

      Specified by:
        `getYF` in interface `VectorReadable2FType`
      Returns:
        The Y value of the given vector.

    - #### getZF

          public float getZF()

      Specified by:
        `getZF` in interface `VectorReadable3FType`
      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