PointLine
Namespace: Digi21.DigiNG.Entities.Relations
Assembly: Digi21.DigiNG
Methods that analyze the relation between a point and a line.
public static class PointLine
The first parameter, point, is a ReadOnlyPoint, and the second, line, is a ReadOnlyLine.
Methods compare the point's coordinate with the line's vertices; they do not analyze edges. A point on a line edge that coincides with no vertex is disjoint from the line.
Disjoint returns the opposite of Coincident || CoincidentAndTerminate. Coincident and CoincidentAndTerminate only both return true if the line passes through the point twice: once at an intermediate vertex and once at an endpoint.
Static methods
| Method | Description |
|---|---|
| Coincident | true if the point coincides with an intermediate line vertex. |
| CoincidentAndTerminate | true if the point coincides with the first or last line vertex. |
| Disjoint | true if the point coincides with no line vertex. |
All methods throw ArgumentNullException if point or line is null.
Example
This program creates a line and three points in memory, and analyzes each point's relation to the line:
using Digi21.DigiNG.Entities;
using Digi21.DigiNG.Entities.Relations;
using Digi21.Math;
static Point Punto(string código, double x, double y) => new Point(new Code(código)) { Coordinate = new Point3D(x, y, 0) };
var línea = new Line(new Code("LINEA"));
línea.Points.Add(new[] { new Point3D(0, 0, 0), new Point3D(5, 0, 0), new Point3D(10, 0, 0) });
var intermedio = Punto("INTERMEDIO", 5, 0);
var extremo = Punto("EXTREMO", 10, 0);
var fuera = Punto("FUERA", 5, 1);
Console.WriteLine($"Coincident(INTERMEDIO): {PointLine.Coincident(intermedio, línea)}"); // True
Console.WriteLine($"CoincidentAndTerminate(INTERMEDIO): {PointLine.CoincidentAndTerminate(intermedio, línea)}"); // False
Console.WriteLine($"CoincidentAndTerminate(EXTREMO): {PointLine.CoincidentAndTerminate(extremo, línea)}"); // True
Console.WriteLine($"Disjoint(FUERA): {PointLine.Disjoint(fuera, línea)}"); // True