Skip to content

DiGi.ComputeSharp.Planar

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

DiGi.ComputeSharp.Planar Namespace

Classes

Create Class

public static class Create

Inheritance System.Object → Create

Methods

Create.Line2Intersection(Line2, Line2, double) Method

Calculates the intersection of two 2D lines within a specified tolerance.

public static DiGi.ComputeSharp.Planar.Classes.Line2Intersection Line2Intersection(DiGi.ComputeSharp.Planar.Classes.Line2 line_1, DiGi.ComputeSharp.Planar.Classes.Line2 line_2, double tolerance);

Parameters

line_1 Line2

The first 2D line.

line_2 Line2

The second 2D line.

tolerance System.Double

The numerical tolerance used for geometric comparisons and proximity checks.

Returns

Line2Intersection
A Line2Intersection object containing the intersection result, which may be empty, a single point, or a line segment in the case of coincident lines.

Create.Line2Intersection(Line2, Triangle2, double) Method

Calculates the intersection between a line and a triangle in 2D space based on a specified tolerance.

public static DiGi.ComputeSharp.Planar.Classes.Line2Intersection Line2Intersection(DiGi.ComputeSharp.Planar.Classes.Line2 line, DiGi.ComputeSharp.Planar.Classes.Triangle2 triangle, double tolerance);

Parameters

line Line2

The line to test for intersection.

triangle Triangle2

The triangle to test for intersection.

tolerance System.Double

The tolerance value used for floating-point comparisons and proximity checks.

Returns

Line2Intersection
A Line2Intersection object representing the intersection result (e.g., a point, a line segment, or no intersection).

Create.Line2Intersections(Line2, IEnumerable<Line2>, double) Method

Calculates the intersections between a specified line and a collection of other lines using GPU acceleration.

public static System.Collections.Generic.IEnumerable<DiGi.ComputeSharp.Planar.Classes.Line2Intersection>? Line2Intersections(DiGi.ComputeSharp.Planar.Classes.Line2 line, System.Collections.Generic.IEnumerable<DiGi.ComputeSharp.Planar.Classes.Line2>? lines, double tolerance);

Parameters

line Line2

The primary line to check for intersections.

lines System.Collections.Generic.IEnumerable<Line2>

The collection of lines to test against the primary line.

tolerance System.Double

The distance tolerance used to determine if two lines are intersecting.

Returns

System.Collections.Generic.IEnumerable<Line2Intersection>
A collection of Line2Intersection results, or null if the input line is invalid, the lines collection is empty/null, or the graphics device is unavailable.

Create.Line2Intersections(IEnumerable<Line2>, IEnumerable<Triangle2>, double) Method

Calculates the intersections between a collection of lines and a collection of triangles using GPU acceleration.

public static System.Collections.Generic.IEnumerable<DiGi.ComputeSharp.Planar.Classes.Line2Intersection>? Line2Intersections(System.Collections.Generic.IEnumerable<DiGi.ComputeSharp.Planar.Classes.Line2>? lines, System.Collections.Generic.IEnumerable<DiGi.ComputeSharp.Planar.Classes.Triangle2>? triangles, double tolerance);

Parameters

lines System.Collections.Generic.IEnumerable<Line2>

The collection of lines to test.

triangles System.Collections.Generic.IEnumerable<Triangle2>

The collection of triangles to intersect against.

tolerance System.Double

The distance tolerance used to determine intersections.

Returns

System.Collections.Generic.IEnumerable<Line2Intersection>
A collection of Line2Intersection results laid out row-major (row = line index, column = triangle index) with NaN results filtered out, or null if either input collection is null/empty or the graphics device is unavailable.

Modify Class

public static class Modify

Inheritance System.Object → Modify

Methods

Modify.Add(Coordinate2, Coordinate2, Coordinate2, double) Method

Adds a point to the pair of points defined by two coordinates within the specified tolerance, filling the first free (NaN) slot.

public static bool Add(ref DiGi.ComputeSharp.Planar.Classes.Coordinate2 point_1, ref DiGi.ComputeSharp.Planar.Classes.Coordinate2 point_2, DiGi.ComputeSharp.Planar.Classes.Coordinate2 point, double tolerance);

Parameters

point_1 Coordinate2

The first endpoint of the pair.

point_2 Coordinate2

The second endpoint of the pair.

point Coordinate2

The point to be added.

tolerance System.Double

The tolerance value for the operation.

Returns

System.Boolean
True if the point was successfully added; otherwise, false.

Modify.SwapIfCrossProductNegative(int, int, Coordinate2, Coordinate2) Method

Swaps two provided indices if the cross product of the given vectors is negative, or if the first vector is NaN while the second is not.

public static bool SwapIfCrossProductNegative(ref int index_1, ref int index_2, DiGi.ComputeSharp.Planar.Classes.Coordinate2 vector_1, DiGi.ComputeSharp.Planar.Classes.Coordinate2 vector_2);

Parameters

index_1 System.Int32

A reference to the first index to be potentially swapped.

index_2 System.Int32

A reference to the second index to be potentially swapped.

vector_1 Coordinate2

The first coordinate vector used for the cross product calculation.

vector_2 Coordinate2

The second coordinate vector used for the cross product calculation.

Returns

System.Boolean
True if the indices were swapped; otherwise, false.

Query Class

public static class Query

Inheritance System.Object → Query

Methods

Query.Centroid(Coordinate2, Coordinate2, Coordinate2, Coordinate2, Coordinate2, Coordinate2) Method

Calculates the centroid of up to six 2D coordinates, ignoring any coordinates that are NaN.

internal static DiGi.ComputeSharp.Planar.Classes.Coordinate2 Centroid(DiGi.ComputeSharp.Planar.Classes.Coordinate2 point_1, DiGi.ComputeSharp.Planar.Classes.Coordinate2 point_2, DiGi.ComputeSharp.Planar.Classes.Coordinate2 point_3, DiGi.ComputeSharp.Planar.Classes.Coordinate2 point_4, DiGi.ComputeSharp.Planar.Classes.Coordinate2 point_5, DiGi.ComputeSharp.Planar.Classes.Coordinate2 point_6);

Parameters

point_1 Coordinate2

The first coordinate.

point_2 Coordinate2

The second coordinate.

point_3 Coordinate2

The third coordinate.

point_4 Coordinate2

The fourth coordinate.

point_5 Coordinate2

The fifth coordinate.

point_6 Coordinate2

The sixth coordinate.

Returns

Coordinate2
A new Coordinate2(Coordinate2, Coordinate2, Coordinate2, Coordinate2, Coordinate2, Coordinate2, int) representing the centroid of the valid coordinates.

Query.Coordinate2(Coordinate2, Coordinate2, Coordinate2, Coordinate2, Coordinate2, Coordinate2, int) Method

Selects one of the six 2D coordinates by its index (1-based).

internal static DiGi.ComputeSharp.Planar.Classes.Coordinate2 Coordinate2(ref DiGi.ComputeSharp.Planar.Classes.Coordinate2 coordinate_1, ref DiGi.ComputeSharp.Planar.Classes.Coordinate2 coordinate_2, ref DiGi.ComputeSharp.Planar.Classes.Coordinate2 coordinate_3, ref DiGi.ComputeSharp.Planar.Classes.Coordinate2 coordinate_4, ref DiGi.ComputeSharp.Planar.Classes.Coordinate2 coordinate_5, ref DiGi.ComputeSharp.Planar.Classes.Coordinate2 coordinate_6, int index);

Parameters

coordinate_1 Coordinate2

The first coordinate reference.

coordinate_2 Coordinate2

The second coordinate reference.

coordinate_3 Coordinate2

The third coordinate reference.

coordinate_4 Coordinate2

The fourth coordinate reference.

coordinate_5 Coordinate2

The fifth coordinate reference.

coordinate_6 Coordinate2

The sixth coordinate reference.

index System.Int32

The 1-based index of the coordinate to select.

Returns

Coordinate2
The selected Coordinate2(Coordinate2, Coordinate2, Coordinate2, Coordinate2, Coordinate2, Coordinate2, int), or a default coordinate if index is out of bounds.

Query.Intersect(Line2, IEnumerable<Triangle2>, bool, bool) Method

Determines whether a specified line segment intersects with any triangle in the provided collection.

public static bool Intersect(DiGi.ComputeSharp.Planar.Classes.Line2 line2, System.Collections.Generic.IEnumerable<DiGi.ComputeSharp.Planar.Classes.Triangle2>? triangle2s, bool includeStart, bool includeEnd);

Parameters

line2 Line2

The line segment to evaluate for intersection.

triangle2s System.Collections.Generic.IEnumerable<Triangle2>

A collection of triangles to check against the line segment.

includeStart System.Boolean

Indicates whether the start point of the line should be included in the intersection test.

includeEnd System.Boolean

Indicates whether the end point of the line should be included in the intersection test.

Returns

System.Boolean
True if an intersection is found; otherwise, false.

Query.Intersect(IEnumerable<Line2>, IEnumerable<Triangle2>, bool, bool) Method

Determines whether each line in the provided collection intersects with any of the specified 2D triangles.

public static System.Collections.Generic.List<bool>? Intersect(System.Collections.Generic.IEnumerable<DiGi.ComputeSharp.Planar.Classes.Line2>? line2s, System.Collections.Generic.IEnumerable<DiGi.ComputeSharp.Planar.Classes.Triangle2>? triangle2s, bool includeStart, bool includeEnd);

Parameters

line2s System.Collections.Generic.IEnumerable<Line2>

The collection of 2D lines to evaluate for intersections.

triangle2s System.Collections.Generic.IEnumerable<Triangle2>

The collection of 2D triangles to test against.

includeStart System.Boolean

If set to true, the start point of the line is included in the intersection calculation.

includeEnd System.Boolean

If set to true, the end point of the line is included in the intersection calculation.

Returns

System.Collections.Generic.List<System.Boolean>
A list of boolean values indicating the intersection result for each input line, or null if the input collections are null.

Query.Intersect(this GraphicsDevice, Line2, ReadOnlyBuffer<Triangle2>, bool, bool) Method

Determines whether a 2D line intersects any of the triangles contained within the specified read-only buffer.

public static bool Intersect(this ComputeSharp.GraphicsDevice graphicDevice, DiGi.ComputeSharp.Planar.Classes.Line2 line2, ComputeSharp.ReadOnlyBuffer<DiGi.ComputeSharp.Planar.Classes.Triangle2> triangle2s, bool includeStart, bool includeEnd);

Parameters

graphicDevice ComputeSharp.GraphicsDevice

The graphics device used to perform the intersection calculation.

line2 Line2

The 2D line to test for intersection.

triangle2s ComputeSharp.ReadOnlyBuffer<Triangle2>

A read-only buffer containing the triangles to be tested against the line.

includeStart System.Boolean

If set to true, includes the start point of the line in the intersection test.

includeEnd System.Boolean

If set to true, includes the end point of the line in the intersection test.

Returns

System.Boolean
True if an intersection is found; otherwise, false.

Query.Intersect(this GraphicsDevice, IEnumerable<Line2>, ReadOnlyBuffer<Triangle2>, bool, bool) Method

Performs an intersection test between a collection of 2D lines and a buffer of 2D triangles using the specified graphics device.

public static System.Collections.Generic.List<bool>? Intersect(this ComputeSharp.GraphicsDevice? graphicDevice, System.Collections.Generic.IEnumerable<DiGi.ComputeSharp.Planar.Classes.Line2>? line2s, ComputeSharp.ReadOnlyBuffer<DiGi.ComputeSharp.Planar.Classes.Triangle2>? triangle2s, bool includeStart, bool includeEnd);

Parameters

graphicDevice ComputeSharp.GraphicsDevice

The graphics device used to perform the intersection calculations.

line2s System.Collections.Generic.IEnumerable<Line2>

An enumerable collection of 2D lines to be tested for intersections.

triangle2s ComputeSharp.ReadOnlyBuffer<Triangle2>

A read-only buffer containing the 2D triangles to test against.

includeStart System.Boolean

If set to true, includes the start point of each line in the intersection check.

includeEnd System.Boolean

If set to true, includes the end point of each line in the intersection check.

Returns

System.Collections.Generic.List<System.Boolean>
A list of boolean values indicating whether each corresponding line intersects any triangle, or null if the operation failed.

Clone this wiki locally