This site has been permanently archived. The content on this site was last updated in 2019.
Stay organized with collections
Save and categorize content based on your preferences.
GvrMathHelpers
Helper functions to perform common math operations for Gvr.
Summary
Public static functions
|
ConvertFloatArrayToMatrix(float[] floatArray)
|
Matrix4x4
Converts a float array of length 16 into a column-major 4x4 matrix.
|
EaseOutCubic(float min, float max, float value)
|
float
|
GetIntersectionPosition(Camera cam, RaycastResult raycastResult)
|
Vector3
Gets the intersection position of the camera and the raycast result.
|
GvrMatrixToUnitySpace(Matrix4x4 gvrMatrix, out Vector3 position, out Quaternion orientation)
|
void
Converts matrix from Google VR convention to Unity convention.
|
NormalizedCartesianToSpherical(Vector3 cartCoords)
|
Vector2
Normalizes a 3D Cartesian direction to a 2D spherical direction.
|
Public static functions
ConvertFloatArrayToMatrix
Matrix4x4 ConvertFloatArrayToMatrix(
float[] floatArray
)
Converts a float array of length 16 into a column-major 4x4 matrix.
Details |
Parameters |
floatArray
|
The array to convert to a matrix.
|
|
Returns
|
A column-major 4x4 matrix.
|
EaseOutCubic
float EaseOutCubic(
float min,
float max,
float value
)
A cubic easing function (https://easings.net/#easeOutCubic).
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
Vector3 GetIntersectionPosition(
Camera cam,
RaycastResult raycastResult
)
Gets the intersection position of the camera and the raycast result.
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
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.
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
Vector2 NormalizedCartesianToSpherical(
Vector3 cartCoords
)
Normalizes a 3D Cartesian direction to a 2D spherical direction.
Details |
Parameters |
cartCoords
|
The coordinates to normalize.
|
|
Returns
|
The spherical coordinates.
|
All rights reserved. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-09 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-09 UTC."],[[["\u003cp\u003eGvrMathHelpers provides helper functions for common math operations in Google VR development.\u003c/p\u003e\n"],["\u003cp\u003eIt includes functions for matrix conversions, easing, raycast intersection calculations, and coordinate transformations.\u003c/p\u003e\n"],["\u003cp\u003eThe functions facilitate interaction between Google VR and Unity by handling differences in coordinate systems and conventions.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can utilize these helpers to simplify tasks like object positioning, animation, and user interactions in VR environments.\u003c/p\u003e\n"]]],["The `GvrMathHelpers` class provides static functions for common math operations. These include: converting a float array to a 4x4 matrix; applying a cubic easing function to a value; determining the intersection position between a camera and a raycast; converting a matrix from Google VR to Unity conventions (position and orientation); and normalizing 3D Cartesian coordinates to 2D spherical coordinates. Each function takes specific inputs and returns a calculated value or modified data.\n"],null,["GvrMathHelpers\n\nHelper functions to perform common math operations for Gvr.\n\nSummary\n\n| Public static functions ||\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------|\n| [ConvertFloatArrayToMatrix](#classGvrMathHelpers_1a0a4d84d7a8819d4aaa7a18af666c8196)`(float[] floatArray)` | `Matrix4x4` Converts a float array of length 16 into a column-major 4x4 matrix. |\n| [EaseOutCubic](#classGvrMathHelpers_1ad45492f840656ca23c0402bc7ba2b2ff)`(float min, float max, float value)` | `float` A cubic easing function (\u003chttps://easings.net/#easeOutCubic\u003e). |\n| [GetIntersectionPosition](#classGvrMathHelpers_1ab0e97d9b07f3e42e1cb0d0f155aad233)`(Camera cam, RaycastResult raycastResult)` | `Vector3` Gets the intersection position of the camera and the raycast result. |\n| [GvrMatrixToUnitySpace](#classGvrMathHelpers_1a08f851fd8bd9d5a3b710c232b0ba6b02)`(Matrix4x4 gvrMatrix, out Vector3 position, out Quaternion orientation)` | `void` Converts matrix from Google VR convention to Unity convention. |\n| [NormalizedCartesianToSpherical](#classGvrMathHelpers_1a10940979f8b826c94149f2040dd4eb0e)`(Vector3 cartCoords)` | `Vector2` Normalizes a 3D Cartesian direction to a 2D spherical direction. |\n\nPublic static functions \n\nConvertFloatArrayToMatrix \n\n```c#\nMatrix4x4 ConvertFloatArrayToMatrix(\n float[] floatArray\n)\n``` \nConverts a float array of length 16 into a column-major 4x4 matrix.\n\n\u003cbr /\u003e\n\n| Details ||\n|-------------|-----------------------------------------------------------------------------------------------------------|\n| Parameters | |--------------|-----------------------------------| | `floatArray` | The array to convert to a matrix. | |\n| **Returns** | A column-major 4x4 matrix. |\n\nEaseOutCubic \n\n```c#\nfloat EaseOutCubic(\n float min,\n float max,\n float value\n)\n``` \nA cubic easing function (\u003chttps://easings.net/#easeOutCubic\u003e).\n\n\u003cbr /\u003e\n\n| Details ||\n|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Parameters | |---------|---------------------------------------------------| | `min` | The minimum output value. | | `max` | The maximum output value. | | `value` | The input to the easing function between 0 and 1. | |\n| **Returns** | The output of the easing function between (min) and (max). |\n\nGetIntersectionPosition \n\n```c#\nVector3 GetIntersectionPosition(\n Camera cam,\n RaycastResult raycastResult\n)\n``` \nGets the intersection position of the camera and the raycast result.\n\n\u003cbr /\u003e\n\n| Details ||\n|-------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Parameters | |-----------------|---------------------------------------------------------| | `cam` | The camera to use. | | `raycastResult` | The result of the raycast to intersect with the camera. | |\n| **Returns** | The position of the intersection. |\n\nGvrMatrixToUnitySpace \n\n```c#\nvoid GvrMatrixToUnitySpace(\n Matrix4x4 gvrMatrix,\n out Vector3 position,\n out Quaternion orientation\n)\n``` \nConverts matrix from Google VR convention to Unity convention.\n\nGoogle VR is row-major, RHS coordinates, and Unity is column-major, LHS.\n\n\u003cbr /\u003e\n\n| Details ||\n|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 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. | |\n\nNormalizedCartesianToSpherical \n\n```c#\nVector2 NormalizedCartesianToSpherical(\n Vector3 cartCoords\n)\n``` \nNormalizes a 3D Cartesian direction to a 2D spherical direction.\n\n\u003cbr /\u003e\n\n| Details ||\n|-------------|---------------------------------------------------------------------------------------------------|\n| Parameters | |--------------|-------------------------------| | `cartCoords` | The coordinates to normalize. | |\n| **Returns** | The spherical coordinates. |"]]