Skip to content

DiGi.ComputeSharp.Planar.Classes

github-actions[bot] edited this page Jul 1, 2026 · 3 revisions

DiGi.ComputeSharp.Planar.Classes Namespace

Structs

Coordinate2 Struct

Represents a two-dimensional coordinate or vector in a planar system.

public readonly struct Coordinate2 : DiGi.ComputeSharp.Planar.Interfaces.IGeometry2, DiGi.ComputeSharp.Core.Interfaces.IGeometry

Implements IGeometry2, IGeometry

Constructors

Coordinate2() Constructor

Initializes a new instance of the Coordinate2 struct with NaN values.

public Coordinate2();

Coordinate2(Coordinate2) Constructor

Initializes a new instance of the Coordinate2 struct by copying an existing coordinate.

public Coordinate2(DiGi.ComputeSharp.Planar.Classes.Coordinate2 coordinate);

Parameters

coordinate Coordinate2

The source coordinate to copy.

Coordinate2(Coordinate2, Coordinate2) Constructor

Initializes a new instance of the Coordinate2 struct as a vector representing the difference between two points.

public Coordinate2(DiGi.ComputeSharp.Planar.Classes.Coordinate2 start, DiGi.ComputeSharp.Planar.Classes.Coordinate2 end);

Parameters

start Coordinate2

The starting point.

end Coordinate2

The ending point.

Coordinate2(double, double) Constructor

Initializes a new instance of the Coordinate2 struct with specified X and Y coordinates.

public Coordinate2(double x, double y);

Parameters

x System.Double

The X-coordinate.

y System.Double

The Y-coordinate.

Fields

Coordinate2.X Field

The X-coordinate of the point or the X-component of the vector.

public readonly double X;

Field Value

System.Double

Coordinate2.Y Field

The Y-coordinate of the point or the Y-component of the vector.

public readonly double Y;

Field Value

System.Double

Methods

Coordinate2.Add(Coordinate2) Method

Performs vector addition of this coordinate and another coordinate.

public DiGi.ComputeSharp.Planar.Classes.Coordinate2 Add(DiGi.ComputeSharp.Planar.Classes.Coordinate2 coordinate);

Parameters

coordinate Coordinate2

The coordinate to add.

Returns

Coordinate2
A new Coordinate2 representing the sum.

Coordinate2.AlmostEquals(Coordinate2, double) Method

Determines whether this coordinate is approximately equal to another coordinate within a specified tolerance.

public bool AlmostEquals(DiGi.ComputeSharp.Planar.Classes.Coordinate2 coordinate, double tolerance);

Parameters

coordinate Coordinate2

The coordinate to compare.

tolerance System.Double

The maximum allowed difference between coordinates.

Returns

System.Boolean
True if the coordinates are within the tolerance; otherwise, false.

Coordinate2.CrossProduct(Coordinate2) Method

Calculates the 2D cross product of this vector and another vector.

public double CrossProduct(DiGi.ComputeSharp.Planar.Classes.Coordinate2 vector);

Parameters

vector Coordinate2

The other vector.

Returns

System.Double
The scalar result of the 2D cross product.

Coordinate2.Divide(Coordinate2) Method

Performs component-wise division of this coordinate by another coordinate.

public DiGi.ComputeSharp.Planar.Classes.Coordinate2 Divide(DiGi.ComputeSharp.Planar.Classes.Coordinate2 coordinate);

Parameters

coordinate Coordinate2

The divisor coordinate.

Returns

Coordinate2
A new Coordinate2 representing the result of the division.

Coordinate2.Divide(double) Method

Divides this coordinate by a scalar factor.

public DiGi.ComputeSharp.Planar.Classes.Coordinate2 Divide(double factor);

Parameters

factor System.Double

The divisor value.

Returns

Coordinate2
A new Coordinate2 representing the result of the division.

Coordinate2.DotProduct(Coordinate2) Method

Calculates the dot product of this vector and another vector.

public double DotProduct(DiGi.ComputeSharp.Planar.Classes.Coordinate2 vector);

Parameters

vector Coordinate2

The other vector.

Returns

System.Double
The scalar result of the dot product.

Coordinate2.Equals(Coordinate2) Method

Determines whether this coordinate is equal to another coordinate based on exact values.

public bool Equals(DiGi.ComputeSharp.Planar.Classes.Coordinate2 coordinate);

Parameters

coordinate Coordinate2

The coordinate to compare.

Returns

System.Boolean
True if the coordinates are identical or both are NaN; otherwise, false.

Coordinate2.Equals(object) Method

Determines whether this instance is equal to a specified object.

public override bool Equals(object? obj);

Parameters

obj System.Object

The object to compare with the current instance.

Returns

System.Boolean
True if the object is a Coordinate2 and has identical values; otherwise, false.

Coordinate2.GetApproximateDistance(Coordinate2) Method

Calculates an approximate distance between this point and another point using a fast approximation formula.

public double GetApproximateDistance(DiGi.ComputeSharp.Planar.Classes.Coordinate2 point);

Parameters

point Coordinate2

The target point.

Returns

System.Double
An approximated Euclidean distance.

Coordinate2.GetApproximateLength() Method

Calculates the approximate length of this vector from the origin (0,0).

public double GetApproximateLength();

Returns

System.Double
An approximated magnitude of the vector.

Coordinate2.GetCentroid() Method

Calculates the centroid (midpoint) between this coordinate and the origin.

public DiGi.ComputeSharp.Planar.Classes.Coordinate2 GetCentroid();

Returns

Coordinate2
A new Coordinate2 representing the midpoint.

Coordinate2.GetCentroid(Coordinate2) Method

Calculates the centroid (midpoint) between this coordinate and another point.

public DiGi.ComputeSharp.Planar.Classes.Coordinate2 GetCentroid(DiGi.ComputeSharp.Planar.Classes.Coordinate2 point);

Parameters

point Coordinate2

The other point.

Returns

Coordinate2
A new Coordinate2 representing the midpoint.

Coordinate2.GetDistance(Coordinate2, double) Method

Calculates the Euclidean distance between this coordinate and another point.

public double GetDistance(DiGi.ComputeSharp.Planar.Classes.Coordinate2 point, double tolerance);

Parameters

point Coordinate2

The target point.

tolerance System.Double

Tolerance used for the square root calculation.

Returns

System.Double
The distance between the two points.

Coordinate2.GetHashCode() Method

Returns a hash code for the current coordinate.

public override int GetHashCode();

Returns

System.Int32
An integer hash code representing the coordinate's value.

Coordinate2.GetInversed() Method

Returns a coordinate with inverted X and Y values.

public DiGi.ComputeSharp.Planar.Classes.Coordinate2 GetInversed();

Returns

Coordinate2
A new Coordinate2 representing the inverse vector.

Coordinate2.GetLength(double) Method

Calculates the magnitude (length) of this vector.

public double GetLength(double tolerance);

Parameters

tolerance System.Double

Tolerance used for the square root calculation.

Returns

System.Double
The length of the vector.

Coordinate2.GetMoved(Coordinate2) Method

Translates this coordinate by a given vector.

public DiGi.ComputeSharp.Planar.Classes.Coordinate2 GetMoved(DiGi.ComputeSharp.Planar.Classes.Coordinate2 vector);

Parameters

vector Coordinate2

The translation vector.

Returns

Coordinate2
A new Coordinate2 representing the moved position.

Coordinate2.GetNormalized(double) Method

Returns a unit vector in the same direction as this coordinate.

public DiGi.ComputeSharp.Planar.Classes.Coordinate2 GetNormalized(double tolerance);

Parameters

tolerance System.Double

Tolerance used for length calculation.

Returns

Coordinate2
A normalized Coordinate2 with a magnitude of 1.

Coordinate2.GetSquaredDistance(Coordinate2) Method

Calculates the squared Euclidean distance between this coordinate and another.

public double GetSquaredDistance(DiGi.ComputeSharp.Planar.Classes.Coordinate2 coordinate);

Parameters

coordinate Coordinate2

The target coordinate.

Returns

System.Double
The squared distance value.

Coordinate2.GetSquaredLength() Method

Calculates the squared length of the coordinate vector (X*X + Y*Y).

public double GetSquaredLength();

Returns

System.Double
The sum of the squares of the X and Y components.

Coordinate2.InRange(Line2, double) Method

Checks if this point is within the range of the specified line's bounding box expanded by a tolerance.

public bool InRange(DiGi.ComputeSharp.Planar.Classes.Line2 line, double tolerance);

Parameters

line Line2

The line to check against.

tolerance System.Double

The distance used to expand the bounding box.

Returns

System.Boolean
True if the point is within the expanded bounding box; otherwise, false.

Coordinate2.InRange(Triangle2, double) Method

Checks if this point is within the bounding box of the specified triangle expanded by a tolerance.

public bool InRange(DiGi.ComputeSharp.Planar.Classes.Triangle2 triangle, double tolerance);

Parameters

triangle DiGi.ComputeSharp.Planar.Classes.Triangle2

The triangle to check against.

tolerance System.Double

The distance used to expand the bounding box.

Returns

System.Boolean
True if the point is within the expanded bounding box; otherwise, false.

Coordinate2.IsNaN() Method

Determines whether either the X or Y component of this coordinate is Not-a-Number (NaN).

public bool IsNaN();

Returns

System.Boolean
True if X or Y is NaN; otherwise, false.

Coordinate2.Multiply(Coordinate2) Method

Performs a component-wise multiplication of this coordinate with another coordinate.

public DiGi.ComputeSharp.Planar.Classes.Coordinate2 Multiply(DiGi.ComputeSharp.Planar.Classes.Coordinate2 coordinate);

Parameters

coordinate Coordinate2

The coordinate to multiply by.

Returns

Coordinate2
A new Coordinate2 resulting from the component-wise multiplication.

Coordinate2.Multiply(double) Method

Performs scalar multiplication of this coordinate by a specified factor.

public DiGi.ComputeSharp.Planar.Classes.Coordinate2 Multiply(double factor);

Parameters

factor System.Double

The scalar value to multiply by.

Returns

Coordinate2
A new Coordinate2 resulting from the scalar multiplication.

Coordinate2.Project(Coordinate2) Method

Projects the specified coordinate onto this vector.

public DiGi.ComputeSharp.Planar.Classes.Coordinate2 Project(DiGi.ComputeSharp.Planar.Classes.Coordinate2 coordinate);

Parameters

coordinate Coordinate2

The coordinate to project.

Returns

Coordinate2
A new Coordinate2 representing the projection of the given coordinate onto this vector.

Coordinate2.Substract(Coordinate2) Method

Subtracts another coordinate from this coordinate.

public DiGi.ComputeSharp.Planar.Classes.Coordinate2 Substract(DiGi.ComputeSharp.Planar.Classes.Coordinate2 coordinate);

Parameters

coordinate Coordinate2

The coordinate to subtract.

Returns

Coordinate2
A new Coordinate2 representing the result of the subtraction.

Coordinate2.ToString() Method

Returns a string representation of the current coordinate.

public override string ToString();

Returns

System.String
A formatted string containing the X and Y components.

Operators

Coordinate2.operator ==(Coordinate2, Coordinate2) Operator

Determines whether two Coordinate2 objects are equal.

public static bool operator ==(DiGi.ComputeSharp.Planar.Classes.Coordinate2 left, DiGi.ComputeSharp.Planar.Classes.Coordinate2 right);

Parameters

left Coordinate2

The first coordinate to compare.

right Coordinate2

The second coordinate to compare.

Returns

System.Boolean
True if the coordinates are equal; otherwise, false.

Coordinate2.operator !=(Coordinate2, Coordinate2) Operator

Determines whether two Coordinate2 objects are not equal.

public static bool operator !=(DiGi.ComputeSharp.Planar.Classes.Coordinate2 left, DiGi.ComputeSharp.Planar.Classes.Coordinate2 right);

Parameters

left Coordinate2

The first coordinate to compare.

right Coordinate2

The second coordinate to compare.

Returns

System.Boolean
True if the coordinates are not equal; otherwise, false.

Line2 Struct

Represents a 2D line segment or an infinite line in a planar coordinate system.

public readonly struct Line2 : DiGi.ComputeSharp.Planar.Interfaces.IGeometry2, DiGi.ComputeSharp.Core.Interfaces.IGeometry

Implements IGeometry2, IGeometry

Constructors

Line2() Constructor

Initializes a new instance of the Line2 struct with default NaN values and unbounded flag.

public Line2();

Line2(Bool, Coordinate2, Coordinate2) Constructor

Initializes a new instance of the Line2 struct with specified boundedness and coordinate objects.

public Line2(DiGi.ComputeSharp.Core.Classes.Bool bounded, DiGi.ComputeSharp.Planar.Classes.Coordinate2 start, DiGi.ComputeSharp.Planar.Classes.Coordinate2 end);

Parameters

bounded Bool

Whether the line is bounded.

start Coordinate2

The starting coordinate.

end Coordinate2

The ending coordinate.

Line2(Bool, double, double, double, double) Constructor

Initializes a new instance of the Line2 struct with specified boundedness and coordinates.

public Line2(DiGi.ComputeSharp.Core.Classes.Bool bounded, double x_1, double y_1, double x_2, double y_2);

Parameters

bounded Bool

Whether the line is bounded.

x_1 System.Double

The X coordinate of the first point.

y_1 System.Double

The Y coordinate of the first point.

x_2 System.Double

The X coordinate of the second point.

y_2 System.Double

The Y coordinate of the second point.

Line2(Coordinate2, Coordinate2) Constructor

Initializes a new instance of the Line2 struct as a bounded line using start and end coordinates.

public Line2(DiGi.ComputeSharp.Planar.Classes.Coordinate2 start, DiGi.ComputeSharp.Planar.Classes.Coordinate2 end);

Parameters

start Coordinate2

The starting coordinate.

end Coordinate2

The ending coordinate.

Line2(double, double, double, double) Constructor

Initializes a new instance of the Line2 struct as a bounded line using specific coordinates.

public Line2(double x_1, double y_1, double x_2, double y_2);

Parameters

x_1 System.Double

The X coordinate of the first point.

y_1 System.Double

The Y coordinate of the first point.

x_2 System.Double

The X coordinate of the second point.

y_2 System.Double

The Y coordinate of the second point.

Fields

Line2.Bounded Field

Indicates whether the line is bounded (a segment) or unbounded (an infinite line).

public readonly Bool Bounded;

Field Value

Bool

Line2.End Field

The end coordinate of the line.

public readonly Coordinate2 End;

Field Value

Coordinate2

Line2.Start Field

The start coordinate of the line.

public readonly Coordinate2 Start;

Field Value

Coordinate2

Methods

Line2.GetApproximateDistance(Coordinate2) Method

Calculates the approximate distance from a given point to the line.

public double GetApproximateDistance(DiGi.ComputeSharp.Planar.Classes.Coordinate2 point);

Parameters

point Coordinate2

The point to measure distance from.

Returns

System.Double
The approximate distance as a double.

Line2.GetApproximateLength() Method

Calculates the approximate length of the line.

public double GetApproximateLength();

Returns

System.Double
The distance between start and end, or positive infinity if the line is unbounded.

Line2.GetCentroid() Method

Calculates the centroid of the line.

public DiGi.ComputeSharp.Planar.Classes.Coordinate2 GetCentroid();

Returns

Coordinate2
The coordinate representing the center point of the line.

Line2.GetClosestPoint(Coordinate2) Method

Finds the closest point on the line to a specified target point.

public DiGi.ComputeSharp.Planar.Classes.Coordinate2 GetClosestPoint(DiGi.ComputeSharp.Planar.Classes.Coordinate2 point);

Parameters

point Coordinate2

The target point.

Returns

Coordinate2
The coordinate on the line closest to the provided point.

Line2.GetDirection(double) Method

Gets the normalized direction vector of the line.

public DiGi.ComputeSharp.Planar.Classes.Coordinate2 GetDirection(double tolerance);

Parameters

tolerance System.Double

The tolerance used for normalization.

Returns

Coordinate2
A normalized coordinate representing the direction.

Line2.GetInversed() Method

Creates a new line that is the inverse of the current line (swapping start and end points).

public DiGi.ComputeSharp.Planar.Classes.Line2 GetInversed();

Returns

Line2
A new Line2 instance with inverted coordinates.

Line2.GetLength(double) Method

Calculates the actual length of the line using a specified tolerance for the square root operation.

public double GetLength(double tolerance);

Parameters

tolerance System.Double

The precision tolerance.

Returns

System.Double
The length of the line as a double.

Line2.GetMax() Method

Gets the maximum coordinate (top-right corner) of the line's axis-aligned bounding box.

public DiGi.ComputeSharp.Planar.Classes.Coordinate2 GetMax();

Returns

Coordinate2
The maximum X and Y coordinates as a Coordinate2.

Line2.GetMin() Method

Gets the minimum coordinate (bottom-left corner) of the line's axis-aligned bounding box.

public DiGi.ComputeSharp.Planar.Classes.Coordinate2 GetMin();

Returns

Coordinate2
The minimum X and Y coordinates as a Coordinate2.

Line2.GetMoved(Coordinate2) Method

Moves the line by a specified translation vector.

public DiGi.ComputeSharp.Planar.Classes.Line2 GetMoved(DiGi.ComputeSharp.Planar.Classes.Coordinate2 vector);

Parameters

vector Coordinate2

The translation vector.

Returns

Line2
A new Line2 instance shifted by the provided vector.

Line2.GetSquaredDistance(Coordinate2) Method

Calculates the squared distance from a given point to the closest point on the line.

public double GetSquaredDistance(DiGi.ComputeSharp.Planar.Classes.Coordinate2 point);

Parameters

point Coordinate2

The point to measure distance from.

Returns

System.Double
The squared distance as a double.

Line2.GetSquaredLength() Method

Calculates the squared length of the line.

public double GetSquaredLength();

Returns

System.Double
The squared distance between start and end, or positive infinity if the line is unbounded.

Line2.GetVector() Method

Gets the vector representing the direction and magnitude from the start to the end of the line.

public DiGi.ComputeSharp.Planar.Classes.Coordinate2 GetVector();

Returns

Coordinate2
A Coordinate2 representing the direction and magnitude of the line.

Line2.InRange(Coordinate2, double) Method

Determines whether a given point is within the range of this line's bounding box.

public bool InRange(DiGi.ComputeSharp.Planar.Classes.Coordinate2 point, double tolerance);

Parameters

point Coordinate2

The point to check.

tolerance System.Double

The overlap tolerance.

Returns

System.Boolean
True if the point is in range; otherwise, false.

Line2.InRange(Line2, double) Method

Determines whether this line's bounding box overlaps with another line's bounding box within a given tolerance.

public bool InRange(DiGi.ComputeSharp.Planar.Classes.Line2 line, double tolerance);

Parameters

line Line2

The other line to check.

tolerance System.Double

The overlap tolerance.

Returns

System.Boolean
True if the lines are in range; otherwise, false.

Line2.InRange(Triangle2, double) Method

Determines whether this line's bounding box overlaps with a triangle's bounding box within a given tolerance.

public bool InRange(DiGi.ComputeSharp.Planar.Classes.Triangle2 triangle, double tolerance);

Parameters

triangle DiGi.ComputeSharp.Planar.Classes.Triangle2

The triangle to check.

tolerance System.Double

The overlap tolerance.

Returns

System.Boolean
True if the line and triangle are in range; otherwise, false.

Line2.IsNaN() Method

Checks if either the start or end coordinates of the line are Not-a-Number (NaN).

public bool IsNaN();

Returns

System.Boolean
True if any coordinate is NaN; otherwise, false.

Line2.On(Coordinate2, double) Method

Determines whether a point lies on the line within a specified squared distance tolerance.

public bool On(DiGi.ComputeSharp.Planar.Classes.Coordinate2 point, double tolerance);

Parameters

point Coordinate2

The point to check.

tolerance System.Double

The squared distance tolerance.

Returns

System.Boolean
True if the point is on the line; otherwise, false.

Line2.Project(Coordinate2) Method

Projects a given point onto the line, returning the closest point on the line.

public DiGi.ComputeSharp.Planar.Classes.Coordinate2 Project(DiGi.ComputeSharp.Planar.Classes.Coordinate2 point);

Parameters

point Coordinate2

The point to project.

Returns

Coordinate2
The closest Coordinate2 on this line to the given point.

Line2.Project(Line2) Method

Projects another line onto this line by finding the closest points for the start and end of the given line.

public DiGi.ComputeSharp.Planar.Classes.Line2 Project(DiGi.ComputeSharp.Planar.Classes.Line2 line);

Parameters

line Line2

The line to project onto this line.

Returns

Line2
A new Line2 representing the projected line, or a default Line2 if the projection collapses to a point.

Line2.ToString() Method

Returns a string representation of the line showing start and end coordinates.

public override string ToString();

Returns

System.String
A formatted string containing the start and end coordinates.

Clone this wiki locally