Class ZOMathUtil
Inheritance
Inherited Members
Namespace: ZO.Math
Assembly: Unity.ZeroSim.dll
Syntax
public static class ZOMathUtil
Methods
| Improve this Doc View SourcecartesianToPolar(Vector2)
Convert 2d cartesian coordinates to polar coordinates.
Declaration
public static Vector2 cartesianToPolar(Vector2 point)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector2 | point | 2D point |
Returns
Type | Description |
---|---|
UnityEngine.Vector2 | 2D polar coordinates. |
DegreesToRadians(Double)
Convert double degrees to radians.
Declaration
public static double DegreesToRadians(double degrees)
Parameters
Type | Name | Description |
---|---|---|
System.Double | degrees | Input angle in degrees. |
Returns
Type | Description |
---|---|
System.Double | Output angle in radians. |
FindOrthonormals(Vector3, out Vector3, out Vector3)
Get the orthonormal basis given a start vector.
Declaration
public static void FindOrthonormals(Vector3 normal, out Vector3 orthonormal1, out Vector3 orthonormal2)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector3 | normal | The start vector. |
UnityEngine.Vector3 | orthonormal1 | The first ortho normal vector to the start vector. |
UnityEngine.Vector3 | orthonormal2 | The second ortho normal vector to the start vector and the first ortho vector. |
FindQuaternionTwist(Quaternion, Vector3)
Calculate the quaternion twist about an axis.
Declaration
public static float FindQuaternionTwist(Quaternion q, Vector3 axis)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Quaternion | q | The quaternion. |
UnityEngine.Vector3 | axis | The axis. |
Returns
Type | Description |
---|---|
System.Single | The twist in radians. |
isApproximatelyEqual(Double, Double, Double)
Checks if two double values are approximately equal.
Declaration
public static bool isApproximatelyEqual(double a, double b, double tolerance = 4.94065645841247E-324)
Parameters
Type | Name | Description |
---|---|---|
System.Double | a | First value. |
System.Double | b | Second value. |
System.Double | tolerance | The epsilon cut off. |
Returns
Type | Description |
---|---|
System.Boolean |
isApproximatelyZero(Double, Double)
Checks if a value is approximately zero given an epsilon.
Declaration
public static bool isApproximatelyZero(double a, double tolerance = 4.94065645841247E-324)
Parameters
Type | Name | Description |
---|---|---|
System.Double | a | The value |
System.Double | tolerance | The epsilon cut off. |
Returns
Type | Description |
---|---|
System.Boolean | True if zero otherwise false. |
lowPassFilter(Single, Single, Single)
Simple low pass filter on float
.
Declaration
public static float lowPassFilter(float currentValue, float prevValue, float alpha)
Parameters
Type | Name | Description |
---|---|---|
System.Single | currentValue | The current value. |
System.Single | prevValue | The previous value. |
System.Single | alpha | Weight 0..1 where greater value biases towards the current value. |
Returns
Type | Description |
---|---|
System.Single | Weighted value. |
lowPassFilter(Vector3, Vector3, Single)
Simple low pass filter on Vector3
Declaration
public static Vector3 lowPassFilter(Vector3 currentValue, Vector3 prevValue, float alpha)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector3 | currentValue | The current value. |
UnityEngine.Vector3 | prevValue | The previous value. |
System.Single | alpha | Weight 0..1 where greater value biases towards the current value. |
Returns
Type | Description |
---|---|
UnityEngine.Vector3 | Weighted value. |
lowPassFilter(Vector3, ref Vector3, Single, Boolean)
Declaration
public static Vector3 lowPassFilter(Vector3 targetValue, ref Vector3 intermediateValueBuf, float factor, bool init)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector3 | targetValue | |
UnityEngine.Vector3 | intermediateValueBuf | |
System.Single | factor | |
System.Boolean | init |
Returns
Type | Description |
---|---|
UnityEngine.Vector3 |
lowPassFilterQuaternion(Quaternion, Quaternion, Single, Boolean)
Declaration
public static Quaternion lowPassFilterQuaternion(Quaternion intermediateValue, Quaternion targetValue, float factor, bool init = false)
Parameters
Type | Name | Description |
---|---|---|
System.Numerics.Quaternion | intermediateValue | |
System.Numerics.Quaternion | targetValue | |
System.Single | factor | |
System.Boolean | init |
Returns
Type | Description |
---|---|
System.Numerics.Quaternion |
RadiansToDegrees(Double)
Converts double radians to degrees.
Declaration
public static double RadiansToDegrees(double angle)
Parameters
Type | Name | Description |
---|---|---|
System.Double | angle | Input angle in radians. |
Returns
Type | Description |
---|---|
System.Double | Outpus angle in degrees. |