org.dayflower.pathtracer.math

## Class Vector3F

• java.lang.Object
• org.dayflower.pathtracer.math.Vector3F

• ```public final class Vector3F
extends java.lang.Object```
A `Vector3F` denotes a 3-dimensional vector with elements denoted by X, Y and Z.

This class is immutable and therefore thread-safe.

Since:
1.0.0
Author:
Jörgen Lundgren
• ### Field Summary

Fields
Modifier and Type Field and Description
`float` `x`
The element value along the X-axis.
`float` `y`
The element value along the Y-axis.
`float` `z`
The element value along the Z-axis.
• ### Constructor Summary

Constructors
Constructor and Description
`Vector3F()`
Constructs a new `Vector3F` instance given its element values `0.0F`, `0.0F` and `0.0F`.
```Vector3F(float x, float y, float z)```
Constructs a new `Vector3F` instance given its element values `x`, `y` and `z`.
`Vector3F(Point3F p)`
Constructs a new `Vector3F` instance given a `Point3F`.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`Vector3F` `add(Vector3F v)`
Adds `v` to this `Vector3F` instance.
`Vector3F` `crossProduct(Vector3F v)`
Computes the cross product between this `Vector3F` instance and `v`.
`static Vector3F` ```direction(float u, float v)```
Returns a `Vector3F` based on the U- and V-coordinates `u` and `v`.
`static Vector3F` ```direction(Point3F eye, Point3F lookAt)```
Returns a `Vector3F` pointing in the direction from `eye` to `lookAt`.
`Vector3F` `divide(float s)`
Divides this `Vector3F` instance by `s`.
`float` `dotProduct(Vector3F v)`
Returns the dot product between this `Vector3F` instance and `v`.
`boolean` `equals(java.lang.Object object)`
Compares `object` to this `Vector3F` instance for equality.
`int` `hashCode()`
Returns a hash code for this `Vector3F` instance.
`float` `length()`
Returns the length of this `Vector3F` instance.
`float` `lengthSquared()`
Returns the length of this `Vector3F` instance in squared form.
`Vector3F` `multiply(float s)`
Multiplies this `Vector3F` instance with `s`.
`Vector3F` `negate()`
Negates this `Vector3F` instance.
`static Vector3F` ```normal(Point3F a, Point3F b, Point3F c)```
Returns a `Vector3F` denoting the normal of the plane defined by `a`, `b` and `c`.
`Vector3F` `normalize()`
Normalizes this `Vector3F` instance.
`static Vector3F` ```normalNormalized(Point3F a, Point3F b, Point3F c)```
Returns a `Vector3F` denoting the normalized normal of the plane defined by `a`, `b` and `c`.
`Vector3F` `subtract(Vector3F v)`
Subtracts `v` from this `Vector3F` instance.
`java.lang.String` `toString()`
Returns a `String` representation of this `Vector3F` instance.
`Vector3F` `transform(Matrix44F m)`
Performs a transformation.
`Vector3F` `transform(OrthoNormalBasis33F orthoNormalBasis)`
Performs a transformation.
`Vector3F` `transformReverse(OrthoNormalBasis33F orthoNormalBasis)`
Performs a transformation in reverse order.
`Vector3F` `transformTranspose(Matrix44F m)`
Performs a transformation in transpose order.
`static Vector3F` `x()`
Returns a new `Vector3F` instance equivalent to `new Vector3F(1.0F, 0.0F, 0.0F)`.
`static Vector3F` `x(float x)`
Returns a new `Vector3F` instance equivalent to `new Vector3F(x, 0.0F, 0.0F)`.
`static Vector3F` `y()`
Returns a new `Vector3F` instance equivalent to `new Vector3F(0.0F, 1.0F, 0.0F)`.
`static Vector3F` `y(float y)`
Returns a new `Vector3F` instance equivalent to `new Vector3F(0.0F, y, 0.0F)`.
`static Vector3F` `z()`
Returns a new `Vector3F` instance equivalent to `new Vector3F(0.0F, 0.0F, 1.0F)`.
`static Vector3F` `z(float z)`
Returns a new `Vector3F` instance equivalent to `new Vector3F(0.0F, 0.0F, z)`.
• ### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`
• ### Field Detail

• #### x

`public final float x`
The element value along the X-axis.
• #### y

`public final float y`
The element value along the Y-axis.
• #### z

`public final float z`
The element value along the Z-axis.
• ### Constructor Detail

• #### Vector3F

`public Vector3F()`
Constructs a new `Vector3F` instance given its element values `0.0F`, `0.0F` and `0.0F`.

Calling this constructor is equivalent to the following:

``` ```
new Vector3F(0.0F, 0.0F, 0.0F)
```
```
• #### Vector3F

```public Vector3F(float x,
float y,
float z)```
Constructs a new `Vector3F` instance given its element values `x`, `y` and `z`.
Parameters:
`x` - the element value along the X-axis
`y` - the element value along the Y-axis
`z` - the element value along the Z-axis
• #### Vector3F

`public Vector3F(Point3F p)`
Constructs a new `Vector3F` instance given a `Point3F`.

Calling this constructor is equivalent to the following:

``` ```
new Vector3F(p.x, p.y, p.z);
```
```
If `p` is `null`, a `NullPointerException` will be thrown.
Parameters:
`p` - a `Point3F`
Throws:
`java.lang.NullPointerException` - thrown if, and only if, `p` is `null`
• ### Method Detail

• #### toString

`public java.lang.String toString()`
Returns a `String` representation of this `Vector3F` instance.
Overrides:
`toString` in class `java.lang.Object`
Returns:
a `String` representation of this `Vector3F` instance

`public Vector3F add(Vector3F v)`
Adds `v` to this `Vector3F` instance.

Returns a new `Vector3F` instance with the result of the addition.

If `v` is `null`, a `NullPointerException` will be thrown.

Parameters:
`v` - the `Vector3F` to add
Returns:
a new `Vector3F` instance with the result of the addition
Throws:
`java.lang.NullPointerException` - thrown if, and only if, `v` is `null`
• #### crossProduct

`public Vector3F crossProduct(Vector3F v)`
Computes the cross product between this `Vector3F` instance and `v`.

Returns a new `Vector3F` instance with the result of the computation.

If `v` is `null`, a `NullPointerException` will be thrown.

Parameters:
`v` - a `Vector3F`
Returns:
a new `Vector3F` instance with the result of the computation
Throws:
`java.lang.NullPointerException` - thrown if, and only if, `v` is `null`
• #### divide

`public Vector3F divide(float s)`
Divides this `Vector3F` instance by `s`.

Returns a new `Vector3F` instance with the result of the division.

Parameters:
`s` - the scalar value to divide by
Returns:
a new `Vector3F` instance with the result of the division
• #### multiply

`public Vector3F multiply(float s)`
Multiplies this `Vector3F` instance with `s`.

Returns a new `Vector3F` instance with the result of the multiplication.

Parameters:
`s` - the scalar value to multiply with
Returns:
a new `Vector3F` instance with the result of the multiplication
• #### negate

`public Vector3F negate()`
Negates this `Vector3F` instance.

Returns a new `Vector3F` instance with the result of the negation.

Returns:
a new `Vector3F` instance with the result of the negation
• #### normalize

`public Vector3F normalize()`
Normalizes this `Vector3F` instance.

Returns a new `Vector3F` instance with the result of the normalization.

Returns:
a new `Vector3F` instance with the result of the normalization
• #### subtract

`public Vector3F subtract(Vector3F v)`
Subtracts `v` from this `Vector3F` instance.

Returns a new `Vector3F` instance with the result of the subtraction.

If `v` is `null`, a `NullPointerException` will be thrown.

Parameters:
`v` - the `Vector3` to subtract
Returns:
a new `Vector3F` instance with the result of the subtraction
Throws:
`java.lang.NullPointerException` - thrown if, and only if, `v` is `null`
• #### transform

`public Vector3F transform(Matrix44F m)`
Performs a transformation.

Returns a new `Vector3F` with the result of the transformation.

If `m` is `null`, a `NullPointerException` will be thrown.

Parameters:
`m` - the `Matrix44F` to perform the transformation with
Returns:
a new `Vector3F` with the result of the transformation
Throws:
`java.lang.NullPointerException` - thrown if, and only if, `m` is `null`
• #### transform

`public Vector3F transform(OrthoNormalBasis33F orthoNormalBasis)`
Performs a transformation.

Returns a new `Vector3F` with the result of the transformation.

If `orthoNormalBasis` is `null`, a `NullPointerException` will be thrown.

Parameters:
`orthoNormalBasis` - an `OrthoNormalBasis33F`
Returns:
a new `Vector3F` with the result of the transformation
Throws:
`java.lang.NullPointerException` - thrown if, and only if, `orthoNormalBasis` is `null`
• #### transformReverse

`public Vector3F transformReverse(OrthoNormalBasis33F orthoNormalBasis)`
Performs a transformation in reverse order.

Returns a new `Vector3F` with the result of the transformation.

If `orthoNormalBasis` is `null`, a `NullPointerException` will be thrown.

Parameters:
`orthoNormalBasis` - an `OrthoNormalBasis33F`
Returns:
a new `Vector3F` with the result of the transformation
Throws:
`java.lang.NullPointerException` - thrown if, and only if, `orthoNormalBasis` is `null`
• #### transformTranspose

`public Vector3F transformTranspose(Matrix44F m)`
Performs a transformation in transpose order.

Returns a new `Vector3F` with the result of the transformation.

If `m` is `null`, a `NullPointerException` will be thrown.

Parameters:
`m` - a `Matrix44F`
Returns:
a new `Vector3F` with the result of the transformation
Throws:
`java.lang.NullPointerException` - thrown if, and only if, `m` is `null`
• #### equals

`public boolean equals(java.lang.Object object)`
Compares `object` to this `Vector3F` instance for equality.

Returns `true` if, and only if, `object` is an instance of `Vector3F`, and their respective values are equal, `false` otherwise.

Overrides:
`equals` in class `java.lang.Object`
Parameters:
`object` - the `Object` to compare to this `Vector3F` instance for equality
Returns:
`true` if, and only if, `object` is an instance of `Vector3F`, and their respective values are equal, `false` otherwise
• #### dotProduct

`public float dotProduct(Vector3F v)`
Returns the dot product between this `Vector3F` instance and `v`.

If `v` is `null`, a `NullPointerException` will be thrown.

Parameters:
`v` - a `Vector3F`
Returns:
the dot product between this `Vector3F` instance and `v`
Throws:
`java.lang.NullPointerException` - thrown if, and only if, `v` is `null`
• #### length

`public float length()`
Returns the length of this `Vector3F` instance.
Returns:
the length of this `Vector3F` instance
• #### lengthSquared

`public float lengthSquared()`
Returns the length of this `Vector3F` instance in squared form.
Returns:
the length of this `Vector3F` instance in squared form
• #### hashCode

`public int hashCode()`
Returns a hash code for this `Vector3F` instance.
Overrides:
`hashCode` in class `java.lang.Object`
Returns:
a hash code for this `Vector3F` instance
• #### direction

```public static Vector3F direction(float u,
float v)```
Returns a `Vector3F` based on the U- and V-coordinates `u` and `v`.
Parameters:
`u` - the U-coordinate
`v` - the V-coordinate
Returns:
a `Vector3F` based on the U- and V-coordinates `u` and `v`
• #### direction

```public static Vector3F direction(Point3F eye,
Point3F lookAt)```
Returns a `Vector3F` pointing in the direction from `eye` to `lookAt`.

If either `eye` or `lookAt` are `null`, a `NullPointerException` will be thrown.

Parameters:
`eye` - a `Point3F` denoting the eye to look from
`lookAt` - a `Point3F` denoting the target to look at
Returns:
a `Vector3F` pointing in the direction from `eye` to `lookAt`
Throws:
`java.lang.NullPointerException` - thrown if, and only if, either `eye` or `lookAt` are `null`
• #### normal

```public static Vector3F normal(Point3F a,
Point3F b,
Point3F c)```
Returns a `Vector3F` denoting the normal of the plane defined by `a`, `b` and `c`.

If either `a`, `b` or `c` are `null`, a `NullPointerException` will be thrown.

Parameters:
`a` - one of the three `Point3F`s in the plane
`b` - one of the three `Point3F`s in the plane
`c` - one of the three `Point3F`s in the plane
Returns:
a `Vector3F` denoting the normal of the plane defined by `a`, `b` and `c`
Throws:
`java.lang.NullPointerException` - thrown if, and only if, either `a`, `b` or `c` are `null`
• #### normalNormalized

```public static Vector3F normalNormalized(Point3F a,
Point3F b,
Point3F c)```
Returns a `Vector3F` denoting the normalized normal of the plane defined by `a`, `b` and `c`.

If either `a`, `b` or `c` are `null`, a `NullPointerException` will be thrown.

Parameters:
`a` - one of the three `Point3F`s in the plane
`b` - one of the three `Point3F`s in the plane
`c` - one of the three `Point3F`s in the plane
Returns:
a `Vector3F` denoting the normalized normal of the plane defined by `a`, `b` and `c`
Throws:
`java.lang.NullPointerException` - thrown if, and only if, either `a`, `b` or `c` are `null`
• #### x

`public static Vector3F x()`
Returns a new `Vector3F` instance equivalent to `new Vector3F(1.0F, 0.0F, 0.0F)`.
Returns:
a new `Vector3F` instance equivalent to `new Vector3F(1.0F, 0.0F, 0.0F)`
• #### x

`public static Vector3F x(float x)`
Returns a new `Vector3F` instance equivalent to `new Vector3F(x, 0.0F, 0.0F)`.
Parameters:
`x` - the element value along the X-axis
Returns:
a new `Vector3F` instance equivalent to `new Vector3F(x, 0.0F, 0.0F)`
• #### y

`public static Vector3F y()`
Returns a new `Vector3F` instance equivalent to `new Vector3F(0.0F, 1.0F, 0.0F)`.
Returns:
a new `Vector3F` instance equivalent to `new Vector3F(0.0F, 1.0F, 0.0F)`
• #### y

`public static Vector3F y(float y)`
Returns a new `Vector3F` instance equivalent to `new Vector3F(0.0F, y, 0.0F)`.
Parameters:
`y` - the element value along the Y-axis
Returns:
a new `Vector3F` instance equivalent to `new Vector3F(0.0F, y, 0.0F)`
• #### z

`public static Vector3F z()`
Returns a new `Vector3F` instance equivalent to `new Vector3F(0.0F, 0.0F, 1.0F)`.
Returns:
a new `Vector3F` instance equivalent to `new Vector3F(0.0F, 0.0F, 1.0F)`
• #### z

`public static Vector3F z(float z)`
Returns a new `Vector3F` instance equivalent to `new Vector3F(0.0F, 0.0F, z)`.
Parameters:
`z` - the element value along the Z-axis
Returns:
a new `Vector3F` instance equivalent to `new Vector3F(0.0F, 0.0F, z)`