[StructLayout(LayoutKind.Sequential, Pack = 8, Size = 48)] [Serializable] public struct Line : IEquatable<Line>, IEpsilonComparable<Line>, ICloneable, IFormattable
Represents the value of start and end points in a single line segment.

Constructors

Line

#Since v5.0
public Line(double x0, double y0, double z0, double x1, double y1, double z1)
Constructs a new line segment between two points.
x0 (double)The X coordinate of the first point.
y0 (double)The Y coordinate of the first point.
z0 (double)The Z coordinate of the first point.
x1 (double)The X coordinate of the second point.
y1 (double)The Y coordinate of the second point.
z1 (double)The Z coordinate of the second point.

Line

#Since v5.0
public Line(Point3d from, Point3d to)
Constructs a new line segment between two points.
from (Point3d)Start point of line.
to (Point3d)End point of line.

Line

#Since v5.0
public Line(Point3d start, Vector3d direction, double length)
Constructs a new line segment from start point, direction and length.
start (Point3d)Start point of line segment.
direction (Vector3d)Direction of line segment.
length (double)Length of line segment.

Line

#Since v5.0
public Line(Point3d start, Vector3d span)
Constructs a new line segment from start point and span vector.
start (Point3d)Start point of line segment.
span (Vector3d)Direction and length of line segment.

Properties

BoundingBox

#Since v5.0
public BoundingBox BoundingBox { get; }
Gets the line's 3d axis aligned bounding box.
3d bounding box.

Direction

#ExampleSince v5.0
public Vector3d Direction { get; }
Gets the direction of this line segment. The length of the direction vector equals the length of the line segment.

From

#Since v5.0
public Point3d From { get; set; }
Start point of line segment.

FromX

#Since v5.0
public double FromX { get; set; }
Gets or sets the X coordinate of the line From point.

FromY

#Since v5.0
public double FromY { get; set; }
Gets or sets the Y coordinate of the line From point.

FromZ

#Since v5.0
public double FromZ { get; set; }
Gets or sets the Z coordinate of the line From point.

IsValid

#Since v5.0
public bool IsValid { get; }
Gets a value indicating whether or not this line is valid. Valid lines must have valid start and end points, and the points must not be equal.

Length

#Since v5.0
public double Length { get; set; }
Gets or sets the length of this line segment. Note that a negative length will invert the line segment without making the actual length negative. The line From point will remain fixed when a new Length is set.

To

#Since v5.0
public Point3d To { get; set; }
End point of line segment.

ToX

#Since v5.0
public double ToX { get; set; }
Gets or sets the X coordinate of the line To point.

ToY

#Since v5.0
public double ToY { get; set; }
Gets or sets the Y coordinate of the line To point.

ToZ

#Since v5.0
public double ToZ { get; set; }
Gets or sets the Z coordinate of the line To point.

UnitTangent

#Since v5.0
public Vector3d UnitTangent { get; }
Gets the tangent of the line segment. Note that tangent vectors are always unit vectors.
Sets only the direction of the line, the length is maintained.

Unset

#Since v5.0
public static Line Unset { get; }
Gets a line segment which has Point3d.Unset end points.

Methods

ClosestParameter

#Since v5.0
[ConstOperation] public double ClosestParameter(Point3d testPoint)
Finds the parameter on the infinite line segment that is closest to a test point.
testPoint (Point3d)Point to project onto the line.
The parameter on the line that is closest to testPoint.

ClosestPoint

#Since v5.0
[ConstOperation] public Point3d ClosestPoint(Point3d testPoint, bool limitToFiniteSegment)
Finds the point on the (in)finite line segment that is closest to a test point.
testPoint (Point3d)Point to project onto the line.
limitToFiniteSegment (bool)If true, the projection is limited to the finite line segment.
The point on the (in)finite line that is closest to testPoint.

DistanceTo

#Since v5.0
[ConstOperation] public double DistanceTo(Point3d testPoint, bool limitToFiniteSegment)
Compute the shortest distance between this line segment and a test point.
testPoint (Point3d)Point for distance computation.
limitToFiniteSegment (bool)If true, the distance is limited to the finite line segment.
The shortest distance between this line segment and testPoint.

EpsilonEquals

#Since v5.4
[ConstOperation] public bool EpsilonEquals(Line other, double epsilon)
Check that all values in other are within epsilon of the values in this
other (Line)
epsilon (double)
EpsilonEquals

Equals

#Since v5.0
[ConstOperation] public bool Equals(Line other)
Determines whether a line has the same value as this line.
other (Line)A line.
true if other has the same coordinates as this; otherwise false.

Equals

#
[ConstOperation] public override bool Equals(object obj)
Determines whether an object is a line that has the same value as this line.
obj (object)An object.
true if obj is a Line and has the same coordinates as this; otherwise false.
ValueType.Equals

Extend

#Since v5.0
public bool Extend(double startLength, double endLength)
Extend the line by custom distances on both sides.
startLength (double)Distance to extend the line at the start point. Positive distance result in longer lines.
endLength (double)Distance to extend the line at the end point. Positive distance result in longer lines.
true on success, false on failure.

ExtendThroughBox

#Since v5.0
public bool ExtendThroughBox(BoundingBox box, double additionalLength)
Ensure the line extends all the way through a box. Note, this does not result in the shortest possible line that overlaps the box.
box (BoundingBox)Box to extend through.
additionalLength (double)Additional length to append at both sides of the line.
true on success, false on failure.

ExtendThroughBox

#Since v5.0
public bool ExtendThroughBox(BoundingBox box)
Ensure the line extends all the way through a box. Note, this does not result in the shortest possible line that overlaps the box.
box (BoundingBox)Box to extend through.
true on success, false on failure.

ExtendThroughBox

#Since v5.0
public bool ExtendThroughBox(Box box, double additionalLength)
Ensure the line extends all the way through a box. Note, this does not result in the shortest possible line that overlaps the box.
box (Box)Box to extend through.
additionalLength (double)Additional length to append at both sides of the line.
true on success, false on failure.

ExtendThroughBox

#Since v5.0
public bool ExtendThroughBox(Box box)
Ensure the line extends all the way through a box. Note, this does not result in the shortest possible line that overlaps the box.
box (Box)Box to extend through.
true on success, false on failure.

Flip

#Since v5.0
public void Flip()
Flip the endpoints of the line segment.

GetHashCode

#
[ConstOperation] public override int GetHashCode()
Computes a hash number that represents this line.
A number that is not unique to the value of this line.

MaximumDistanceTo

#Since v5.0
[ConstOperation] public double MaximumDistanceTo(Line testLine)
Finds the largest distance between this line as a finite segment and another finite segment.
testLine (Line)A line to test.
The maximum distance.

MaximumDistanceTo

#Since v5.0
[ConstOperation] public double MaximumDistanceTo(Point3d testPoint)
Finds the largest distance between this line as a finite segment and a test point.
testPoint (Point3d)A point to test.
The maximum distance.

MinimumDistanceTo

#Since v5.0
[ConstOperation] public double MinimumDistanceTo(Line testLine)
Finds the shortest distance between this line as a finite segment and another finite segment.
testLine (Line)A line to test.
The minimum distance.

MinimumDistanceTo

#Since v5.0
[ConstOperation] public double MinimumDistanceTo(Point3d testPoint)
Finds the shortest distance between this line as a finite segment and a test point.
testPoint (Point3d)A point to test.
The minimum distance.

PointAt

#ExampleSince v5.0
[ConstOperation] public Point3d PointAt(double t)
Evaluates the line at the specified parameter.
t (double)Parameter to evaluate line segment at. Line parameters are normalized parameters.
The point at the specified parameter.

PointAtLength

#Since v6.0
[ConstOperation] public Point3d PointAtLength(double distance)
Computes a point located at a specific metric distance from the line origin (From).

If line start and end coincide, then the start point is always returned.

distance (double)A positive, 0, or a negative value that will be the distance from From.
The newly found point.
Explicit

ICloneable.Clone

#

ToNurbsCurve

#Since v5.0
[ConstOperation] public NurbsCurve ToNurbsCurve()
Constructs a nurbs curve representation of this line. This amounts to the same as calling NurbsCurve.CreateFromLine().
A nurbs curve representation of this line or null if no such representation could be made.

ToString

#
[ConstOperation] public override string ToString()
Constructs the string representation of this line, in the form "From,To".
A text string.

ToString

#Since v7.0
[ConstOperation] public string ToString(string format, IFormatProvider formatProvider)
Formats the value of the current instance using the specified format.
format (string)The format to use. -or- A null reference (Nothing in Visual Basic) to use the default format defined for the type of the IFormattable implementation.
formatProvider (IFormatProvider)The provider to use to format the value. -or- A null reference (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.
The value of the current instance in the specified format.

Transform

#Since v5.0
public bool Transform(Transform xform)
Transform the line using a Transformation matrix.
xform (Transform)Transform to apply to this line.
true on success, false on failure.

TryCreateBetweenCurves

#Since v5.2
public static bool TryCreateBetweenCurves(Curve curve0, Curve curve1, ref double t0, ref double t1, bool perpendicular0, bool perpendicular1, out Line line)
Creates a line segment between a pair of curves such that the line segment is either tangent or perpendicular to each of the curves.
curve0 (Curve)The first curve.
curve1 (Curve)The second curve.
t0 (ref double)Parameter value of point on curve0. Seed value at input and solution at output.
t1 (ref double)Parameter value of point on curve 0. Seed value at input and solution at output.
perpendicular0 (bool)Find line perpendicular to (true) or tangent to (false) curve0.
perpendicular1 (bool)Find line Perpendicular to (true) or tangent to (false) curve1.
line (out Line)The line segment if successful.
true on success, false on failure.

TryFitLineToPoints

#Since v5.0
public static bool TryFitLineToPoints(IEnumerable<Point3d> points, out Line fitLine)
Attempt to fit a line through a set of points.
points (IEnumerable<Point3d>)The points through which to fit.
fitLine (out Line)The resulting line on success.
true on success, false on failure.

TryGetPlane

#Since v5.0
[ConstOperation] public bool TryGetPlane(out Plane plane)
Gets a plane that contains the line. The origin of the plane is at the start of the line. If possible, a plane parallel to the world XY, YZ, or ZX plane is returned.
plane (out Plane)If the return value is true, the plane out parameter is assigned during this call.
true on success.

Operators

OperationResultDescription
Line==LineboolDetermines whether two lines have the same value.
Line!=LineboolDetermines whether two lines have different values.