Skip to content

DiGi.ComputeSharp.Planar.Classes

github-actions[bot] edited this page Jul 15, 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 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 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.

Line2IntersectComputeShader Struct

public readonly struct Line2IntersectComputeShader : ComputeSharp.IComputeShader, ComputeSharp.Descriptors.IComputeShaderDescriptor<DiGi.ComputeSharp.Planar.Classes.Line2IntersectComputeShader>

Implements ComputeSharp.IComputeShader, ComputeSharp.Descriptors.IComputeShaderDescriptor<Line2IntersectComputeShader>

Constructors

Line2IntersectComputeShader(GraphicsDevice, IEnumerable<Line2>, IEnumerable<Triangle2>, bool, bool) Constructor

Initializes a new instance of the Line2IntersectComputeShader struct.

public Line2IntersectComputeShader(ComputeSharp.GraphicsDevice graphicsDevice, System.Collections.Generic.IEnumerable<DiGi.ComputeSharp.Planar.Classes.Line2> lines, System.Collections.Generic.IEnumerable<DiGi.ComputeSharp.Planar.Classes.Triangle2> triangles, bool includeStart, bool includeEnd);

Parameters

graphicsDevice ComputeSharp.GraphicsDevice

The graphics device to use for allocating resources.

lines System.Collections.Generic.IEnumerable<Line2>

The collection of 2D lines to check for intersections.

triangles System.Collections.Generic.IEnumerable<Triangle2>

The collection of 2D triangles to test against.

includeStart System.Boolean

A value indicating whether to include the start point of each line in the intersection tests.

includeEnd System.Boolean

A value indicating whether to include the end point of each line in the intersection tests.

Line2IntersectComputeShader(GraphicsDevice, IEnumerable<Line2>, IEnumerable<Triangle2>, bool, bool, double) Constructor

Initializes a new instance of the Line2IntersectComputeShader struct with a custom tolerance.

public Line2IntersectComputeShader(ComputeSharp.GraphicsDevice graphicsDevice, System.Collections.Generic.IEnumerable<DiGi.ComputeSharp.Planar.Classes.Line2> lines, System.Collections.Generic.IEnumerable<DiGi.ComputeSharp.Planar.Classes.Triangle2> triangles, bool includeStart, bool includeEnd, double tolerance);

Parameters

graphicsDevice ComputeSharp.GraphicsDevice

The graphics device to use for allocating resources.

lines System.Collections.Generic.IEnumerable<Line2>

The collection of 2D lines to check for intersections.

triangles System.Collections.Generic.IEnumerable<Triangle2>

The collection of 2D triangles to test against.

includeStart System.Boolean

A value indicating whether to include the start point of each line in the intersection tests.

includeEnd System.Boolean

A value indicating whether to include the end point of each line in the intersection tests.

tolerance System.Double

The tolerance value used for geometric comparison.

Line2IntersectComputeShader(ReadOnlyBuffer<Line2>, ReadOnlyBuffer<Triangle2>, ReadWriteBuffer<int>, bool, bool) Constructor

Initializes a new instance of the Line2IntersectComputeShader struct using pre-allocated buffers.

public Line2IntersectComputeShader(ComputeSharp.ReadOnlyBuffer<DiGi.ComputeSharp.Planar.Classes.Line2> lines, ComputeSharp.ReadOnlyBuffer<DiGi.ComputeSharp.Planar.Classes.Triangle2> triangles, ComputeSharp.ReadWriteBuffer<int> result, bool includeStart, bool includeEnd);

Parameters

lines ComputeSharp.ReadOnlyBuffer<Line2>

The read-only buffer of 2D lines.

triangles ComputeSharp.ReadOnlyBuffer<Triangle2>

The read-only buffer of 2D triangles.

result ComputeSharp.ReadWriteBuffer<System.Int32>

The read-write buffer for storing the intersection results.

includeStart System.Boolean

A value indicating whether to include the start point of each line in the intersection tests.

includeEnd System.Boolean

A value indicating whether to include the end point of each line in the intersection tests.

Line2IntersectComputeShader(ReadOnlyBuffer<Line2>, ReadOnlyBuffer<Triangle2>, ReadWriteBuffer<int>, double, bool, bool) Constructor

Initializes a new instance of the Line2IntersectComputeShader struct using pre-allocated buffers and a custom tolerance.

public Line2IntersectComputeShader(ComputeSharp.ReadOnlyBuffer<DiGi.ComputeSharp.Planar.Classes.Line2> lines, ComputeSharp.ReadOnlyBuffer<DiGi.ComputeSharp.Planar.Classes.Triangle2> triangles, ComputeSharp.ReadWriteBuffer<int> result, double tolerance, bool includeStart, bool includeEnd);

Parameters

lines ComputeSharp.ReadOnlyBuffer<Line2>

The read-only buffer of 2D lines.

triangles ComputeSharp.ReadOnlyBuffer<Triangle2>

The read-only buffer of 2D triangles.

result ComputeSharp.ReadWriteBuffer<System.Int32>

The read-write buffer for storing the intersection results.

tolerance System.Double

The tolerance value used for geometric comparison.

includeStart System.Boolean

A value indicating whether to include the start point of each line in the intersection tests.

includeEnd System.Boolean

A value indicating whether to include the end point of each line in the intersection tests.

Fields

Line2IntersectComputeShader.Result Field

Gets the writeable buffer containing the index of the first intersecting triangle for each line, or -1 if no intersection is found.

public readonly ReadWriteBuffer<int> Result;

Field Value

ComputeSharp.ReadWriteBuffer<System.Int32>

Line2Intersection Struct

Represents the result of an intersection operation in 2D space, which can be a single point, two points, or a line segment.

public readonly struct Line2Intersection : DiGi.ComputeSharp.Planar.Interfaces.IIntersection2, DiGi.ComputeSharp.Core.Interfaces.IIntersection, DiGi.ComputeSharp.Core.Interfaces.IResult

Implements IIntersection2, IIntersection, IResult

Constructors

Line2Intersection() Constructor

Initializes a new instance of the Line2Intersection struct with default values.

public Line2Intersection();

Line2Intersection(Bool, Coordinate2) Constructor

Initializes a new instance of the Line2Intersection struct with specified solidity and the first point.

public Line2Intersection(DiGi.ComputeSharp.Core.Classes.Bool solid, DiGi.ComputeSharp.Planar.Classes.Coordinate2 point_1);

Parameters

solid Bool

The solidity flag for the intersection.

point_1 Coordinate2

The first coordinate point.

Line2Intersection(Bool, Coordinate2, Coordinate2) Constructor

Initializes a new instance of the Line2Intersection struct with specified solidity and two coordinate points.

public Line2Intersection(DiGi.ComputeSharp.Core.Classes.Bool solid, DiGi.ComputeSharp.Planar.Classes.Coordinate2 point_1, DiGi.ComputeSharp.Planar.Classes.Coordinate2 point_2);

Parameters

solid Bool

The solidity flag for the intersection.

point_1 Coordinate2

The first coordinate point.

point_2 Coordinate2

The second coordinate point.

Line2Intersection(Coordinate2) Constructor

Initializes a new instance of the Line2Intersection struct with the first point.

public Line2Intersection(DiGi.ComputeSharp.Planar.Classes.Coordinate2 point_1);

Parameters

point_1 Coordinate2

The first coordinate point.

Line2Intersection(Coordinate2, Coordinate2) Constructor

Initializes a new instance of the Line2Intersection struct with two coordinate points.

public Line2Intersection(DiGi.ComputeSharp.Planar.Classes.Coordinate2 point_1, DiGi.ComputeSharp.Planar.Classes.Coordinate2 point_2);

Parameters

point_1 Coordinate2

The first coordinate point.

point_2 Coordinate2

The second coordinate point.

Line2Intersection(Line2) Constructor

Initializes a new instance of the Line2Intersection struct from an existing line.

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

Parameters

line Line2

The line to use for initialization.

Fields

Line2Intersection.Point_1 Field

The first coordinate point of the intersection.

public readonly Coordinate2 Point_1;

Field Value

Coordinate2

Line2Intersection.Point_2 Field

The second coordinate point of the intersection, used when the result is a line segment.

public readonly Coordinate2 Point_2;

Field Value

Coordinate2

Line2Intersection.Solid Field

Indicates whether the intersection result is a solid line segment rather than discrete points.

public readonly Bool Solid;

Field Value

Bool

Methods

Line2Intersection.GetIntersectionGeometries(Nullable<bool>) Method

Retrieves the geometries resulting from the intersection, optionally overriding the solidity of the result.

public DiGi.ComputeSharp.Planar.Interfaces.IGeometry2[]? GetIntersectionGeometries(System.Nullable<bool> solid=null);

Parameters

solid System.Nullable<System.Boolean>

An optional override for whether the result should be treated as a solid geometry.

Implements GetIntersectionGeometries(Nullable<bool>)

Returns

IGeometry2[]
An array of IGeometry2 objects representing the intersection, or null if the primary point is NaN.

Line2Intersection.GetLine() Method

Converts the intersection result into a line segment if it is marked as solid and contains valid points.

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

Returns

Line2
A Line2 representing the intersection line, or an empty line if not applicable.

Line2Intersection.IsNaN() Method

Determines whether the intersection result is Not-a-Number (NaN).

public bool IsNaN();

Returns

System.Boolean
True if the first point is NaN; otherwise, false.

Line2IntersectionComputeShader Struct

public readonly struct Line2IntersectionComputeShader : ComputeSharp.IComputeShader, ComputeSharp.Descriptors.IComputeShaderDescriptor<DiGi.ComputeSharp.Planar.Classes.Line2IntersectionComputeShader>

Implements ComputeSharp.IComputeShader, ComputeSharp.Descriptors.IComputeShaderDescriptor<Line2IntersectionComputeShader>

Constructors

Line2IntersectionComputeShader(GraphicsDevice, Line2, IEnumerable<Line2>) Constructor

Initializes a new instance of the Line2IntersectionComputeShader struct.

public Line2IntersectionComputeShader(ComputeSharp.GraphicsDevice graphicsDevice, DiGi.ComputeSharp.Planar.Classes.Line2 line, System.Collections.Generic.IEnumerable<DiGi.ComputeSharp.Planar.Classes.Line2> lines);

Parameters

graphicsDevice ComputeSharp.GraphicsDevice

The graphics device to use for allocating resources.

line Line2

The primary 2D line to intersect with other lines.

lines System.Collections.Generic.IEnumerable<Line2>

The collection of 2D lines to check against the primary line.

Line2IntersectionComputeShader(GraphicsDevice, Line2, IEnumerable<Line2>, double) Constructor

Initializes a new instance of the Line2IntersectionComputeShader struct with a custom tolerance.

public Line2IntersectionComputeShader(ComputeSharp.GraphicsDevice graphicsDevice, DiGi.ComputeSharp.Planar.Classes.Line2 line, System.Collections.Generic.IEnumerable<DiGi.ComputeSharp.Planar.Classes.Line2> lines, double tolerance);

Parameters

graphicsDevice ComputeSharp.GraphicsDevice

The graphics device to use for allocating resources.

line Line2

The primary 2D line to intersect with other lines.

lines System.Collections.Generic.IEnumerable<Line2>

The collection of 2D lines to check against the primary line.

tolerance System.Double

The tolerance value used for geometric comparison.

Line2IntersectionComputeShader(Line2, ReadOnlyBuffer<Line2>, ReadWriteBuffer<Line2Intersection>) Constructor

Initializes a new instance of the Line2IntersectionComputeShader struct using pre-allocated buffers.

public Line2IntersectionComputeShader(DiGi.ComputeSharp.Planar.Classes.Line2 line, ComputeSharp.ReadOnlyBuffer<DiGi.ComputeSharp.Planar.Classes.Line2> lines, ComputeSharp.ReadWriteBuffer<DiGi.ComputeSharp.Planar.Classes.Line2Intersection> lineIntersections);

Parameters

line Line2

The primary 2D line to intersect with other lines.

lines ComputeSharp.ReadOnlyBuffer<Line2>

The read-only buffer of 2D lines to check against.

lineIntersections ComputeSharp.ReadWriteBuffer<Line2Intersection>

The read-write buffer for storing the intersection results.

Line2IntersectionComputeShader(Line2, ReadOnlyBuffer<Line2>, ReadWriteBuffer<Line2Intersection>, double) Constructor

Initializes a new instance of the Line2IntersectionComputeShader struct using pre-allocated buffers and a custom tolerance.

public Line2IntersectionComputeShader(DiGi.ComputeSharp.Planar.Classes.Line2 line, ComputeSharp.ReadOnlyBuffer<DiGi.ComputeSharp.Planar.Classes.Line2> lines, ComputeSharp.ReadWriteBuffer<DiGi.ComputeSharp.Planar.Classes.Line2Intersection> lineIntersections, double tolerance);

Parameters

line Line2

The primary 2D line to intersect with other lines.

lines ComputeSharp.ReadOnlyBuffer<Line2>

The read-only buffer of 2D lines to check against.

lineIntersections ComputeSharp.ReadWriteBuffer<Line2Intersection>

The read-write buffer for storing the intersection results.

tolerance System.Double

The tolerance value used for geometric comparison.

Fields

Line2IntersectionComputeShader.LineIntersections Field

Gets the writeable buffer containing the line intersection results.

public readonly ReadWriteBuffer<Line2Intersection> LineIntersections;

Field Value

ComputeSharp.ReadWriteBuffer<Line2Intersection>

Methods

Line2IntersectionComputeShader.Execute() Method

Executes the compute shader operation over the designated range of threads.

public void Execute();

Implements Execute()

Line2IntersectionsComputeShader Struct

public readonly struct Line2IntersectionsComputeShader : ComputeSharp.IComputeShader, ComputeSharp.Descriptors.IComputeShaderDescriptor<DiGi.ComputeSharp.Planar.Classes.Line2IntersectionsComputeShader>

Implements ComputeSharp.IComputeShader, ComputeSharp.Descriptors.IComputeShaderDescriptor<Line2IntersectionsComputeShader>

Constructors

Line2IntersectionsComputeShader(ReadOnlyBuffer<Line2>, ReadOnlyBuffer<Triangle2>, ReadWriteBuffer<Line2Intersection>) Constructor

Initializes a new instance of the Line2IntersectionsComputeShader struct.

public Line2IntersectionsComputeShader(ComputeSharp.ReadOnlyBuffer<DiGi.ComputeSharp.Planar.Classes.Line2> lines, ComputeSharp.ReadOnlyBuffer<DiGi.ComputeSharp.Planar.Classes.Triangle2> triangles, ComputeSharp.ReadWriteBuffer<DiGi.ComputeSharp.Planar.Classes.Line2Intersection> lineIntersections);

Parameters

lines ComputeSharp.ReadOnlyBuffer<Line2>

The read-only buffer of 2D lines.

triangles ComputeSharp.ReadOnlyBuffer<Triangle2>

The read-only buffer of 2D triangles.

lineIntersections ComputeSharp.ReadWriteBuffer<Line2Intersection>

The read-write buffer for storing the intersection results.

Line2IntersectionsComputeShader(ReadOnlyBuffer<Line2>, ReadOnlyBuffer<Triangle2>, ReadWriteBuffer<Line2Intersection>, double) Constructor

Initializes a new instance of the Line2IntersectionsComputeShader struct with a custom tolerance.

public Line2IntersectionsComputeShader(ComputeSharp.ReadOnlyBuffer<DiGi.ComputeSharp.Planar.Classes.Line2> lines, ComputeSharp.ReadOnlyBuffer<DiGi.ComputeSharp.Planar.Classes.Triangle2> triangles, ComputeSharp.ReadWriteBuffer<DiGi.ComputeSharp.Planar.Classes.Line2Intersection> lineIntersections, double tolerance);

Parameters

lines ComputeSharp.ReadOnlyBuffer<Line2>

The read-only buffer of 2D lines.

triangles ComputeSharp.ReadOnlyBuffer<Triangle2>

The read-only buffer of 2D triangles.

lineIntersections ComputeSharp.ReadWriteBuffer<Line2Intersection>

The read-write buffer for storing the intersection results.

tolerance System.Double

The tolerance value used for geometric comparison.

Fields

Line2IntersectionsComputeShader.LineIntersections Field

Gets the writeable buffer containing the line-to-triangle intersection results.

public readonly ReadWriteBuffer<Line2Intersection> LineIntersections;

Field Value

ComputeSharp.ReadWriteBuffer<Line2Intersection>

Methods

Line2IntersectionsComputeShader.Execute() Method

Executes the compute shader operation over the designated range of threads.

public void Execute();

Implements Execute()

Triangle2 Struct

Represents a two-dimensional triangle in a planar coordinate system.

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

Implements IGeometry2, IGeometry

Constructors

Triangle2() Constructor

Initializes a new instance of the Triangle2 struct with default values (NaN coordinates and not solid).

public Triangle2();

Triangle2(Bool, Coordinate2, Coordinate2, Coordinate2) Constructor

Initializes a new instance of the Triangle2 struct with the specified solid state and vertices.

public Triangle2(DiGi.ComputeSharp.Core.Classes.Bool solid, DiGi.ComputeSharp.Planar.Classes.Coordinate2 point_1, DiGi.ComputeSharp.Planar.Classes.Coordinate2 point_2, DiGi.ComputeSharp.Planar.Classes.Coordinate2 point_3);

Parameters

solid Bool

A value indicating whether the triangle is solid.

point_1 Coordinate2

The first vertex.

point_2 Coordinate2

The second vertex.

point_3 Coordinate2

The third vertex.

Fields

Triangle2.Point_1 Field

The first vertex of the triangle.

public readonly Coordinate2 Point_1;

Field Value

Coordinate2

Triangle2.Point_2 Field

The second vertex of the triangle.

public readonly Coordinate2 Point_2;

Field Value

Coordinate2

Triangle2.Point_3 Field

The third vertex of the triangle.

public readonly Coordinate2 Point_3;

Field Value

Coordinate2

Triangle2.Solid Field

A value indicating whether the triangle is solid (filled) or boundary-only.

public readonly Bool Solid;

Field Value

Bool

Methods

Triangle2.GetApproximatePerimeter() Method

Calculates the approximate perimeter of the triangle using fast distance calculations.

public double GetApproximatePerimeter();

Returns

System.Double
The approximate perimeter of the triangle.

Triangle2.GetArea() Method

Calculates the signed area of the triangle.

public double GetArea();

Returns

System.Double
The area of the triangle.

Triangle2.GetCentroid() Method

Gets the centroid (geometric center) of the triangle.

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

Returns

Coordinate2
A Coordinate2 representing the centroid of the triangle.

Triangle2.GetInversed() Method

Gets a new triangle with inverted vertex order (reversing winding direction).

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

Returns

Triangle2
An inverted Triangle2.

Triangle2.GetLine(int) Method

Gets one of the boundary lines of the triangle by index.

public DiGi.ComputeSharp.Planar.Classes.Line2 GetLine(int index);

Parameters

index System.Int32

The line index (0, 1, or 2).

Returns

Line2
The boundary Line2 at the specified index.

Triangle2.GetLines() Method

Gets all boundary lines of the triangle.

public DiGi.ComputeSharp.Planar.Classes.Line2[] GetLines();

Returns

Line2[]
An array of three Line2 objects representing the boundary lines.

Triangle2.GetMax() Method

Gets the maximum coordinate bounds of the triangle.

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

Returns

Coordinate2
A Coordinate2 representing the maximum X and Y coordinates.

Triangle2.GetMin() Method

Gets the minimum coordinate bounds of the triangle.

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

Returns

Coordinate2
A Coordinate2 representing the minimum X and Y coordinates.

Triangle2.GetMoved(Coordinate2) Method

Translates the triangle by the specified offset vector.

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

Parameters

vector Coordinate2

The translation vector.

Returns

Triangle2
A translated Triangle2.

Triangle2.GetPerimeter(double) Method

Calculates the perimeter of the triangle with the specified tolerance.

public double GetPerimeter(double tolerance);

Parameters

tolerance System.Double

The tolerance used for distance calculations.

Returns

System.Double
The perimeter of the triangle.

Triangle2.InRange(Coordinate2, double) Method

Checks if a point is within the bounding range of the triangle.

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

Parameters

point Coordinate2

The point to check.

tolerance System.Double

The distance tolerance.

Returns

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

Triangle2.InRange(Line2, double) Method

Checks if a line is within the bounding range of the triangle.

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

Parameters

line Line2

The line to check.

tolerance System.Double

The distance tolerance.

Returns

System.Boolean
True if the line is within range; otherwise, false.

Triangle2.InRange(Triangle2, double) Method

Checks if another triangle is within the bounding range of this triangle.

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

Parameters

triangle Triangle2

The other triangle to check.

tolerance System.Double

The distance tolerance.

Returns

System.Boolean
True if the triangles' bounding boxes overlap; otherwise, false.

Triangle2.Inside(Coordinate2, double) Method

Determines whether a point lies inside the triangle using barycentric coordinates.

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

Parameters

point Coordinate2

The point to test.

tolerance System.Double

The numerical tolerance value.

Returns

System.Boolean
True if the point lies inside or on the boundary of the triangle; otherwise, false.

Triangle2.IsNaN() Method

Checks if any of the triangle's vertices contain NaN coordinates.

public bool IsNaN();

Returns

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

Triangle2.On(Coordinate2, double) Method

Determines whether a point lies on the triangle (inside if solid, or on boundary lines if not).

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

Parameters

point Coordinate2

The point to test.

tolerance System.Double

The tolerance value.

Returns

System.Boolean
True if the point lies on the triangle; otherwise, false.

Triangle2.ToString() Method

Returns a string representation of the current triangle.

public override string ToString();

Returns

System.String
A formatted string describing the triangle vertices.

Clone this wiki locally