# GvrMathHelpers Class Reference

# GvrMathHelpers

Helper functions to perform common math operations for Gvr.

## Summary

| ### Public static functions ||
|---|---|
| `https://developers.google.com/vr/reference/unity/class/GvrMathHelpers#classGvrMathHelpers_1a0a4d84d7a8819d4aaa7a18af666c8196(float[] floatArray)` | `Matrix4x4` Converts a float array of length 16 into a column-major 4x4 matrix. |
| `https://developers.google.com/vr/reference/unity/class/GvrMathHelpers#classGvrMathHelpers_1ad45492f840656ca23c0402bc7ba2b2ff(float min, float max, float value)` | `float` A cubic easing function (<https://easings.net/#easeOutCubic>). |
| `https://developers.google.com/vr/reference/unity/class/GvrMathHelpers#classGvrMathHelpers_1ab0e97d9b07f3e42e1cb0d0f155aad233(Camera cam, RaycastResult raycastResult)` | `Vector3` Gets the intersection position of the camera and the raycast result. |
| `https://developers.google.com/vr/reference/unity/class/GvrMathHelpers#classGvrMathHelpers_1a08f851fd8bd9d5a3b710c232b0ba6b02(Matrix4x4 gvrMatrix, out Vector3 position, out Quaternion orientation)` | `void` Converts matrix from Google VR convention to Unity convention. |
| `https://developers.google.com/vr/reference/unity/class/GvrMathHelpers#classGvrMathHelpers_1a10940979f8b826c94149f2040dd4eb0e(Vector3 cartCoords)` | `Vector2` Normalizes a 3D Cartesian direction to a 2D spherical direction. |

## Public static functions

### ConvertFloatArrayToMatrix

```c#
Matrix4x4 ConvertFloatArrayToMatrix(
  float[] floatArray
)
```
Converts a float array of length 16 into a column-major 4x4 matrix.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `floatArray` | The array to convert to a matrix. | |
| **Returns** | A column-major 4x4 matrix. |

### EaseOutCubic

```c#
float EaseOutCubic(
  float min,
  float max,
  float value
)
```
A cubic easing function (<https://easings.net/#easeOutCubic>).

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `min` | The minimum output value. | | `max` | The maximum output value. | | `value` | The input to the easing function between 0 and 1. | |
| **Returns** | The output of the easing function between (min) and (max). |

### GetIntersectionPosition

```c#
Vector3 GetIntersectionPosition(
  Camera cam,
  RaycastResult raycastResult
)
```
Gets the intersection position of the camera and the raycast result.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `cam` | The camera to use. | | `raycastResult` | The result of the raycast to intersect with the camera. | |
| **Returns** | The position of the intersection. |

### GvrMatrixToUnitySpace

```c#
void GvrMatrixToUnitySpace(
  Matrix4x4 gvrMatrix,
  out Vector3 position,
  out Quaternion orientation
)
```
Converts matrix from Google VR convention to Unity convention.

Google VR is row-major, RHS coordinates, and Unity is column-major, LHS.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `gvrMatrix` | The Google VR matrix data. | | `position` | The position in Unity space based on the Google VR matrix. | | `orientation` | The orientation in Unity space. | |

### NormalizedCartesianToSpherical

```c#
Vector2 NormalizedCartesianToSpherical(
  Vector3 cartCoords
)
```
Normalizes a 3D Cartesian direction to a 2D spherical direction.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `cartCoords` | The coordinates to normalize. | |
| **Returns** | The spherical coordinates. |