Rhino C++ API  8.14
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
ON_Line Class Reference

#include <opennurbs_line.h>

Public Member Functions

 ON_Line ()
 Default constructor sets from = to = ON_3dPoint::Origin. More...
 
 ON_Line (ON_2dPoint start, ON_2dPoint end)
 
 ON_Line (ON_3dPoint start, ON_3dPoint end)
 
 ~ON_Line ()
 
ON_BoundingBox BoundingBox () const
 
ON_3dPoint ClosestPointTo (const ON_3dPoint &test_point) const
 
bool ClosestPointTo (const ON_3dPoint &test_point, double *t) const
 
bool Create (const ON_2dPoint start, const ON_2dPoint end)
 
bool Create (const ON_3dPoint start, const ON_3dPoint end)
 
ON_3dVector Direction () const
 
double DistanceTo (ON_3dPoint test_point) const
 
bool GetBoundingBox (ON_BoundingBox &bbox, int bGrowBox=false) const
 
bool GetTightBoundingBox (ON_BoundingBox &tight_bbox, bool bGrowBox=false, const ON_Xform *xform=nullptr) const
 
bool InPlane (ON_Plane &plane, double tolerance=0.0) const
 
int IntersectSurface (const class ON_Surface *surfaceB, ON_SimpleArray< ON_X_EVENT > &x, double intersection_tolerance=0.0, double overlap_tolerance=0.0, const ON_Interval *line_domain=0, const ON_Interval *surfaceB_udomain=0, const ON_Interval *surfaceB_vdomain=0) const
 
bool IsFartherThan (double d, const ON_3dPoint &P) const
 
bool IsFartherThan (double d, const ON_Line &L) const
 
bool IsValid () const
 
double Length () const
 
double MaximumCoordinate () const
 Maximum absolute coordinate of from and to. More...
 
double MaximumDistanceTo (const ON_3dPoint &P) const
 
double MaximumDistanceTo (const ON_Line &other) const
 
double MinimumDistanceTo (const ON_3dPoint &P) const
 
double MinimumDistanceTo (const ON_Line &L) const
 
ON_3dPointoperator[] (int)
 line[0] = start point line[1] = end point More...
 
const ON_3dPointoperator[] (int) const
 
ON_3dPoint PointAt (double t) const
 
void Reverse ()
 For intersections see ON_Intersect();. More...
 
bool Rotate (double angle_in_radians, const ON_3dVector &axis_of_rotation, const ON_3dPoint &center_of_rotation)
 
bool Rotate (double sin_angle, double cos_angle, const ON_3dVector &axis_of_rotation, const ON_3dPoint &center_of_rotation)
 rotate line about a point and axis More...
 
ON_3dVector Tangent () const
 
bool Transform (const ON_Xform &xform)
 
bool Translate (const ON_3dVector &delta)
 

Public Attributes

ON_3dPoint from
 start point More...
 
ON_3dPoint to
 end point More...
 

Static Public Attributes

static const ON_Line NanLine
 (ON_3dPoint::NanPoint, ON_3dPoint::NanPoint) More...
 
static const ON_Line UnsetLine
 (ON_3dPoint::UnsetPoint, ON_3dPoint::UnsetPoint) More...
 
static const ON_Line ZeroLine
 (ON_3dPoint::Origin, ON_3dPoint::Origin) More...
 

Detailed Description

Copyright (c) 1993-2022 Robert McNeel & Associates. All rights reserved. OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert McNeel & Associates.

THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.

For complete openNURBS copyright information see http://www.opennurbs.org.

Constructor & Destructor Documentation

◆ ON_Line() [1/3]

ON_Line::ON_Line ( )

Default constructor sets from = to = ON_3dPoint::Origin.

◆ ~ON_Line()

ON_Line::~ON_Line ( )

◆ ON_Line() [2/3]

ON_Line::ON_Line ( ON_3dPoint  start,
ON_3dPoint  end 
)
explicit

◆ ON_Line() [3/3]

ON_Line::ON_Line ( ON_2dPoint  start,
ON_2dPoint  end 
)
explicit

Member Function Documentation

◆ BoundingBox()

ON_BoundingBox ON_Line::BoundingBox ( ) const

Description: Get line's 3d axis aligned bounding box. Returns: 3d bounding box.

◆ ClosestPointTo() [1/2]

ON_3dPoint ON_Line::ClosestPointTo ( const ON_3dPoint test_point) const

Description: Find the point on the (infinite) line that is closest to the test_point. Parameters: test_point - [in] Returns: The point on the line that is closest to test_point.

◆ ClosestPointTo() [2/2]

bool ON_Line::ClosestPointTo ( const ON_3dPoint test_point,
double *  t 
) const

Description: Find the point on the (infinite) line that is closest to the test_point. Parameters: test_point - [in] t - [out] line.PointAt(*t) is the point on the line that is closest to test_point. Returns: true if successful.

◆ Create() [1/2]

bool ON_Line::Create ( const ON_2dPoint  start,
const ON_2dPoint  end 
)

◆ Create() [2/2]

bool ON_Line::Create ( const ON_3dPoint  start,
const ON_3dPoint  end 
)

Description: Create a line from two points. Parameters: start - [in] point at start of line segment end - [in] point at end of line segment Returns: true if start and end are distinct points.

◆ Direction()

ON_3dVector ON_Line::Direction ( ) const

Returns: direction vector = line.to - line.from See Also: ON_Line::Tangent

◆ DistanceTo()

double ON_Line::DistanceTo ( ON_3dPoint  test_point) const

Description: Find the point on the (infinite) line that is closest to the test_point. Parameters: test_point - [in] Returns: distance from the point on the line that is closest to test_point. See Also: ON_3dPoint::DistanceTo ON_Line::ClosestPointTo

◆ GetBoundingBox()

bool ON_Line::GetBoundingBox ( ON_BoundingBox bbox,
int  bGrowBox = false 
) const

Description: Get line's 3d axis aligned bounding box or the union of the input box with the object's bounding box. Parameters: bbox - [in/out] 3d axis aligned bounding box bGrowBox - [in] (default=false) If true, then the union of the input bbox and the object's bounding box is returned in bbox.
If false, the object's bounding box is returned in bbox. Returns: true if object has bounding box and calculation was successful.

◆ GetTightBoundingBox()

bool ON_Line::GetTightBoundingBox ( ON_BoundingBox tight_bbox,
bool  bGrowBox = false,
const ON_Xform xform = nullptr 
) const

Description: Get tight bounding box. Parameters: tight_bbox - [in/out] tight bounding box bGrowBox -[in] (default=false)
If true and the input tight_bbox is valid, then returned tight_bbox is the union of the input tight_bbox and the line's tight bounding box. xform -[in] (default=nullptr) If not nullptr, the tight bounding box of the transformed line is calculated. The line is not modified. Returns: True if a valid tight_bbox is returned.

◆ InPlane()

bool ON_Line::InPlane ( ON_Plane plane,
double  tolerance = 0.0 
) const

Description: Get a plane that contains the line. Parameters: plane - [out] a plane that contains the line. The origin of the plane is at the start of the line. The distance from the end of the line to the plane is <= tolerance. If possible a plane parallel to the world xy, yz or zx plane is returned. tolerance - [in] Returns: true if a coordinate of the line's direction vector is larger than tolerance.

◆ IntersectSurface()

int ON_Line::IntersectSurface ( const class ON_Surface surfaceB,
ON_SimpleArray< ON_X_EVENT > &  x,
double  intersection_tolerance = 0.0,
double  overlap_tolerance = 0.0,
const ON_Interval line_domain = 0,
const ON_Interval surfaceB_udomain = 0,
const ON_Interval surfaceB_vdomain = 0 
) const

Description: Intersect infinite line with surfaceB. Parameters: surfaceB - [in] x - [out] Intersection events are appended to this array. intersection_tolerance - [in] If the distance from a point on this line to the surface is <= intersection tolerance, then the point will be part of an intersection event. If the input intersection_tolerance <= 0.0, then 0.001 is used. overlap_tolerance - [in] If t1 and t2 are curve parameters of intersection events and the distance from line(t) to the surface is <= overlap_tolerance for every t1 <= t <= t2, then the event will be returned as an overlap event. If the input overlap_tolerance <= 0.0, then intersection_tolerance*2.0 is used. line_domain - [in] optional restriction on line's domain If you want a finite intersection, then specify a line_domain. If you want a ray intersection, then specify a line domain like (0.0, ON_DBL_MAX). surfaceB_udomain - [in] optional restriction on surfaceB u domain surfaceB_vdomain - [in] optional restriction on surfaceB v domain Returns: Number of intersection events appended to x.

◆ IsFartherThan() [1/2]

bool ON_Line::IsFartherThan ( double  d,
const ON_3dPoint P 
) const

Description: Quickly determine if the shortest distance from this line to the other object is greater than d. Parameters: d - [in] distance (> 0.0) P - [in] L - [in] Returns: True if if the shortest distance from this line to the other object is greater than d.

◆ IsFartherThan() [2/2]

bool ON_Line::IsFartherThan ( double  d,
const ON_Line L 
) const

◆ IsValid()

bool ON_Line::IsValid ( ) const

Returns: True if from != to and both from and to are valid.

◆ Length()

double ON_Line::Length ( ) const

Returns: Length of line

◆ MaximumCoordinate()

double ON_Line::MaximumCoordinate ( ) const

Maximum absolute coordinate of from and to.

◆ MaximumDistanceTo() [1/2]

double ON_Line::MaximumDistanceTo ( const ON_3dPoint P) const

Description: Finds the longest distance between the line as a finite chord and the other object. Parameters: P - [in] L - [in] (another finite chord) Returns: A value d such that if Q is any point on this line and P is any point on the other object, then d >= Q.DistanceTo(P).

◆ MaximumDistanceTo() [2/2]

double ON_Line::MaximumDistanceTo ( const ON_Line other) const

◆ MinimumDistanceTo() [1/2]

double ON_Line::MinimumDistanceTo ( const ON_3dPoint P) const

Description: Finds the shortest distance between the line as a finite chord and the other object. Parameters: P - [in] L - [in] (another finite chord) Returns: A value d such that if Q is any point on this line and P is any point on the other object, then d <= Q.DistanceTo(P).

◆ MinimumDistanceTo() [2/2]

double ON_Line::MinimumDistanceTo ( const ON_Line L) const

◆ operator[]() [1/2]

ON_3dPoint& ON_Line::operator[] ( int  )

line[0] = start point line[1] = end point

◆ operator[]() [2/2]

const ON_3dPoint& ON_Line::operator[] ( int  ) const

◆ PointAt()

ON_3dPoint ON_Line::PointAt ( double  t) const

Description: Evaluate point on (infinite) line. Parameters: t - [in] evaluation parameter. t=0 returns line.from and t=1 returns line.to. Returns: (1-t)*line.from + t*line.to. See Also: ON_Line::Direction ON_Line::Tangent

◆ Reverse()

void ON_Line::Reverse ( )

For intersections see ON_Intersect();.

Description: Reverse line by swapping from and to.

◆ Rotate() [1/2]

bool ON_Line::Rotate ( double  angle_in_radians,
const ON_3dVector axis_of_rotation,
const ON_3dPoint center_of_rotation 
)

◆ Rotate() [2/2]

bool ON_Line::Rotate ( double  sin_angle,
double  cos_angle,
const ON_3dVector axis_of_rotation,
const ON_3dPoint center_of_rotation 
)

rotate line about a point and axis

◆ Tangent()

ON_3dVector ON_Line::Tangent ( ) const

Returns: Unit tangent vector. See Also: ON_Line::Direction

◆ Transform()

bool ON_Line::Transform ( const ON_Xform xform)

◆ Translate()

bool ON_Line::Translate ( const ON_3dVector delta)

Member Data Documentation

◆ from

ON_3dPoint ON_Line::from

start point

◆ NanLine

const ON_Line ON_Line::NanLine
static

◆ to

ON_3dPoint ON_Line::to

end point

◆ UnsetLine

const ON_Line ON_Line::UnsetLine
static

◆ ZeroLine

const ON_Line ON_Line::ZeroLine
static