MathUtilities

Collection of math function.

namespace Sirenix.Utilities
{
[ExtensionAttribute]
public static class MathUtilities
}

Requirements

Namespace: Sirenix.Utilities
Assembly: Sirenix.OdinInspector
Version: 2.0.0.0

Static Methods

Return Type Definition Description
float Bounce(float) Returns a value that bounces between 0 and 1 based on value.
float BounceEaseInFastOut(float) Returns a value based on t, that bounces faster and faster.
float ClampWrapAngle(float, float, float) Clamps and wraps an angle between two values.
int ComputeByteArrayHash(byte[]) Computes a hash for a byte array.
double DiscardLeastSignificantDecimal(double) Discards the least significant demicals.
float EaseInElastic(float, float, float) Returns a value that eases in elasticly.
float EaseInOut(float) Returns a smooth value betweeen that peaks at t=0.5 and then comes back down again.
float EaseOutElastic(float, float, float) Returns a value that eases out elasticly.
float Fract(float) Returns the fractional of the value.
Vector2 Fract(Vector2) Returns the fractional of the value.
Vector3 Fract(Vector3) Returns the fractional of the value.
float Hermite(float, float, float) Returns a smooth value between start and end based on t.
float Hermite01(float) Returns a smooth value between 0 and 1 based on t.
Vector2 InfiniteLineIntersect(Vector2, Vector2, Vector2, Vector2) Returns the collision point between two infinite lines.
Vector3 InterpolatePoints(Vector3[], float) Gives a smooth path between a collection of points.
Vector2 LerpUnclamped(Vector2, Vector2, float) Returns an unclamped linear interpolation of two vectors.
Vector3 LerpUnclamped(Vector3, Vector3, float) Returns an unclamped linear interpolation of two vectors.
float LinearStep(float, float, float) Interpolates t between a and b to a value between 0 and 1.
float LineDistToPlane(Vector3, Vector3, Vector3, Vector3) Distance from line to plane.
bool LineIntersectsLine(Vector2, Vector2, Vector2, Vector2, ref Vector2) Checks if two given lines intersect with one another and returns the intersection point (if any) in an out parameter. Source: http://stackoverflow.com/questions/3746274/line-intersection-with-aabb-rectangle. Edited to implement Cohen-Sutherland type pruning for efficiency.
float PointDistanceToLine(Vector3, Vector3, Vector3) Distance from a point to a line.
float RayDistToPlane(Ray, Plane) Distance from ray to plane.
Vector2 RotatePoint(Vector2, float) Rotates a Vector2 by an angle.
Vector2 RotatePoint(Vector2, Vector2, float) Rotates a Vector2 around a point by an angle..
double RoundBasedOnMinimumDifference(double, double) Rounds a number based on a mininum difference.
float SmoothStep(float, float, float) Interpolates t between a and b to a value between 0 and 1 using a Hermite polynomial.
float StackHermite(float, float, float, int) Returns a smooth value between start and end based on t.
float StackHermite01(float, int) Returns a smooth value between 0 and 1 based on t.
double Wrap(double, double, double) Wraps a value between min and max.
float Wrap(float, float, float) Wraps a value between min and max.
int Wrap(int, int, int) Wraps a value between min and max.

Extension Methods

Return Type Definition Description
Vector3 Abs(this Vector3) Returns a Vector2 with each element set to their respective sign.
Vector2 Clamp(this Vector2, Vector2, Vector2) Clamps the value of a Vector2.
Vector3 Clamp(this Vector3, Vector3, Vector3) Clamps the value of a Vector3.
Vector3 Pow(this Vector3, float) Pows each element of the vector.
Vector3 Sign(this Vector3) Returns a Vector3 with each element set to their respective sign.