[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
Constructs a new line segment between two points.
public Line(
x0,
The X coordinate of the first point.
y0,
The Y coordinate of the first point.
z0,
The Z coordinate of the first point.
x1,
The X coordinate of the second point.
y1,
The Y coordinate of the second point.
z1
The Z coordinate of the second point.
)

Line

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

Line

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

Line

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

Properties

BoundingBox

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

Direction

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

From

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

FromX

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

FromY

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

FromZ

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

IsValid

#Since v5.0
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.
public bool IsValid { get; }

Length

#Since v5.0
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.
public double Length { get; set; }

To

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

ToX

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

ToY

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

ToZ

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

UnitTangent

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

Unset

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

Methods

ClosestParameter

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

ClosestPoint

#Since v5.0
Finds the point on the (in)finite line segment that is closest to a test point.
[ConstOperation] public Point3d ClosestPoint(
testPoint,
Point to project onto the line.
limitToFiniteSegment
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
Compute the shortest distance between this line segment and a test point.
[ConstOperation] public double DistanceTo(
testPoint,
Point for distance computation.
limitToFiniteSegment
If true, the distance is limited to the finite line segment.
)
The shortest distance between this line segment and testPoint.

EpsilonEquals

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

Equals

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

Equals

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

Extend

#Since v5.0
Extend the line by custom distances on both sides.
public bool Extend(
startLength,
Distance to extend the line at the start point. Positive distance result in longer lines.
endLength
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
Ensure the line extends all the way through a box. Note, this does not result in the shortest possible line that overlaps the box.
public bool ExtendThroughBox(
box,
Box to extend through.
additionalLength
Additional length to append at both sides of the line.
)
true on success, false on failure.

ExtendThroughBox

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

ExtendThroughBox

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

ExtendThroughBox

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

Flip

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

GetHashCode

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

MaximumDistanceTo

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

MaximumDistanceTo

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

MinimumDistanceTo

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

MinimumDistanceTo

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

PointAt

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

PointAtLength

#Since v6.0
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.

[ConstOperation] public Point3d PointAtLength(
distance
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
Constructs a nurbs curve representation of this line. This amounts to the same as calling NurbsCurve.CreateFromLine().
[ConstOperation] public NurbsCurve ToNurbsCurve()
A nurbs curve representation of this line or null if no such representation could be made.

ToString

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

ToString

#Since v7.0
Formats the value of the current instance using the specified format.
[ConstOperation] public string ToString(
format,
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
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
Transform the line using a Transformation matrix.
public bool Transform(
Transform
xform
Transform to apply to this line.
)
true on success, false on failure.

TryCreateBetweenCurves

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

TryFitLineToPoints

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

TryGetPlane

#Since v5.0
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.
[ConstOperation] public bool TryGetPlane(
out Plane
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.