Line2d Class

Class describing a linear object. The Line2d class is used to describe booth infinite lines, line segments and rays.
Public Class Line2d 
Inherits Geometry2d
This language is not supported or no code example is available.
public class Line2d : Geometry2d
This language is not supported or no code example is available.
public ref class Line2d : public Geometry2d^
This language is not supported or no code example is available.
public class Line2d 
extends Geometry2d
This language is not supported or no code example is available.
Name Description
Public constructor Line2d() Creates a new line which have start and end point at origo.
Public constructor Line2d(Line2d) Copy constructor.
Public constructor Line2d(Point2d, Point2d) Creates a new line given start and end point. Creates copies of the points.
Public constructor Line2d(double, double, double, double) Creates a line using raw double data.
Top
Name Description
Public property Angle Computes the angle in radians of this line, that is the plane angle from start to end point.
Public property DX Gets the signed horizontal distance from start point to end point.
Public property DY Gets the signed vertical distance from start point to end point.
Public property End Gets a reference to the end point or sets it to a new point. Set copies the point.
Public property Extents Gets a new bounding box for this line.
Public property Length Gets or sets the distance between the definition points. When setting the length the endpoint is altered and the angle is the same.
Public property MidPoint Gets a new point that lies exactly between the start and end points.
Public property SquaredLength Gets the squared length of this line. This is faster than computing the actual length of it.
Public property Start Gets a reference to the start point or sets it to a new point. Set copies the point
Public property Vector
Public property X1 Gets the x coordinate of the start point.
Public property X2 Gets the x coordinate of the end point.
Public property Y1 Gets the y coordinate of the start point.
Public property Y2 Gets the y coordinate of the end point.
Top
Methods
 
Name Description
Public method ClosestPoint(Point2d) Computes a new point which resides on this line as a segment, which is as close as possible to a given point.
Public method ClosestPointInfinite(Point2d) Computes a new point which resides on this line as if it was infinite, which is as close as possible to a given point.
Public method Static CreateFromArc(Arc2d) Creates a new line that has start and end points that equals a given arc.
Public method Direction() The line direction as a Vector2d.
Public method Distance(Point2d) Computes the distance from a point to this line as a segment.
Public method DistanceInfinite(Point2d) Computes the distance from a point to the line in a way assuming the line is infinite.
Public method Eval(double) Computes a new point which is on this infinite line given a parameter in range 0-1. Smaller parameters than 0.0 or larger parameters than 1.0 works as well, and returns points out of the line segment.
Public method Eval(double, out double) Computes a new point which is on this infinite line given a parameter in range 0-1. Smaller parameters than 0.0 or larger parameters than 1.0 works as well, and returns points out of the line segment. A tangent angle at the parameter is computed as well (which in this case is same as lines angle)
Public method Static FindLinearLeastSquaresFit(List<Point2d>, double, double) Computes a least squares fit line of a list of points, starting at x0 and ending at x1. The error minimized is the y-diff to line only (not real distance to line).
Public method Static FindLinearLeastSquaresFitOrigo(List<Point2d>, double, double) Computes a least squares fit line, starting at x0 and ending at x1, and passing throught 0,0. The error minimized is the y-diff to line only (not real distance to line).
Public method GetX(double) Calculates the X value given Y. The line is considered infinite.
Public method GetY(double) Calculates the Y value given X. The line is considered infinite.
Public method IsHorizontal() Checks if the line is horizontal with epsilon tolerance.
Public method IsHorizontal(double) Checks if the line is horizontal with a given tolerance.
Public method IsVertical() Checks if the line is vertical with epsilon tolerance.
Public method IsVertical(double) Checks if the line is vertical with a given tolerance.
Public method Mirror(Point2d, Point2d) Mirrors the line in-place over a reflection line.
Public method Offset(double) Returns a new offsetted line. Positive offset offsetts to the right of the segment, and negative to the left.
Public method Offset(double, double) Same as offset but you can set start offset and end offset individually
Public method Param(Point2d) Computes the parameter in the range 0-1 where the projection of a given point resides on the line segment. If the parameter is less than 0 or larger than 1 the point lies 'before' or 'after' the line.
Public method Param(Point2d, out double) Computes the parameter in the range 0-1 where the projection of a given point resides on the line segment. If the parameter is less than 0 or larger than 1 the point lies 'before' or 'after' the line. A tangent angle at the point is computed as well (which in this case is same as lines angle)
Public method ProjectHorizontal(double, out double) Computes the x position on a line for a given y. If the line is horizontal, x parameter is not changed, and the function returns false.
Public method ProjectVertical(double, ref double) Computes the y position on a line for a given x. If the line is vertical, y parameter is not changed, and the function returns false.
Public method Reverse() Reverses the line in-place.
Public method Rotate(double) Rotates the line in-place around world origo with a given angle in radians.
Public method Rotate(double, Point2d) Rotates the line in-place around a given origo and a given angle in radians.
Public method Scale(double) Scales this line in-place with a given factor. Factors larger then 1 gives a longer line and smaller than 1 gives a shorter.
Public method Scale(double, Point2d) Scales this line in-place with a given factor and a specified origo. Factors larger then 1 gives a longer line and smaller than 1 gives a shorter.
Public method Side(Point2d, double) Checks the relative side of a point to this line. A tolerance decides how close the point can be to the line to be considered to be 'on' the line.
Public method Split(IEnumerable<Double>) Splits this line segment to multiple line segemnt using a list of parameters in the range 0-1. The list of parameters does _not_ need to be sorted. Multiple parameters that are the same will output zero length line segments.
Public method Split(params double[]) Splits this line segment to multiple line segemnt using a list of parameters in the range 0-1. The list of parameters does _not_ need to be sorted. Multiple parameters that are the same will output zero length line segments.
Public method Split(double, out Line2d, out Line2d) Splits the line segment at a given parameter in the range 0-1. If the parameter is less than zero or larger than 1, one of the lines will have zero length.
Public method ToRegion(double) Creates a new region that has the same geometry as this line. A tolerance can be given but is not used in this case.
Public method ToString() Returns a new string containig debug purpose info.
Public method Transform(Matrix2d) Transforms this line in-place with a matrix.
Public method Translate(double, double) Translates the line in place.
Public method WriteAutoCADScript(StreamWriter, int) Writes the object as an AutoCAD loadable script to a stream using a specified color
Top

.NET Framework

Supported in: 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

In this article

Definition