Additional static functions used to extend existing Math support inside of Unity.
More...
|
static float | ClampAngle (float angle, float minimumAngle, float maximumAngle) |
| Clamp and neutralize an angle. More...
|
|
static float | NeutralizeAngle (float angle) |
| Neutralizes the an angle, providing an angle below 360 degrees. More...
|
|
static float | SignedAngle (float angle) |
| The signed equivalent of the angle. More...
|
|
static object | ToUnsigned (object value) |
| Converts the specified values boxed type to its corresponding unsigned type. More...
|
|
static long | UnboxToLong (object value, bool round) |
| Convert object to long value. More...
|
|
static float | UnsignedAngle (float angle) |
| The unsigned equivalent of the angle. More...
|
|
Additional static functions used to extend existing Math support inside of Unity.
Definition at line 36 of file Math.cs.
static float Hydrogen.Math.ClampAngle |
( |
float |
angle, |
|
|
float |
minimumAngle, |
|
|
float |
maximumAngle |
|
) |
| |
|
static |
Clamp and neutralize an angle.
- Returns
- The clamped and neutralized angle.
- Parameters
-
angle | The source angle. |
minimumAngle | Minimum angle. |
maximumAngle | Maximum angle. |
Definition at line 45 of file Math.cs.
48 return UnityEngine.Mathf.Clamp (
NeutralizeAngle (angle), minimumAngle, maximumAngle);
static float NeutralizeAngle(float angle)
Neutralizes the an angle, providing an angle below 360 degrees.
static float Hydrogen.Math.NeutralizeAngle |
( |
float |
angle | ) |
|
|
static |
Neutralizes the an angle, providing an angle below 360 degrees.
- Returns
- The neutralized angle.
- Parameters
-
Definition at line 56 of file Math.cs.
60 return (angle % 360f) * -1;
static float Hydrogen.Math.SignedAngle |
( |
float |
angle | ) |
|
|
static |
The signed equivalent of the angle.
- Returns
- The signed angle.
- Parameters
-
Definition at line 70 of file Math.cs.
75 return (180 - ((angle % 180f))) * -1f;
76 }
else if (angle < -180) {
77 return ((angle % 180) * -1f);
static object Hydrogen.Math.ToUnsigned |
( |
object |
value | ) |
|
|
static |
Converts the specified values boxed type to its corresponding unsigned type.
- Returns
- A boxed numeric object whos type is unsigned.
This allows for converting without knowing the original type.
- Parameters
-
Definition at line 88 of file Math.cs.
90 switch (Type.GetTypeCode (value.GetType ())) {
92 return (byte)((sbyte)value);
94 return (ushort)((short)value);
96 return (uint)((int)value);
98 return (ulong)((long)value);
102 case TypeCode.UInt16:
104 case TypeCode.UInt32:
106 case TypeCode.UInt64:
109 case TypeCode.Single:
110 return (UInt32)((float)value);
111 case TypeCode.Double:
112 return (ulong)((double)value);
113 case TypeCode.Decimal:
114 return (ulong)((decimal)value);
static long Hydrogen.Math.UnboxToLong |
( |
object |
value, |
|
|
bool |
round |
|
) |
| |
|
static |
Convert object to long value.
- Returns
- A long value.
- Parameters
-
value | The object. |
round | Should decimals be rounded? |
Definition at line 127 of file Math.cs.
129 switch (Type.GetTypeCode (value.GetType ())) {
131 return (
long)((sbyte)value);
133 return (
long)((short)value);
135 return (
long)((int)value);
140 return (
long)((byte)value);
141 case TypeCode.UInt16:
142 return (
long)((ushort)value);
143 case TypeCode.UInt32:
144 return (
long)((uint)value);
145 case TypeCode.UInt64:
146 return (
long)((ulong)value);
148 case TypeCode.Single:
149 return (round ? (
long)System.Math.Round ((float)value) : (long)((float)value));
150 case TypeCode.Double:
151 return (round ? (
long)System.Math.Round ((
double)value) : (long)((
double)value));
152 case TypeCode.Decimal:
153 return (round ? (
long)System.Math.Round ((decimal)value) : (long)((decimal)value));
static float Hydrogen.Math.UnsignedAngle |
( |
float |
angle | ) |
|
|
static |
The unsigned equivalent of the angle.
- Returns
- The unsigned angle.
- Parameters
-
Definition at line 165 of file Math.cs.
169 return ((360 + (angle % 360f)) + ((angle - (angle % 360f))) * -1);