A* Pathfinding Project  4.1.12
The A* Pathfinding Project for Unity 3D
VectorMath Class Reference

Various vector math utility functions. More...

Detailed Description

Various vector math utility functions.

Version
A lot of functions in the Polygon class have been moved to this class the names have changed slightly and everything now consistently assumes a left handed coordinate system now instead of sometimes using a left handed one and sometimes using a right handed one. This is why the 'Left' methods in the Polygon class redirect to methods named 'Right'. The functionality is exactly the same.

Note the difference between segments and lines. Lines are infinitely long but segments have only a finite length.

Static Public Member Functions

static Vector3 ClampMagnitudeXZ (Vector3 v, float maxMagnitude)
 
static Vector3 ClosestPointOnLine (Vector3 lineStart, Vector3 lineEnd, Vector3 point)
 Returns the closest point on the line. More...
 
static float ClosestPointOnLineFactor (Vector3 lineStart, Vector3 lineEnd, Vector3 point)
 Factor along the line which is closest to the point. More...
 
static float ClosestPointOnLineFactor (Int3 lineStart, Int3 lineEnd, Int3 point)
 Factor along the line which is closest to the point. More...
 
static float ClosestPointOnLineFactor (Int2 lineStart, Int2 lineEnd, Int2 point)
 Factor of the nearest point on the segment. More...
 
static Vector3 ClosestPointOnSegment (Vector3 lineStart, Vector3 lineEnd, Vector3 point)
 Returns the closest point on the segment. More...
 
static Vector3 ClosestPointOnSegmentXZ (Vector3 lineStart, Vector3 lineEnd, Vector3 point)
 Returns the closest point on the segment in the XZ plane. More...
 
static Vector2 ComplexMultiply (Vector2 a, Vector2 b)
 Complex number multiplication. More...
 
static Vector2 ComplexMultiplyConjugate (Vector2 a, Vector2 b)
 Complex number multiplication. More...
 
static bool IsClockwiseMarginXZ (Vector3 a, Vector3 b, Vector3 c)
 Returns if the points a in a clockwise order. More...
 
static bool IsClockwiseOrColinear (Int2 a, Int2 b, Int2 c)
 Returns true if the points a in a clockwise order or if they are colinear. More...
 
static bool IsClockwiseOrColinearXZ (Int3 a, Int3 b, Int3 c)
 Returns true if the points a in a clockwise order or if they are colinear. More...
 
static bool IsClockwiseXZ (Vector3 a, Vector3 b, Vector3 c)
 Returns if the points a in a clockwise order. More...
 
static bool IsClockwiseXZ (Int3 a, Int3 b, Int3 c)
 Returns if the points a in a clockwise order. More...
 
static bool IsColinear (Vector3 a, Vector3 b, Vector3 c)
 Returns if the points are colinear (lie on a straight line) More...
 
static bool IsColinear (Vector2 a, Vector2 b, Vector2 c)
 Returns if the points are colinear (lie on a straight line) More...
 
static bool IsColinearAlmostXZ (Int3 a, Int3 b, Int3 c)
 Returns if the points are colinear (lie on a straight line) More...
 
static bool IsColinearXZ (Int3 a, Int3 b, Int3 c)
 Returns if the points are colinear (lie on a straight line) More...
 
static bool IsColinearXZ (Vector3 a, Vector3 b, Vector3 c)
 Returns if the points are colinear (lie on a straight line) More...
 
static float LineCircleIntersectionFactor (Vector3 circleCenter, Vector3 linePoint1, Vector3 linePoint2, float radius)
 Intersection of a line and a circle. More...
 
static Vector3 LineDirIntersectionPointXZ (Vector3 start1, Vector3 dir1, Vector3 start2, Vector3 dir2)
 Intersection point between two infinite lines. More...
 
static Vector3 LineDirIntersectionPointXZ (Vector3 start1, Vector3 dir1, Vector3 start2, Vector3 dir2, out bool intersects)
 Intersection point between two infinite lines. More...
 
static bool LineIntersectionFactorXZ (Int3 start1, Int3 end1, Int3 start2, Int3 end2, out float factor1, out float factor2)
 Returns the intersection factors for line 1 and line 2. More...
 
static bool LineIntersectionFactorXZ (Vector3 start1, Vector3 end1, Vector3 start2, Vector3 end2, out float factor1, out float factor2)
 Returns the intersection factors for line 1 and line 2. More...
 
static float LineIntersectionFactorXZ (Vector3 start1, Vector3 end1, Vector3 start2, Vector3 end2)
 Returns the intersection factor for line 1 with line 2. More...
 
static Vector2 LineIntersectionPoint (Vector2 start1, Vector2 end1, Vector2 start2, Vector2 end2)
 Returns the intersection point between the two lines. More...
 
static Vector2 LineIntersectionPoint (Vector2 start1, Vector2 end1, Vector2 start2, Vector2 end2, out bool intersects)
 Returns the intersection point between the two lines. More...
 
static Vector3 LineIntersectionPointXZ (Vector3 start1, Vector3 end1, Vector3 start2, Vector3 end2)
 Returns the intersection point between the two lines. More...
 
static Vector3 LineIntersectionPointXZ (Vector3 start1, Vector3 end1, Vector3 start2, Vector3 end2, out bool intersects)
 Returns the intersection point between the two lines. More...
 
static float LineRayIntersectionFactorXZ (Int3 start1, Int3 end1, Int3 start2, Int3 end2)
 Returns the intersection factor for line 1 with ray 2. More...
 
static float MagnitudeXZ (Vector3 v)
 
static Vector3 Normalize (Vector3 v, out float magnitude)
 Normalize vector and also return the magnitude. More...
 
static Vector2 Normalize (Vector2 v, out float magnitude)
 Normalize vector and also return the magnitude. More...
 
static bool RaySegmentIntersectXZ (Int3 start1, Int3 end1, Int3 start2, Int3 end2)
 Returns if the ray (start1, end1) intersects the segment (start2, end2). More...
 
static bool ReversesFaceOrientations (Matrix4x4 matrix)
 True if the matrix will reverse orientations of faces. More...
 
static bool ReversesFaceOrientationsXZ (Matrix4x4 matrix)
 True if the matrix will reverse orientations of faces in the XZ plane. More...
 
static bool RightOrColinear (Vector2 a, Vector2 b, Vector2 p)
 Returns if p lies on the right side of the line a - b. More...
 
static bool RightOrColinear (Int2 a, Int2 b, Int2 p)
 Returns if p lies on the right side of the line a - b. More...
 
static bool RightOrColinearXZ (Vector3 a, Vector3 b, Vector3 p)
 Returns if p lies on the left side of the line a - b. More...
 
static bool RightOrColinearXZ (Int3 a, Int3 b, Int3 p)
 Returns if p lies on the left side of the line a - b. More...
 
static bool RightXZ (Vector3 a, Vector3 b, Vector3 p)
 Returns if p lies on the right side of the line a - b. More...
 
static bool RightXZ (Int3 a, Int3 b, Int3 p)
 Returns if p lies on the right side of the line a - b. More...
 
static Vector3 SegmentIntersectionPointXZ (Vector3 start1, Vector3 end1, Vector3 start2, Vector3 end2, out bool intersects)
 Returns the intersection point between the two line segments in XZ space. More...
 
static bool SegmentIntersectsBounds (Bounds bounds, Vector3 a, Vector3 b)
 Does the line segment intersect the bounding box. More...
 
static bool SegmentsIntersect (Int2 start1, Int2 end1, Int2 start2, Int2 end2)
 Returns if the line segment start2 - end2 intersects the line segment start1 - end1. More...
 
static bool SegmentsIntersectXZ (Int3 start1, Int3 end1, Int3 start2, Int3 end2)
 Returns if the line segment start2 - end2 intersects the line segment start1 - end1. More...
 
static bool SegmentsIntersectXZ (Vector3 start1, Vector3 end1, Vector3 start2, Vector3 end2)
 Returns if the two line segments intersects. More...
 
static Side SideXZ (Int3 a, Int3 b, Int3 p)
 Returns which side of the line a - b that p lies on. More...
 
static long SignedTriangleAreaTimes2XZ (Int3 a, Int3 b, Int3 c)
 Signed area of a triangle in the XZ plane multiplied by 2. More...
 
static float SignedTriangleAreaTimes2XZ (Vector3 a, Vector3 b, Vector3 c)
 Signed area of a triangle in the XZ plane multiplied by 2. More...
 
static float SqrDistancePointSegment (Vector3 a, Vector3 b, Vector3 p)
 Returns the squared distance between p and the segment a-b. More...
 
static float SqrDistancePointSegmentApproximate (int x, int z, int px, int pz, int qx, int qz)
 Returns the approximate shortest squared distance between x,z and the segment p-q. More...
 
static float SqrDistancePointSegmentApproximate (Int3 a, Int3 b, Int3 p)
 Returns the approximate shortest squared distance between x,z and the segment p-q. More...
 
static float SqrDistanceSegmentSegment (Vector3 s1, Vector3 e1, Vector3 s2, Vector3 e2)
 3D minimum distance between 2 segments. More...
 
static float SqrDistanceXZ (Vector3 a, Vector3 b)
 Squared distance between two points in the XZ plane. More...
 

Member Function Documentation

◆ ClampMagnitudeXZ()

static Vector3 ClampMagnitudeXZ ( Vector3  v,
float  maxMagnitude 
)
static

◆ ClosestPointOnLine()

static Vector3 ClosestPointOnLine ( Vector3  lineStart,
Vector3  lineEnd,
Vector3  point 
)
static

Returns the closest point on the line.

The line is treated as infinite.

See also
ClosestPointOnSegment
ClosestPointOnLineFactor

◆ ClosestPointOnLineFactor() [1/3]

static float ClosestPointOnLineFactor ( Vector3  lineStart,
Vector3  lineEnd,
Vector3  point 
)
static

Factor along the line which is closest to the point.

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 calculated using (end-start)*factor + start.

See also
ClosestPointOnLine
ClosestPointOnSegment

◆ ClosestPointOnLineFactor() [2/3]

static float ClosestPointOnLineFactor ( Int3  lineStart,
Int3  lineEnd,
Int3  point 
)
static

Factor along the line which is closest to the point.

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 calculated using (end-start)*factor + start

◆ ClosestPointOnLineFactor() [3/3]

static float ClosestPointOnLineFactor ( Int2  lineStart,
Int2  lineEnd,
Int2  point 
)
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 calculated using (end-start)*factor + start;

◆ ClosestPointOnSegment()

static Vector3 ClosestPointOnSegment ( Vector3  lineStart,
Vector3  lineEnd,
Vector3  point 
)
static

Returns the closest point on the segment.

The segment is NOT treated as infinite.

See also
ClosestPointOnLine
ClosestPointOnSegmentXZ

◆ ClosestPointOnSegmentXZ()

static Vector3 ClosestPointOnSegmentXZ ( Vector3  lineStart,
Vector3  lineEnd,
Vector3  point 
)
static

Returns the closest point on the segment in the XZ plane.

The y coordinate of the result will be the same as the y coordinate of the point parameter.

The segment is NOT treated as infinite.

See also
ClosestPointOnSegment
ClosestPointOnLine

◆ ComplexMultiply()

static Vector2 ComplexMultiply ( Vector2  a,
Vector2  b 
)
static

Complex number multiplication.

Returns
a * b

Used to rotate vectors in an efficient way.

See also
https://en.wikipedia.org/wiki/Complex_number#Multiplication_and_division

◆ ComplexMultiplyConjugate()

static Vector2 ComplexMultiplyConjugate ( Vector2  a,
Vector2  b 
)
static

Complex number multiplication.

Returns
a * conjugate(b)

Used to rotate vectors in an efficient way.

See also
https://en.wikipedia.org/wiki/Complex_number#Multiplication_and_division
https://en.wikipedia.org/wiki/Complex_conjugate

◆ IsClockwiseMarginXZ()

static bool IsClockwiseMarginXZ ( Vector3  a,
Vector3  b,
Vector3  c 
)
static

Returns if the points a in a clockwise order.

Will return true even if the points are colinear or very slightly counter-clockwise (if the signed area of the triangle formed by the points has an area less than or equals to float.Epsilon)

◆ IsClockwiseOrColinear()

static bool IsClockwiseOrColinear ( Int2  a,
Int2  b,
Int2  c 
)
static

Returns true if the points a in a clockwise order or if they are colinear.

◆ IsClockwiseOrColinearXZ()

static bool IsClockwiseOrColinearXZ ( Int3  a,
Int3  b,
Int3  c 
)
static

Returns true if the points a in a clockwise order or if they are colinear.

◆ IsClockwiseXZ() [1/2]

static bool IsClockwiseXZ ( Vector3  a,
Vector3  b,
Vector3  c 
)
static

Returns if the points a in a clockwise order.

◆ IsClockwiseXZ() [2/2]

static bool IsClockwiseXZ ( Int3  a,
Int3  b,
Int3  c 
)
static

Returns if the points a in a clockwise order.

◆ IsColinear() [1/2]

static bool IsColinear ( Vector3  a,
Vector3  b,
Vector3  c 
)
static

Returns if the points are colinear (lie on a straight line)

◆ IsColinear() [2/2]

static bool IsColinear ( Vector2  a,
Vector2  b,
Vector2  c 
)
static

Returns if the points are colinear (lie on a straight line)

◆ IsColinearAlmostXZ()

static bool IsColinearAlmostXZ ( Int3  a,
Int3  b,
Int3  c 
)
static

Returns if the points are colinear (lie on a straight line)

◆ IsColinearXZ() [1/2]

static bool IsColinearXZ ( Int3  a,
Int3  b,
Int3  c 
)
static

Returns if the points are colinear (lie on a straight line)

◆ IsColinearXZ() [2/2]

static bool IsColinearXZ ( Vector3  a,
Vector3  b,
Vector3  c 
)
static

Returns if the points are colinear (lie on a straight line)

◆ LineCircleIntersectionFactor()

static float LineCircleIntersectionFactor ( Vector3  circleCenter,
Vector3  linePoint1,
Vector3  linePoint2,
float  radius 
)
static

Intersection of a line and a circle.

Returns the greatest t such that segmentStart+t*(segmentEnd-segmentStart) lies on the circle.

In case the line does not intersect with the circle, the closest point on the line to the circle will be returned.

Note
Works for line and sphere in 3D space as well.
See also
http://mathworld.wolfram.com/Circle-LineIntersection.html
https://en.wikipedia.org/wiki/Intersection_(Euclidean_geometry)#A_line_and_a_circle

◆ LineDirIntersectionPointXZ() [1/2]

static Vector3 LineDirIntersectionPointXZ ( Vector3  start1,
Vector3  dir1,
Vector3  start2,
Vector3  dir2 
)
static

Intersection point between two infinite lines.

Note that start points and directions are taken as parameters instead of start and end points. Lines are treated as infinite. If the lines are parallel 'start1' will be returned. Intersections are calculated on the XZ plane.

See also
LineIntersectionPointXZ

◆ LineDirIntersectionPointXZ() [2/2]

static Vector3 LineDirIntersectionPointXZ ( Vector3  start1,
Vector3  dir1,
Vector3  start2,
Vector3  dir2,
out bool  intersects 
)
static

Intersection point between two infinite lines.

Note that start points and directions are taken as parameters instead of start and end points. Lines are treated as infinite. If the lines are parallel 'start1' will be returned. Intersections are calculated on the XZ plane.

See also
LineIntersectionPointXZ

◆ LineIntersectionFactorXZ() [1/3]

static bool LineIntersectionFactorXZ ( Int3  start1,
Int3  end1,
Int3  start2,
Int3  end2,
out float  factor1,
out float  factor2 
)
static

Returns the intersection factors for line 1 and line 2.

The intersection factors is a distance along the line start - end where the other line intersects it.

intersectionPoint = start1 + factor1 * (end1-start1)
intersectionPoint2 = start2 + factor2 * (end2-start2)

Lines are treated as infinite.
false is returned if the lines are parallel and true if they are not. Only the XZ coordinates are used.

◆ LineIntersectionFactorXZ() [2/3]

static bool LineIntersectionFactorXZ ( Vector3  start1,
Vector3  end1,
Vector3  start2,
Vector3  end2,
out float  factor1,
out float  factor2 
)
static

Returns the intersection factors for line 1 and line 2.

The intersection factors is a distance along the line start - end where the other line intersects it.

intersectionPoint = start1 + factor1 * (end1-start1)
intersectionPoint2 = start2 + factor2 * (end2-start2)

Lines are treated as infinite.
false is returned if the lines are parallel and true if they are not. Only the XZ coordinates are used.

◆ LineIntersectionFactorXZ() [3/3]

static float LineIntersectionFactorXZ ( Vector3  start1,
Vector3  end1,
Vector3  start2,
Vector3  end2 
)
static

Returns the intersection factor for line 1 with line 2.

The intersection factor is a distance along the line start1 - end1 where the line start2 - end2 intersects it.

intersectionPoint = start1 + intersectionFactor * (end1-start1)

. Lines are treated as infinite.
-1 is returned if the lines are parallel (note that this is a valid return value if they are not parallel too)

◆ LineIntersectionPoint() [1/2]

static Vector2 LineIntersectionPoint ( Vector2  start1,
Vector2  end1,
Vector2  start2,
Vector2  end2 
)
static

Returns the intersection point between the two lines.

Lines are treated as infinite. start1 is returned if the lines are parallel

◆ LineIntersectionPoint() [2/2]

static Vector2 LineIntersectionPoint ( Vector2  start1,
Vector2  end1,
Vector2  start2,
Vector2  end2,
out bool  intersects 
)
static

Returns the intersection point between the two lines.

Lines are treated as infinite. start1 is returned if the lines are parallel

◆ LineIntersectionPointXZ() [1/2]

static Vector3 LineIntersectionPointXZ ( Vector3  start1,
Vector3  end1,
Vector3  start2,
Vector3  end2 
)
static

Returns the intersection point between the two lines.

Lines are treated as infinite. start1 is returned if the lines are parallel

◆ LineIntersectionPointXZ() [2/2]

static Vector3 LineIntersectionPointXZ ( Vector3  start1,
Vector3  end1,
Vector3  start2,
Vector3  end2,
out bool  intersects 
)
static

Returns the intersection point between the two lines.

Lines are treated as infinite. start1 is returned if the lines are parallel

◆ LineRayIntersectionFactorXZ()

static float LineRayIntersectionFactorXZ ( Int3  start1,
Int3  end1,
Int3  start2,
Int3  end2 
)
static

Returns the intersection factor for line 1 with ray 2.

The intersection factors is a factor distance along the line start - end where the other line intersects it.

intersectionPoint = start1 + factor * (end1-start1)

Lines are treated as infinite.
The second "line" is treated as a ray, meaning only matches on start2 or forwards towards end2 (and beyond) will be returned If the point lies on the wrong side of the ray start, Nan will be returned.

NaN is returned if the lines are parallel.

◆ MagnitudeXZ()

static float MagnitudeXZ ( Vector3  v)
static

◆ Normalize() [1/2]

static Vector3 Normalize ( Vector3  v,
out float  magnitude 
)
static

Normalize vector and also return the magnitude.

This is more efficient than calculating the magnitude and normalizing separately

◆ Normalize() [2/2]

static Vector2 Normalize ( Vector2  v,
out float  magnitude 
)
static

Normalize vector and also return the magnitude.

This is more efficient than calculating the magnitude and normalizing separately

◆ RaySegmentIntersectXZ()

static bool RaySegmentIntersectXZ ( Int3  start1,
Int3  end1,
Int3  start2,
Int3  end2 
)
static

Returns if the ray (start1, end1) intersects the segment (start2, end2).

false is returned if the lines are parallel. Only the XZ coordinates are used.

Todo:
Double check that this actually works

◆ ReversesFaceOrientations()

static bool ReversesFaceOrientations ( Matrix4x4  matrix)
static

True if the matrix will reverse orientations of faces.

Scaling by a negative value along an odd number of axes will reverse the orientation of e.g faces on a mesh. This must be counter adjusted by for example the recast rasterization system to be able to handle meshes with negative scales properly.

We can find out if they are flipped by finding out how the signed volume of a unit cube is transformed when applying the matrix

If the (signed) volume turns out to be negative that also means that the orientation of it has been reversed.

See also
https://en.wikipedia.org/wiki/Normal_(geometry)
https://en.wikipedia.org/wiki/Parallelepiped

◆ ReversesFaceOrientationsXZ()

static bool ReversesFaceOrientationsXZ ( Matrix4x4  matrix)
static

True if the matrix will reverse orientations of faces in the XZ plane.

Almost the same as ReversesFaceOrientations, but this method assumes that scaling a face with a negative scale along the Y axis does not reverse the orientation of the face.

This is used for navmesh cuts.

Scaling by a negative value along one axis or rotating it so that it is upside down will reverse the orientation of the cut, so we need to be reverse it again as a countermeasure. However if it is flipped along two axes it does not need to be reversed. We can handle all these cases by finding out how a unit square formed by our forward axis and our rightward axis is transformed in XZ space when applying the local to world matrix. If the (signed) area of the unit square turns out to be negative that also means that the orientation of it has been reversed. The signed area is calculated using a cross product of the vectors.

◆ RightOrColinear() [1/2]

static bool RightOrColinear ( Vector2  a,
Vector2  b,
Vector2  p 
)
static

Returns if p lies on the right side of the line a - b.

Also returns true if the points are colinear.

◆ RightOrColinear() [2/2]

static bool RightOrColinear ( Int2  a,
Int2  b,
Int2  p 
)
static

Returns if p lies on the right side of the line a - b.

Also returns true if the points are colinear.

◆ RightOrColinearXZ() [1/2]

static bool RightOrColinearXZ ( Vector3  a,
Vector3  b,
Vector3  p 
)
static

Returns if p lies on the left side of the line a - b.

Uses XZ space. Also returns true if the points are colinear.

◆ RightOrColinearXZ() [2/2]

static bool RightOrColinearXZ ( Int3  a,
Int3  b,
Int3  p 
)
static

Returns if p lies on the left side of the line a - b.

Uses XZ space. Also returns true if the points are colinear.

◆ RightXZ() [1/2]

static bool RightXZ ( Vector3  a,
Vector3  b,
Vector3  p 
)
static

Returns if p lies on the right side of the line a - b.

Uses XZ space. Does not return true if the points are colinear.

◆ RightXZ() [2/2]

static bool RightXZ ( Int3  a,
Int3  b,
Int3  p 
)
static

Returns if p lies on the right side of the line a - b.

Uses XZ space. Does not return true if the points are colinear.

◆ SegmentIntersectionPointXZ()

static Vector3 SegmentIntersectionPointXZ ( Vector3  start1,
Vector3  end1,
Vector3  start2,
Vector3  end2,
out bool  intersects 
)
static

Returns the intersection point between the two line segments in XZ space.

Lines are NOT treated as infinite. start1 is returned if the line segments do not intersect The point will be returned along the line [start1, end1] (this matters only for the y coordinate).

◆ SegmentIntersectsBounds()

static bool SegmentIntersectsBounds ( Bounds  bounds,
Vector3  a,
Vector3  b 
)
static

Does the line segment intersect the bounding box.

The line is NOT treated as infinite.

Author
Slightly modified code from http://www.3dkingdoms.com/weekly/weekly.php?a=21

◆ SegmentsIntersect()

static bool SegmentsIntersect ( Int2  start1,
Int2  end1,
Int2  start2,
Int2  end2 
)
static

Returns if the line segment start2 - end2 intersects the line segment start1 - end1.

If only the endpoints coincide, the result is undefined (may be true or false).

◆ SegmentsIntersectXZ() [1/2]

static bool SegmentsIntersectXZ ( Int3  start1,
Int3  end1,
Int3  start2,
Int3  end2 
)
static

Returns if the line segment start2 - end2 intersects the line segment start1 - end1.

If only the endpoints coincide, the result is undefined (may be true or false).

Note
XZ space

◆ SegmentsIntersectXZ() [2/2]

static bool SegmentsIntersectXZ ( Vector3  start1,
Vector3  end1,
Vector3  start2,
Vector3  end2 
)
static

Returns if the two line segments intersects.

The lines are NOT treated as infinite (just for clarification)

See also
IntersectionPoint

◆ SideXZ()

static Side SideXZ ( Int3  a,
Int3  b,
Int3  p 
)
static

Returns which side of the line a - b that p lies on.

Uses XZ space.

◆ SignedTriangleAreaTimes2XZ() [1/2]

static long SignedTriangleAreaTimes2XZ ( Int3  a,
Int3  b,
Int3  c 
)
static

Signed area of a triangle in the XZ plane multiplied by 2.

This will be negative for clockwise triangles and positive for counter-clockwise ones

◆ SignedTriangleAreaTimes2XZ() [2/2]

static float SignedTriangleAreaTimes2XZ ( Vector3  a,
Vector3  b,
Vector3  c 
)
static

Signed area of a triangle in the XZ plane multiplied by 2.

This will be negative for clockwise triangles and positive for counter-clockwise ones.

◆ SqrDistancePointSegment()

static float SqrDistancePointSegment ( Vector3  a,
Vector3  b,
Vector3  p 
)
static

Returns the squared distance between p and the segment a-b.

The line is not considered infinite.

◆ SqrDistancePointSegmentApproximate() [1/2]

static float SqrDistancePointSegmentApproximate ( int  x,
int  z,
int  px,
int  pz,
int  qx,
int  qz 
)
static

Returns the approximate shortest squared distance between x,z and the segment p-q.

The segment is not considered infinite. This function is not entirely exact, but it is about twice as fast as DistancePointSegment2.

Todo:
Is this actually approximate? It looks exact.

◆ SqrDistancePointSegmentApproximate() [2/2]

static float SqrDistancePointSegmentApproximate ( Int3  a,
Int3  b,
Int3  p 
)
static

Returns the approximate shortest squared distance between x,z and the segment p-q.

The segment is not considered infinite. This function is not entirely exact, but it is about twice as fast as DistancePointSegment2.

Todo:
Is this actually approximate? It looks exact.

◆ SqrDistanceSegmentSegment()

static float SqrDistanceSegmentSegment ( Vector3  s1,
Vector3  e1,
Vector3  s2,
Vector3  e2 
)
static

3D minimum distance between 2 segments.

Input: two 3D line segments S1 and S2

Returns
the shortest squared distance between S1 and S2

◆ SqrDistanceXZ()

static float SqrDistanceXZ ( Vector3  a,
Vector3  b 
)
static

Squared distance between two points in the XZ plane.


The documentation for this class was generated from the following file: