Wanzyee Studio

Extension methods for numeric operation. More...

Static Public Member Functions

static float ToRound (this float value)
 Convert the float to the rounded value. More...
 
static Vector2 ToRound (this Vector2 value)
 Convert the UnityEngine.Vector2 to the rounded value. More...
 
static Vector3 ToRound (this Vector3 value)
 Convert the UnityEngine.Vector3 to the rounded value. More...
 
static int ToAbs (this int value)
 Convert the int to the absolute value. More...
 
static float ToAbs (this float value)
 Convert the float to the absolute value. More...
 
static Vector2 ToAbs (this Vector2 value)
 Convert the UnityEngine.Vector2 to the absolute value. More...
 
static Vector3 ToAbs (this Vector3 value)
 Convert the UnityEngine.Vector3 to the absolute value. More...
 
static bool ApproxFloat (this float value, float to, float range=1e-7f)
 Test if a float is close to another. More...
 
static bool ApproxVector2 (this Vector2 value, Vector2 to, float range=1e-7f)
 Test if a UnityEngine.Vector2 is close to another. More...
 
static bool ApproxVector3 (this Vector3 value, Vector3 to, float range=1e-7f)
 Test if a UnityEngine.Vector3 is close to another. More...
 
static bool ApproxQuaternion (this Quaternion value, Quaternion to, bool euler=true, float range=1e-7f)
 Test if a UnityEngine.Quaternion is close to another. More...
 
static bool ApproxColor (this Color value, Color to, float range=0.004f)
 Test if a UnityEngine.Color is close to another. More...
 
static bool ApproxColor32 (this Color32 value, Color32 to, int range=1)
 Test if a UnityEngine.Color32 is close to another. More...
 
static Vector3 NormalizedToPoint (this Bounds bounds, Vector3 value, bool clamp=true)
 Returns a point inside UnityEngine.Bounds, given normalized coordinates. More...
 
static Vector3 PointToNormalized (this Bounds bounds, Vector3 value, bool clamp=true)
 Returns the normalized coordinates cooresponding of the point. More...
 
static Bounds GetIntersect (this Bounds bounds, Bounds value, bool absolute=true)
 Get the intersected UnityEngine.Bounds with another one. More...
 
static Vector3 GetRandomPoint (this Bounds bounds)
 Get a random point inside the UnityEngine.Bounds. More...
 
static Rect GetOverlap (this Rect rect, Rect value, bool absolute=true)
 Get the overlaped UnityEngine.Rect with another one. More...
 
static Vector2 GetRandomPoint (this Rect rect)
 Get a random point inside the UnityEngine.Rect. More...
 

Detailed Description

Extension methods for numeric operation.

Member Function Documentation

static float ToRound ( this float  value)
static

Convert the float to the rounded value.

Parameters
valueValue.
Returns
The new value.
static Vector2 ToRound ( this Vector2  value)
static

Convert the UnityEngine.Vector2 to the rounded value.

Parameters
valueValue.
Returns
The new value.
static Vector3 ToRound ( this Vector3  value)
static

Convert the UnityEngine.Vector3 to the rounded value.

Parameters
valueValue.
Returns
The new value.
static int ToAbs ( this int  value)
static

Convert the int to the absolute value.

Parameters
valueValue.
Returns
The new value.
static float ToAbs ( this float  value)
static

Convert the float to the absolute value.

Parameters
valueValue.
Returns
The new value.
static Vector2 ToAbs ( this Vector2  value)
static

Convert the UnityEngine.Vector2 to the absolute value.

Parameters
valueValue.
Returns
The new value.
static Vector3 ToAbs ( this Vector3  value)
static

Convert the UnityEngine.Vector3 to the absolute value.

Parameters
valueValue.
Returns
The new value.
static bool ApproxFloat ( this float  value,
float  to,
float  range = 1e-7f 
)
static

Test if a float is close to another.

Parameters
valueValue.
toValue to compare.
rangeMax difference.
Returns
if is close to another.
static bool ApproxVector2 ( this Vector2  value,
Vector2  to,
float  range = 1e-7f 
)
static

Test if a UnityEngine.Vector2 is close to another.

Parameters
valueValue.
toValue to compare.
rangeMax difference.
Returns
if is close to another.
static bool ApproxVector3 ( this Vector3  value,
Vector3  to,
float  range = 1e-7f 
)
static

Test if a UnityEngine.Vector3 is close to another.

Parameters
valueValue.
toValue to compare.
rangeMax difference.
Returns
if is close to another.
static bool ApproxQuaternion ( this Quaternion  value,
Quaternion  to,
bool  euler = true,
float  range = 1e-7f 
)
static

Test if a UnityEngine.Quaternion is close to another.

Optional to compare eulerAngles or each component.

Parameters
valueValue.
toValue to compare.
eulerTo compare eulerAngles, or each component.
rangeMax difference.
Returns
if is close to another.
static bool ApproxColor ( this Color  value,
Color  to,
float  range = 0.004f 
)
static

Test if a UnityEngine.Color is close to another.

Check by the sum of each component's absolute difference.

Parameters
valueValue.
toValue to compare.
rangeMax difference.
Returns
if is close to another.
static bool ApproxColor32 ( this Color32  value,
Color32  to,
int  range = 1 
)
static

Test if a UnityEngine.Color32 is close to another.

Check by the sum of each component's absolute difference.

Parameters
valueValue.
toValue to compare.
rangeMax difference.
Returns
if is close to another.
static Vector3 NormalizedToPoint ( this Bounds  bounds,
Vector3  value,
bool  clamp = true 
)
static

Returns a point inside UnityEngine.Bounds, given normalized coordinates.

Parameters
boundsBounds.
valueNormalized point.
clampIf set to true clamp.
Returns
The point.
static Vector3 PointToNormalized ( this Bounds  bounds,
Vector3  value,
bool  clamp = true 
)
static

Returns the normalized coordinates cooresponding of the point.

Parameters
boundsBounds.
valuePoint.
clampIf set to true clamp.
Returns
The normalized point.
static Bounds GetIntersect ( this Bounds  bounds,
Bounds  value,
bool  absolute = true 
)
static

Get the intersected UnityEngine.Bounds with another one.

Optional to use absolute extents to calculate. Absolute extents make result with positive extents and valid only if really intersect. Otherwise, you might get a result encapsulate the bounds or with negative extents.

Parameters
boundsBounds.
valueAnother UnityEngine.Bounds.
absoluteIf set to true absolute.
Returns
The intersected UnityEngine.Bounds.
static Vector3 GetRandomPoint ( this Bounds  bounds)
static

Get a random point inside the UnityEngine.Bounds.

Parameters
boundsBounds.
Returns
The random point.
static Rect GetOverlap ( this Rect  rect,
Rect  value,
bool  absolute = true 
)
static

Get the overlaped UnityEngine.Rect with another one.

Optional to use absolute size to calculate. Absolute size makes the result with positive size and valid only if really overlap. Otherwise, you might get a result encapsulate the rects or with negative size.

Parameters
rectRect.
valueAnother UnityEngine.Rect.
absoluteIf set to true absolute.
Returns
The overlaped UnityEngine.Rect.
static Vector2 GetRandomPoint ( this Rect  rect)
static

Get a random point inside the UnityEngine.Rect.

Parameters
rectRect.
Returns
The random point.