Class Vector3Extensions
Extension methods for the Vector3 type.
Inherited Members
Namespace: Unity.XR.CoreUtils
Syntax
public static class Vector3Extensions
Methods
Abs(Vector3)
Returns the component-wise absolute value of this vector [abs(x), abs(y), abs(z)].
Declaration
public static Vector3 Abs(this Vector3 vector)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector | The vector whose absolute value will be returned |
Returns
Type | Description |
---|---|
Vector3 | A vector containing the component-wise absolute values of this vector. |
Divide(Vector3, Vector3)
Returns a new Vector3
that divides each component of the input value by each component of the scale value.
Declaration
public static Vector3 Divide(this Vector3 value, Vector3 scale)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | Input value to scale. |
Vector3 | scale |
|
Returns
Type | Description |
---|---|
Vector3 | Scaled input value. |
Exceptions
Type | Condition |
---|---|
DivideByZeroException | Thrown if scale parameter has any 0 values. Consider using SafeDivide(Vector3, Vector3). |
Inverse(Vector3)
Returns the component-wise inverse of this vector [1/x,1/y,1/z].
Declaration
public static Vector3 Inverse(this Vector3 vector)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector | The vector to invert. |
Returns
Type | Description |
---|---|
Vector3 | The inverted vector |
MaxComponent(Vector3)
Returns the largest component of this vector.
Declaration
public static float MaxComponent(this Vector3 vector)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector | The vector whose maximum component will be returned. |
Returns
Type | Description |
---|---|
Single | The maximum value. |
MinComponent(Vector3)
Returns the smallest component of this vector.
Declaration
public static float MinComponent(this Vector3 vector)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector | The vector whose minimum component will be returned. |
Returns
Type | Description |
---|---|
Single | The minimum value. |
Multiply(Vector3, Vector3)
Returns a new vector3 that multiplies each component of both input vectors together.
Declaration
public static Vector3 Multiply(this Vector3 value, Vector3 scale)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | Input value to scale. |
Vector3 | scale | Vector3 used to scale components of input value. |
Returns
Type | Description |
---|---|
Vector3 | Scaled input value. |
SafeDivide(Vector3, Vector3)
Returns a new Vector3
that divides each component of the input value by each component of the scale value.
If any divisor is 0 or the output of the division is a NaN
, then the output of that component will be zero.
Declaration
public static Vector3 SafeDivide(this Vector3 value, Vector3 scale)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | value | Input value to scale. |
Vector3 | scale |
|
Returns
Type | Description |
---|---|
Vector3 | Scaled input value. |