A* Pathfinding Project
3.7.2
The A* Pathfinding Project for Unity 3D
|
Utility functions for working with numbers, lines and vectors. More...
Utility functions for working with numbers, lines and vectors.
Static Public Member Functions | |
static float | Abs (float a) |
static int | Abs (int a) |
static float | Clamp (float a, float b, float c) |
static int | Clamp (int a, int b, int c) |
static float | Clamp01 (float a) |
static int | Clamp01 (int a) |
static int | ComputeVertexHash (int x, int y, int z) |
Returns a hash value for a integer vector. | |
static Vector3 | CubicBezier (Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t) |
Returns a point on a cubic bezier curve. | |
static float | DistancePointSegment (int x, int z, int px, int pz, int qx, int qz) |
Returns the approximate shortest squared distance between x,z and the line p-q. | |
static float | DistancePointSegment (Int3 a, Int3 b, Int3 p) |
Returns the approximate shortest squared distance between x,z and the line p-q. | |
static float | DistancePointSegment2 (int x, int z, int px, int pz, int qx, int qz) |
Returns the distance between x,z and the line p-q. | |
static float | DistancePointSegment2 (Vector3 a, Vector3 b, Vector3 p) |
Returns the distance between c and the line a-b. | |
static float | DistancePointSegmentStrict (Vector3 a, Vector3 b, Vector3 p) |
Returns the squared distance between c and the line a-b. | |
static string | FormatBytes (int bytes) |
Returns a nicely formatted string for the number of bytes (kB, MB, GB etc). | |
static string | FormatBytesBinary (int bytes) |
Returns a nicely formatted string for the number of bytes (KiB, MiB, GiB etc). | |
static float | Hermite (float start, float end, float value) |
Returns a point on a hermite curve. | |
static Color | IntToColor (int i, float a) |
Returns a nice color from int i with alpha a. | |
static float | Lerp (float a, float b, float t) |
static float | MagnitudeXZ (Vector3 a, Vector3 b) |
Distance between two points on the XZ plane. | |
static float | MapTo (float startMin, float startMax, float value) |
Maps a value between startMin and startMax to be between 0 and 1. | |
static float | MapTo (float startMin, float startMax, float targetMin, float targetMax, float value) |
Maps a value between startMin and startMax to be between targetMin and targetMax. | |
static float | MapToRange (float targetMin, float targetMax, float value) |
Maps a value (0...1) to be between targetMin and targetMax. | |
static float | Max (float a, float b) |
static int | Max (int a, int b) |
static uint | Max (uint a, uint b) |
static ushort | Max (ushort a, ushort b) |
static float | Min (float a, float b) |
static int | Min (int a, int b) |
static uint | Min (uint a, uint b) |
static Vector3 | NearestPoint (Vector3 lineStart, Vector3 lineEnd, Vector3 point) |
Returns the closest point on the line. | |
static float | NearestPointFactor (Vector3 lineStart, Vector3 lineEnd, Vector3 point) |
static float | NearestPointFactor (Int3 lineStart, Int3 lineEnd, Int3 point) |
Factor of the nearest point on the segment. | |
static float | NearestPointFactor (Int2 lineStart, Int2 lineEnd, Int2 point) |
Factor of the nearest point on the segment. | |
static Vector3 | NearestPointStrict (Vector3 lineStart, Vector3 lineEnd, Vector3 point) |
Returns the closest point on the line segment. | |
static Vector3 | NearestPointStrictXZ (Vector3 lineStart, Vector3 lineEnd, Vector3 point) |
Returns the closest point on the line segment on the XZ plane. | |
static int | Repeat (int i, int n) |
static int | RoundToInt (float v) |
static int | RoundToInt (double v) |
static float | Sign (float a) |
static int | Sign (int a) |
static float | SqrMagnitudeXZ (Vector3 a, Vector3 b) |
Squared distance between two points on the XZ plane. | |
Static Private Member Functions | |
static int | Bit (int a, int b) |
Returns bit number b from int a. | |
|
static |
|
static |
|
staticprivate |
Returns bit number b from int a.
The bit number is zero based. Relevant b values are from 0 to 31
Equals to (a >> b) & 1
|
static |
|
static |
|
static |
|
static |
|
static |
Returns a hash value for a integer vector.
|
static |
Returns a point on a cubic bezier curve.
t is clamped between 0 and 1
|
static |
Returns the approximate shortest squared distance between x,z and the line p-q.
The line is considered infinite. This function is not entirely exact, but it is about twice as fast as DistancePointSegment2.
Returns the approximate shortest squared distance between x,z and the line p-q.
The line is considered infinite. This function is not entirely exact, but it is about twice as fast as DistancePointSegment2.
|
static |
Returns the distance between x,z and the line p-q.
The line is considered infinite.
|
static |
Returns the distance between c and the line a-b.
The line is considered infinite.
|
static |
Returns the squared distance between c and the line a-b.
The line is not considered infinite.
|
static |
Returns a nicely formatted string for the number of bytes (kB, MB, GB etc).
Uses decimal values, not binary ones
|
static |
Returns a nicely formatted string for the number of bytes (KiB, MiB, GiB etc).
Uses decimal names (KB, Mb - 1000) but calculates using binary values (KiB, MiB - 1024)
|
static |
Returns a point on a hermite curve.
Slow start and slow end, fast in the middle
|
static |
Returns a nice color from int i with alpha a.
Got code from the open-source Recast project, works really good
Seems like there are only 64 possible colors from studying the code
|
static |
|
static |
Distance between two points on the XZ plane.
|
static |
Maps a value between startMin and startMax to be between 0 and 1.
|
static |
Maps a value between startMin and startMax to be between targetMin and targetMax.
|
static |
Maps a value (0...1) to be between targetMin and targetMax.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Factor of the nearest point on the segment.
Returned value is in the range [0,1] if the point lies on the segment otherwise it just lies on the line. The closest point can be got by (end-start)*factor + start;
Factor of the nearest point on the segment.
Returned value is in the range [0,1] if the point lies on the segment otherwise it just lies on the line. The closest point can be got by (end-start)*factor + start;
|
static |
Returns the closest point on the line segment.
The line is NOT treated as infinite.
|
static |
Returns the closest point on the line segment on the XZ plane.
The line is NOT treated as infinite.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Squared distance between two points on the XZ plane.