Geometric

Description

static class Tinman.Core.Math.Geometric

Helper class for computing geometric intersections.

Public / Methods

Area​Polygon

2 overloads


public static method AreaPolygon1 → (3)

in : Vec2D [ ]

[not-null]
The polygon vertices.

in : int32

[0..v.Length-1]
Index of first polygon vertex.

in : int32

[0..v.Length-1]
Index of last polygon vertex.

returns → float64

The signed area of the simple polygon.

Computes the signed area of the given simple polygon.

The polygon is defined as follows:

v[a    ] := first polygon vertex
v[a + n] := n-th polygon vertex
v[b    ] := last polygon vertex (not equal to first)

where b - a >= 2
      b - a >= n >= 0

Inverting the order of the polygon vertices will flip the sign of the area value. For a standard Cartesian coordinate system (X-axis points to the right, Y-axis points upwards), clockwise polygons have negative area values and counter-clockwise polygons have positive area values.


public static method AreaPolygon2 → (4)

in : Vec2D [ ]

[not-null]
The polygon vertices.

in : int32 [ ]

[not-null]
The polygon vertex indices.

in : int32

[0..i.Length-1]
Index of first polygon vertex index.

in : int32

[0..i.Length-1]
Index of last polygon vertex index.

returns → float64

The signed area of the simple polygon.

Computes the signed area of the given simple polygon.

The polygon is defined as follows:

v[i[a    ]] := first polygon vertex
v[i[a + n]] := n-th polygon vertex
v[i[b    ]] := last polygon vertex (not equal to first)

where b - a >= 2
      b - a >= n >= 0

Inverting the order of the polygon vertices will flip the sign of the area value. For a standard Cartesian coordinate system (X-axis points to the right, Y-axis points upwards), clockwise polygons have negative area values and counter-clockwise polygons have positive area values.

Area​Triangle

4 overloads


[Pure]
public static method AreaTriangle1 → (3)

v1 in : Vec2D

First vertex of triangle.

v2 in : Vec2D

Second vertex of triangle.

v3 in : Vec2D

Third vertex of triangle.

returns → float64

The signed area of the triangle.

Computes the area of the given triangle.


[Pure]
public static method AreaTriangle2 → (6)

x1 in : float64

X-coordinate of first vertex of triangle.

y1 in : float64

Y-coordinate of first vertex of triangle.

x2 in : float64

X-coordinate of second vertex of triangle.

y2 in : float64

Y-coordinate of second vertex of triangle.

x3 in : float64

X-coordinate of third vertex of triangle.

y3 in : float64

Y-coordinate of third vertex of triangle.

returns → float64

The signed area of the triangle.

Computes the area of the given triangle.


[Pure]
public static method AreaTriangle3 → (3)

v1 in : Vec3D

First vertex of triangle.

v2 in : Vec3D

Second vertex of triangle.

v3 in : Vec3D

Third vertex of triangle.

returns → float64

The area of the triangle.

Computes the area of the given triangle.


[Pure]
public static method AreaTriangle4 → (9)

x1 in : float64

X-coordinate of first vertex of triangle.

y1 in : float64

Y-coordinate of first vertex of triangle.

z1 in : float64

Z-coordinate of first vertex of triangle.

x2 in : float64

X-coordinate of second vertex of triangle.

y2 in : float64

Y-coordinate of second vertex of triangle.

z2 in : float64

Z-coordinate of second vertex of triangle.

x3 in : float64

X-coordinate of third vertex of triangle.

y3 in : float64

Y-coordinate of third vertex of triangle.

z3 in : float64

Z-coordinate of third vertex of triangle.

returns → float64

The area of the triangle.

Computes the area of the given triangle.

Best​Basis​Vector


[Pure]
public static method BestBasisVector → (1)

in : Vec3D

The vector.

returns → Vec3D

The basis vector with the smallest absolute dot product with in.

Returns the basis vector (X, Y or Z) that has the highest amount of perpendicularity to the given vector.

Cartesian​To​Spherical

2 overloads


[Pure]
public static method CartesianToSpherical1 → (1)

cartesian in : Vec3D

The cartesian coordinates.

returns → Vec3D

The spherical coordinates.

Converts the given cartesian coordinates into spherical coordinates.

The components of the returned vector have the following semantic:

spherical.X := radius (distance to origin).
spherical.Y := azimuthal angle (angle from positive X-axis in radians) in the range [-PI..PI].
spherical.Z := polar angle (angle from positive Z-axis in radians) in the range [0..PI].

[Pure]
public static method CartesianToSpherical2 → (3)

in : float64

The cartesian X-coordinate.

in : float64

The cartesian Y-coordinate.

in : float64

The cartesian Z-coordinate.

returns → Vec3D

The spherical coordinates.

Converts the given cartesian coordinates into spherical coordinates.

The components of the returned vector have the following semantic:

spherical.X := radius (distance to origin).
spherical.Y := azimuthal angle (angle from positive X-axis in radians) in the range [-PI..PI].
spherical.Z := polar angle (angle from positive Z-axis in radians) in the range [0..PI].

Check​Intersection​Of​Line​Segments

2 overloads


[Pure]
public static method CheckIntersectionOfLineSegments1 → (4)

v1 in : Vec2D

Start of first line segment.

v2 in : Vec2D

End of first line segment.

v3 in : Vec2D

Start of second line segment.

v4 in : Vec2D

End of second line segment.

returns → bool

true if the line segments intersect, false if not.

Checks if the given line segments intersect.


[Pure]
public static method CheckIntersectionOfLineSegments2 → (8)

x1 in : float64

X-coordinate of start of first line segment.

y1 in : float64

Y-coordinate of start of first line segment.

x2 in : float64

X-coordinate of end of first line segment.

y2 in : float64

Y-coordinate of end of first line segment.

x3 in : float64

X-coordinate of start of second line segment.

y3 in : float64

X-coordinate of start of second line segment.

x4 in : float64

X-coordinate of end of second line segment.

y4 in : float64

X-coordinate of end of second line segment.

returns → bool

true if the line segments intersect, false if not.

Checks if the given line segments intersect.

Cone​Fit​Angle


[Pure]
public static method ConeFitAngle → (3)

in : float64

X-coordinate of sphere center.

in : float64

Y-coordinate of sphere center.

in : float64

Radius of sphere.

returns → float64

The opening angle of the cone, in radians. Will be Maths.NanD if in, in or in is negative or if the cone apex is inside of the sphere.

Computes the opening angle of the right circular cone having the smallest volume that contains the given sphere.

The cone apex is at (0,0,0). The cone axis is collinear to (1,0,0). The sphere center is at (in, in, 0).

Cone​Fit​Distance


[Pure]
public static method ConeFitDistance → (4)

in : float64

The cone opening angle, in radians.

in : float64

X-coordinate of sphere center.

in : float64

Y-coordinate of sphere center.

in : float64

Radius of sphere.

returns → float64

The translation along the X-axis that must be applied to the cone apex in order to make the cone touch the sphere, while containing it. Will be Maths.NanD if in or in is negative or if in is outside of the range ]0..pi[.

Computes the translation that must be applied to the given right circular to make it contain the given sphere, while only touching it in a single point.

The cone apex is at (0,0,0). The cone axis is collinear to (1,0,0). The sphere center is at (in, in, 0).

Distance​Line​To​Line


[Pure]
public static method DistanceLineToLine → (4)

s1 in : Vec3D

Point on first line.

v1 in : Vec3D

Direction vector of first line.

s2 in : Vec3D

Point on second line.

v2 in : Vec3D

Direction vector of second line.

returns → Vec2D

The coefficient vector for computing the two nearest points on both lines:

p1 = s1 + v1 * X
p2 = s2 + v2 * Y

Computes the pair of nearest points on two lines.

Distance​Point​To​Horizon


[Pure]
public static method DistancePointToHorizon → (2)

point in : Vec3D

The point coordinates.

radius in : float64

[>0]
The sphere radius.

returns → float64

The distance to the horizon, in terrain-space.

Computes the distance from the given point to the horizon circle on a sphere centered at the coordinate origin and having the given radius.

Distance​Point​To​Line


public static method DistancePointToLine → (3)

in : Vec3D

The point.

in : Vec3D

A point on the line.

in : Vec3D

Unit-length direction vector of the line.

returns → Vec3D

The point on the line that is nearest to in.

Returns the distance of the given point to the specified line.

Distance​Point​To​Line​Segment

8 overloads


[Pure]
public static method DistancePointToLineSegment1 → (2)

in : Vec2D

Start point of line segment.

in : Vec2D

End point of line segment.

returns → float64

The distance of the point on line segment from where the distance has been computed.

Computes the distance between the point (0|0) and the given line segment.


[Pure]
public static method DistancePointToLineSegment2 → (4)

ax in : float64

X-coordinate of start point of line segment.

ay in : float64

Y-coordinate of start point of line segment.

bx in : float64

X-coordinate of end point of line segment.

by in : float64

Y-coordinate of end point of line segment.

returns → float64

The distance of the point on line segment from where the distance has been computed.

Computes the distance between the point (0|0) and the given line segment.


[Pure]
public static method DistancePointToLineSegment3 → (2)

in : Vec3D

Start point of line segment.

in : Vec3D

End point of line segment.

returns → float64

The distance of the point on line segment from where the distance has been computed.

Computes the distance between the point (0|0) and the given line segment.


[Pure]
public static method DistancePointToLineSegment4 → (6)

ax in : float64

X-coordinate of start point of line segment.

ay in : float64

Y-coordinate of start point of line segment.

az in : float64

Z-coordinate of start point of line segment.

bx in : float64

X-coordinate of end point of line segment.

by in : float64

Y-coordinate of end point of line segment.

bz in : float64

Z-coordinate of end point of line segment.

returns → float64

The distance of the point on line segment from where the distance has been computed.

Computes the distance between the point (0|0) and the given line segment.


[Pure]
public static method DistancePointToLineSegment5 → (3)

in : Vec2D

Start point of line segment.

in : Vec2D

End point of line segment.

result out : Vec2D

The distance (see Vec2D.X) and weight of point on line segment from where the distance has been computed (see Vec2D.Y, 0 = start point, 1 = end point).

Computes the distance between the point (0|0) and the given line segment.


[Pure]
public static method DistancePointToLineSegment6 → (5)

ax in : float64

X-coordinate of start point of line segment.

ay in : float64

Y-coordinate of start point of line segment.

bx in : float64

X-coordinate of end point of line segment.

by in : float64

Y-coordinate of end point of line segment.

result out : Vec2D

The distance (see Vec2D.X) and weight of point on line segment from where the distance has been computed (see Vec2D.Y, 0 = start point, 1 = end point).

Computes the distance between the point (0|0) and the given line segment.


[Pure]
public static method DistancePointToLineSegment7 → (3)

in : Vec3D

Start point of line segment.

in : Vec3D

End point of line segment.

result out : Vec2D

The distance (see Vec2D.X) and weight of point on line segment from where the distance has been computed (see Vec2D.Y, 0 = start point, 1 = end point).

Computes the distance between the point (0|0) and the given line segment.


[Pure]
public static method DistancePointToLineSegment8 → (7)

ax in : float64

X-coordinate of start point of line segment.

ay in : float64

Y-coordinate of start point of line segment.

az in : float64

Z-coordinate of start point of line segment.

bx in : float64

X-coordinate of end point of line segment.

by in : float64

Y-coordinate of end point of line segment.

bz in : float64

Z-coordinate of end point of line segment.

result out : Vec2D

The distance (see Vec2D.X) and weight of point on line segment from where the distance has been computed (see Vec2D.Y, 0 = start point, 1 = end point).

Computes the distance between the point (0|0) and the given line segment.

Distance​Point​To​Triangle


[Pure]
public static method DistancePointToTriangle → (4)

point in : Vec3D

The point.

in : Vec3D

First triangle vertex.

in : Vec3D

Second triangle vertex.

in : Vec3D

Third triangle vertex.

returns → float64

The positive distance.

Computes the distance between a triangle and the given point.

Intersection​Of​Circles


[Pure]
public static method IntersectionOfCircles → (3)

in : float64

Distance between the center points of the circles.

r0 in : float64

Radius of first circle.

r1 in : float64

Radius of second circle.

returns → Vec2D

If Vec2D.Undefined, the circles do not intersect.
If Vec2D.Y is zero, the circles intersect in a single point.
Otherwise, the circles intersect in two points.
The intersection points can be computed as follows:
(X, -Y)
(X, +Y)

Computes the intersection of the given circles.

The first circle is centered at the coordinate origin, the second circle is centered at (d,0).

Intersection​Of​Lines

2 overloads


[Pure]
public static method IntersectionOfLines1 → (4)

v1 in : Vec2D

First point on first line.

v2 in : Vec2D

Second point on first line.

v3 in : Vec2D

First point on second line.

v4 in : Vec2D

Second point on second line.

returns → Vec2D

The intersection point or Vec2D.Undefined if the lines parallel.

Computes the intersection of the given lines.


[Pure]
public static method IntersectionOfLines2 → (8)

x1 in : float64

X-coordinate of first point on first line.

y1 in : float64

Y-coordinate of first point on first line.

x2 in : float64

X-coordinate of second point on first line.

y2 in : float64

Y-coordinate of second point on first line.

x3 in : float64

X-coordinate of first point on second line.

y3 in : float64

Y-coordinate of first point on second line.

x4 in : float64

X-coordinate of second point on second line.

y4 in : float64

Y-coordinate of second point on second line.

returns → Vec2D

The intersection point or Vec2D.Undefined if the lines parallel.

Computes the intersection of the given lines.

Intersection​Of​Line​Segments

2 overloads


[Pure]
public static method IntersectionOfLineSegments1 → (4)

v1 in : Vec2D

Start of first line segment.

v2 in : Vec2D

End of first line segment.

v3 in : Vec2D

Start of second line segment.

v4 in : Vec2D

End of second line segment.

returns → Vec2D

The intersection point or Vec2D.Undefined if the line segments are parallel or do not intersect.

Computes the intersection of the given line segments.


[Pure]
public static method IntersectionOfLineSegments2 → (8)

x1 in : float64

X-coordinate of start of first line segment.

y1 in : float64

Y-coordinate of start of first line segment.

x2 in : float64

X-coordinate of end of first line segment.

y2 in : float64

Y-coordinate of end of first line segment.

x3 in : float64

X-coordinate of start of second line segment.

y3 in : float64

Y-coordinate of start of second line segment.

x4 in : float64

X-coordinate of end of second line segment.

y4 in : float64

Y-coordinate of end of second line segment.

returns → Vec2D

The intersection point or Vec2D.Undefined if the line segments are parallel or do not intersect.

Computes the intersection of the given line segments.

Intersection​Of​Ray​And​Plane


[Pure]
public static method IntersectionOfRayAndPlane → (4)

origin in : Vec3D

The ray origin.

direction in : Vec3D

The ray direction.

normal in : Vec3D

Normal vector of plane.

dot in : float64

Dot product of normal in with any point in the plane.

returns → Vec3D

The intersection point or Vec3D.Undefined if there is no intersection.

Computes the intersection between the given ray and plane.

Intersection​Of​Ray​And​Plane​X


[Pure]
public static method IntersectionOfRayAndPlaneX → (4)

origin in : Vec3D

The ray origin.

direction in : Vec3D

The ray direction.

dot in : float64

Dot product of the plane normal (1,0,0) with any point in the plane.

maximum opt : float64 = Maths.MaxDouble

Maximum ray distance to return.

returns → Vec3D

The intersection point or Vec3D.Undefined if there is no intersection.

Computes the intersection between the given ray and plane.

Intersection​Of​Ray​And​Plane​Y


[Pure]
public static method IntersectionOfRayAndPlaneY → (4)

origin in : Vec3D

The ray origin.

direction in : Vec3D

The ray direction.

dot in : float64

Dot product of the plane normal (0,1,0) with any point in the plane.

maximum opt : float64 = Maths.MaxDouble

Maximum ray distance to return.

returns → Vec3D

The intersection point or Vec3D.Undefined if there is no intersection.

Computes the intersection between the given ray and plane.

Intersection​Of​Ray​And​Plane​Z


[Pure]
public static method IntersectionOfRayAndPlaneZ → (4)

origin in : Vec3D

The ray origin.

direction in : Vec3D

The ray direction.

dot in : float64

Dot product of the plane normal (0,0,1) with any point in the plane.

maximum opt : float64 = Maths.MaxDouble

Maximum ray distance to return.

returns → Vec3D

The intersection point or Vec3D.Undefined if there is no intersection.

Computes the intersection between the given ray and plane.

Intersection​Of​Ray​And​Sphere


[Pure]
public static method IntersectionOfRayAndSphere → (4)

origin in : Vec3D

The ray origin.

direction in : Vec3D

The ray direction.

radius in : float64

Sphere radius (center lies at coordinate origin).

sign opt : int32 = 0

Determines which intersection point to return:
<0 : point behind origin in
=0 : any point
>0 : point in front of origin in

returns → Vec3D

The intersection point that is nearest origin in or Vec3D.Undefined.

Computes the intersection between the given ray and sphere.

Intersection​Of​Ray​And​Triangle


[Pure]
public static method IntersectionOfRayAndTriangle → (6)

origin in : Vec3D

The ray origin.

direction in : Vec3D

The ray direction.

v1 in : Vec3D

First triangle vertex.

v2 in : Vec3D

Second triangle vertex.

v3 in : Vec3D

Third triangle vertex.

weights out : Vec3D

The barycentric weights of the found intersection point of or Vec3D.Undefined if there is no intersection.

returns → float64

The distance between the origin in and the found intersection point, divided by the length of direction in. Will be negative iff there is no intersection.

Computes the intersection between the given ray and triangle.

Is​Concave


public static method IsConcave → (4)

in : Vec2D

First vertex.

in : Vec2D

Second vertex.

in : Vec2D

Third vertex.

in : Vec2D

Fourth vertex.

returns → bool

true if the quadrilateral is concave, false if it is convex.

Checks if the given quadrilateral is concave.

Length

4 overloads


[Pure]
public static method Length1 → (2)

in : float64

X-component of vector.

in : float64

Y-component of vector.

returns → float64

The vector length.

Computes the length of the given vector.


[Pure]
public static method Length2 → (3)

in : float64

X-component of vector.

in : float64

Y-component of vector.

in : float64

Z-component of vector.

returns → float64

The vector length.

Computes the length of the given vector.


[Pure]
public static method Length3 → (2)

in : float32

X-component of vector.

in : float32

Y-component of vector.

returns → float32

The vector length.

Computes the length of the given vector.


[Pure]
public static method Length4 → (3)

in : float32

X-component of vector.

in : float32

Y-component of vector.

in : float32

Z-component of vector.

returns → float32

The vector length.

Computes the length of the given vector.

Length​Sqr

4 overloads


[Pure]
public static method LengthSqr1 → (2)

in : float64

X-component of vector.

in : float64

Y-component of vector.

returns → float64

The square vector length.

Computes the square length of the given vector.


[Pure]
public static method LengthSqr2 → (3)

in : float64

X-component of vector.

in : float64

Y-component of vector.

in : float64

Z-component of vector.

returns → float64

The square vector length.

Computes the square length of the given vector.


[Pure]
public static method LengthSqr3 → (2)

in : float32

X-component of vector.

in : float32

Y-component of vector.

returns → float32

The square vector length.

Computes the square length of the given vector.


[Pure]
public static method LengthSqr4 → (3)

in : float32

X-component of vector.

in : float32

Y-component of vector.

in : float32

Z-component of vector.

returns → float32

The square vector length.

Computes the square length of the given vector.

Lerp

4 overloads


[Pure]
public static method Lerp1 → (3)

in : Vec2F

First input vector (maps to f=0).

in : Vec2F

Second input vector (maps to f=1).

in : float32

The interpolation factor in the range [0..1].

returns → Vec2F

The interpolated vector.

Linearly interpolates between the given vectors.


[Pure]
public static method Lerp2 → (3)

in : Vec2D

First input vector (maps to f=0).

in : Vec2D

Second input vector (maps to f=1).

in : float64

The interpolation factor in the range [0..1].

returns → Vec2D

The interpolated vector.

Linearly interpolates between the given vectors.


[Pure]
public static method Lerp3 → (3)

in : Vec3F

First input vector (maps to f=0).

in : Vec3F

Second input vector (maps to f=1).

in : float32

The interpolation factor in the range [0..1].

returns → Vec3F

The interpolated vector.

Linearly interpolates between the given vectors.


[Pure]
public static method Lerp4 → (3)

in : Vec3D

First input vector (maps to f=0).

in : Vec3D

Second input vector (maps to f=1).

in : float64

The interpolation factor in the range [0..1].

returns → Vec3D

The interpolated vector.

Linearly interpolates between the given vectors.

Point​On​Line


[Pure]
public static method PointOnLine → (3)

in : Vec3D

The point.

in : Vec3D

A point on the line.

in : Vec3D

Direction vector of the line.

returns → float64

The coefficient t for computing the projected point on the line:

p' = s + v * t

Computes the projection of a point to a line.

RLength

4 overloads


[Pure]
public static method RLength1 → (2)

in : float64

X-component of vector.

in : float64

Y-component of vector.

returns → float64

The reciprocal vector length or 0 if all vector components are zero.

Computes the reciprocal length of the given vector.


[Pure]
public static method RLength2 → (3)

in : float64

X-component of vector.

in : float64

Y-component of vector.

in : float64

Z-component of vector.

returns → float64

The reciprocal vector length or 0 if all vector components are zero.

Computes the reciprocal length of the given vector.


[Pure]
public static method RLength3 → (2)

in : float32

X-component of vector.

in : float32

Y-component of vector.

returns → float32

The reciprocal vector length or 0 if all vector components are zero.

Computes the reciprocal length of the given vector.


[Pure]
public static method RLength4 → (3)

in : float32

X-component of vector.

in : float32

Y-component of vector.

in : float32

Z-component of vector.

returns → float32

The reciprocal vector length or 0 if all vector components are zero.

Computes the reciprocal length of the given vector.

Slerp

3 overloads


[Pure]
public static method Slerp1 → (2)

dot in : float64

The dot product of the unit-length input vectors, in the range [-1..+1].

in : float64

The interpolation factor in the range [0..1].

returns → Vec2D

The interpolation weights:
Vec2D.X : first input vector
Vec2D.Y : second input vector

Spherically interpolates between the given vectors.


[Pure]
public static method Slerp2 → (3)

in : Vec2D

First input vector (maps to f=0).

in : Vec2D

Second input vector (maps to f=1).

in : float64

The interpolation factor in the range [0..1].

returns → Vec2D

The interpolated vector.

Spherically interpolates between the given vectors.

See also

Geometric.Slerp1


[Pure]
public static method Slerp3 → (3)

in : Vec3D

First input vector (maps to f=0).

in : Vec3D

Second input vector (maps to f=1).

in : float64

The interpolation factor in the range [0..1].

returns → Vec3D

The interpolated vector.

Spherically interpolates between the given vectors.

See also

Geometric.Slerp1

Sort​By​XY


[Pure]
public static method SortByXY → (2)

in : Vec2D

First point.

in : Vec2D

Second point.

returns → int32

The comparison result.

Sorts the given 2D points by their coordinates (X ascending, Y ascending).

Spherical​To​Cartesian

2 overloads


[Pure]
public static method SphericalToCartesian1 → (1)

spherical in : Vec3D

The spherical coordinates.

returns → Vec3D

The cartesian coordinates.

Converts the given spherical coordinates into cartesian coordinates.

The components of the given vector have the following semantic:

spherical.X := radius (distance to origin).
spherical.Y := azimuthal angle (angle from positive X-axis in radians) in the range [-PI..PI].
spherical.Z := polar angle (angle from positive Z-axis in radians) in the range [0..PI].

[Pure]
public static method SphericalToCartesian2 → (3)

in : float64

The spherical X-coordinate.

in : float64

The spherical Y-coordinate.

in : float64

The spherical Z-coordinate.

returns → Vec3D

The cartesian coordinates.

Converts the given spherical coordinates into cartesian coordinates.

The components of the given vector have the following semantic:

spherical.X := radius (distance to origin).
spherical.Y := azimuthal angle (angle from positive X-axis in radians) in the range [-PI..PI].
spherical.Z := polar angle (angle from positive Z-axis in radians) in the range [0..PI].

Winding

2 overloads


[Pure]
public static method Winding1 → (3)

in : Vec2D

Start of first line segment.

in : Vec2D

End of first line segment, start of second line segment.

in : Vec2D

End of second line segment.

returns → int32

The winding (see remarks).

Returns the winding at the joint of two connected line segments.

The winding is defined as the sign of the Z-component of the cross product between b-a and c-b. The Z-components of a, b and c are assumed to be 0. A winding of zero means that all three points lie on the same line (i.e. the input vectors of the cross product are collinear). For a standard Cartesian coordinate system (X-axis points to the right, Y-axis points upwards), clockwise is negative and counter-clockwise is positive.


[Pure]
public static method Winding2 → (6)

ax in : float64

X-coordinate of start of first line segment.

ay in : float64

Y-coordinate of start of first line segment.

bx in : float64

X-coordinate of end of first line segment, start of second line segment.

by in : float64

Y-coordinate of end of first line segment, start of second line segment.

cx in : float64

X-coordinate of end of second line segment.

cy in : float64

Y-coordinate of end of second line segment.

returns → int32

The winding (see remarks).

Returns the winding at the joint of two connected line segments.

The winding is defined as the sign of the Z-component of the cross product between b-a and c-b. The Z-components of a, b and c are assumed to be 0. A winding of zero means that all three points lie on the same line (i.e. the input vectors of the cross product are collinear). For a standard Cartesian coordinate system (X-axis points to the right, Y-axis points upwards), clockwise is negative and counter-clockwise is positive.