Class CurvyUtility
- Namespace
- FluffyUnderware.Curvy.Utils
Curvy Utility class
public static class CurvyUtility
- Inheritance
-
CurvyUtility
Methods
Approximately(float, float)
Does the same things as Mathf.Approximately, but with different handling of case where one of the two values is 0 Considering inputs of 0 and 1E-7, Mathf.Approximately will return false, while this method will return true.
public static bool Approximately(this float x, float y)
Parameters
Returns
ClampDistance(float, CurvyClamping, float)
Clamps absolute position
public static float ClampDistance(float distance, CurvyClamping clamping, float length)
Parameters
distance
floatclamping
CurvyClampinglength
float
Returns
ClampDistance(float, CurvyClamping, float, float, float)
Clamps absolute position
public static float ClampDistance(float distance, CurvyClamping clamping, float length, float min, float max)
Parameters
distance
floatclamping
CurvyClampinglength
floatmin
floatmax
float
Returns
ClampDistance(float, ref int, CurvyClamping, float)
Clamps absolute position and sets new direction
public static float ClampDistance(float distance, ref int dir, CurvyClamping clamping, float length)
Parameters
distance
floatdir
intclamping
CurvyClampinglength
float
Returns
ClampDistance(float, ref int, CurvyClamping, float, float, float)
Clamps absolute position and sets new direction
public static float ClampDistance(float distance, ref int dir, CurvyClamping clamping, float length, float min, float max)
Parameters
Returns
ClampTF(float, CurvyClamping)
Clamps relative position
public static float ClampTF(float tf, CurvyClamping clamping)
Parameters
tf
floatclamping
CurvyClamping
Returns
ClampTF(float, ref int, CurvyClamping)
Clamps relative position and sets new direction
public static float ClampTF(float tf, ref int dir, CurvyClamping clamping)
Parameters
tf
floatdir
intclamping
CurvyClamping
Returns
ClampValue(float, CurvyClamping, float, float)
Clamps a float to a range
public static float ClampValue(float tf, CurvyClamping clamping, float minTF, float maxTF)
Parameters
tf
floatclamping
CurvyClampingminTF
floatmaxTF
float
Returns
GetDefaultMaterial()
Gets the default material, i.e. Curvy/Resources/CurvyDefaultMaterial
public static Material GetDefaultMaterial()
Returns
- Material
GetNearestPointIndex(Vector3, Vector3[], int, out int, out float)
Given an input point, gets the index of the point in the array that is closest to the input point.
public static void GetNearestPointIndex(Vector3 point, Vector3[] points, int pointsCount, out int index, out float fragement)
Parameters
point
Vector3the input point
points
Vector3[]A list of points to test against
pointsCount
intThe number of points to test against
index
intthe index of the closest point
fragement
floata value between 0 and 1 indicating how close the input point is close to the point of index: index + 1
InterpolationSearch(float[], int, float)
Finds the index of x in an array of sorted values (ascendant order). If x not found, the closest smaller value's index is returned if any, -1 otherwise
public static int InterpolationSearch(float[] array, int elementsCount, float x)
Parameters
array
float[]The array to search into
elementsCount
intThe number of elements of the array to search into
x
floatThe element to search for
Returns
InterpolationSearch(float[], float)
Finds the index of x in an array of sorted values (ascendant order). If x not found, the closest smaller value's index is returned if any, -1 otherwise
public static int InterpolationSearch(float[] array, float x)
Parameters
Returns
SplineToMesh(CurvySpline)
Returns a mesh which boundaries are the input spline, similarly to what the Spline To Mesh window does, but simpler and less configurable.
public static Mesh SplineToMesh(this CurvySpline spline)
Parameters
spline
CurvySpline
Returns
- Mesh