Class Line
A curve representing a straight line.
public class Line : NurbsBase, IGeometry<NurbsBase>, IEquatable<NurbsBase>, ITransformable<NurbsBase>, IGeometry<Line>, IEquatable<Line>, ITransformable<Line>
// Initializes a line by start and end point.
Point3 pt1 = new Point3(5, 0, 0);
Point3 pt2 = new Point3(15, 15, 0);
_exampleLine = new Line(pt1, pt2);
// Initializes a line by a starting point a direction and a length.
Line line = new Line(pt1, Vector3.XAxis, 15);
Initializes a line by start point and end point.
public Line(Point3 startPoint, Point3 endPoint)
Type | Name | Description |
---|---|---|
Point3 | startPoint | Start point. |
Point3 | endPoint | End point. |
Initializes a line from a starting point, direction and length.
public Line(Point3 startPoint, Vector3 direction, double length)
Type | Name | Description |
---|---|---|
Point3 | startPoint | Starting point of the line. |
Vector3 | direction | Direction of the line. |
System.Double | length | Length of the line. |
Unit vector representing direction of the line.
public Vector3 Direction { get; }
Type | Description |
---|---|
Vector3 |
Gets the end point of the line.
public override Point3 EndPoint { get; }
Type | Description |
---|---|
Point3 |
Length of the line.
public override double Length { get; }
Type | Description |
---|---|
System.Double |
Gets the middle point of the line.
public override Point3 MidPoint { get; }
Type | Description |
---|---|
Point3 |
Gets the start point of the line.
public override Point3 StartPoint { get; }
Type | Description |
---|---|
Point3 |
Computes the parameter on the line that is closest to a test point.
public override double ClosestParameter(Point3 point)
Type | Name | Description |
---|---|---|
Point3 | point | The test point. |
Type | Description |
---|---|
System.Double | The parameter on the line closest to the test point. |
Gets the closest point on the line to the test point.
public override Point3 ClosestPoint(Point3 point)
Type | Name | Description |
---|---|---|
Point3 | point | The closest point to find. |
Type | Description |
---|---|
Point3 | The point on the line closest to the test point. |
Checks if the line is equal to the provided line.
Two lines are equal if the end points are the same.
public bool Equals(Line other)
Type | Name | Description |
---|---|---|
Line | other | The line to compare. |
Type | Description |
---|---|
System.Boolean | True if the end points are equal, otherwise false. |
Checks if the line is equal to the provided line.
Two lines are equal if the end points are the same.
public override bool Equals(object obj)
Type | Name | Description |
---|---|---|
System.Object | obj | The curve object. |
Type | Description |
---|---|
System.Boolean | Return true if the nurbs curves are equal. |
Extends the line by lengths on both side.
public Line Extend(double startLength, double endLength)
Type | Name | Description |
---|---|---|
System.Double | startLength | Length to extend the line at the start point. |
System.Double | endLength | Length to extend the line at the end point. |
Type | Description |
---|---|
Line | The extended line. |
Gets the bounding box in ascending fashion.
public override BoundingBox GetBoundingBox()
Type | Description |
---|---|
BoundingBox |
Gets the hash code for the line.
public override int GetHashCode()
Type | Description |
---|---|
System.Int32 | A unique hashCode of an line. |
Returns the length at a given parameter.
public override double LengthAt(double t)
Type | Name | Description |
---|---|---|
System.Double | t | Parameter, between 0.0 and 1.0. |
Type | Description |
---|---|
System.Double | The curve length at parameter. |
Computes the offset of the line.
public Line Offset(double distance, Plane pln)
Type | Name | Description |
---|---|---|
System.Double | distance | The distance of the offset. If negative the offset will be in the opposite side. |
Plane | pln | The plane for the offset operation. |
Type | Description |
---|---|
Line | The offset line. |
Evaluates the line at the specified parameter.
public override Point3 PointAt(double t)
Type | Name | Description |
---|---|---|
System.Double | t | Parameter to evaluate the line. Parameter should be between 0.0 and 1.0. |
Type | Description |
---|---|
Point3 | The point at the specific parameter. |
Evaluates the point on the curve at a given length.
public override Point3 PointAtLength(double length)
Type | Name | Description |
---|---|---|
System.Double | length | Length, between 0.0 and the length of the curve. |
Type | Description |
---|---|
Point3 | The point at the given length. |
Flip the endpoint of the line.
public Line Reverse()
Type | Description |
---|---|
Line | The line flipped. |
Constructs the string representation of the line.
public override string ToString()
Type | Description |
---|---|
System.String | A text string. |
Transforms the line using the transformation matrix.
public Line Transform(TransformMatrix t)
Type | Name | Description |
---|---|---|
TransformMatrix | t | Transformation matrix to apply. |
Type | Description |
---|---|
Line | A line transformed. |