A straight line in the 2D plane. More...
#include <MBARI/Geometry2D.H>
Public Member Functions | |
StraightLine2D () | |
default constructo, constructs an invalid object | |
StraightLine2D (const Vector2D &point, const Vector2D &direction) | |
construct from two Vector2D | |
StraightLine2D (std::istream &is) | |
Construct from the data contained in the input stream is. | |
void | reset (const Vector2D &point, const Vector2D &direction) |
reset the straight line | |
void | writeToStream (std::ostream &os) const |
write the entire StraightLine2D to the output stream os | |
void | readFromStream (std::istream &is) |
read the StraightLine2D from the input stream is | |
Vector2D | point (float n=0.0F) const |
get a point on the line | |
Vector2D | direction () const |
returns the direction vector for this straight line | |
Vector2D | intersect (const StraightLine2D &other, float &n, float &m) const |
returns a vector to the intersection point of this and other | |
bool | isParallel (const StraightLine2D &other) const |
whether this and other are parallel | |
bool | isOrthogonal (const StraightLine2D &other) const |
whether this and other are orthogonal | |
bool | isPointOnLine (const Vector2D &pt) const |
whether pt is on the straight line | |
bool | isIdentical (const StraightLine2D &other) const |
whether this and other describe identical straight lines | |
bool | isValid () const |
whether this object is valid |
A straight line in the 2D plane.
Definition at line 165 of file Geometry2D.H.
StraightLine2D::StraightLine2D | ( | ) |
default constructo, constructs an invalid object
Definition at line 319 of file Geometry2D.C.
construct from two Vector2D
point | vector determining a point on the line | |
direction | vector determing the direction if the line |
Definition at line 324 of file Geometry2D.C.
StraightLine2D::StraightLine2D | ( | std::istream & | is | ) |
Construct from the data contained in the input stream is.
Definition at line 330 of file Geometry2D.C.
References readFromStream().
Vector2D StraightLine2D::direction | ( | ) | const |
returns the direction vector for this straight line
Definition at line 369 of file Geometry2D.C.
References ASSERT, and isValid().
Referenced by intersect(), isOrthogonal(), and isParallel().
Vector2D StraightLine2D::intersect | ( | const StraightLine2D & | other, | |
float & | n, | |||
float & | m | |||
) | const |
returns a vector to the intersection point of this and other
if the lines do not intersect (i.e. they are parallel), an invalid Vector2D is returned.
n | in this variable, the scalar is returned, for which the intersection point is this->point(n); | |
m | the scalar, for which the interesection point is other.point(m) |
Definition at line 376 of file Geometry2D.C.
References ASSERT, direction(), isParallel(), isValid(), point(), Vector2D::x(), and Vector2D::y().
bool StraightLine2D::isIdentical | ( | const StraightLine2D & | other | ) | const |
whether this and other describe identical straight lines
Definition at line 421 of file Geometry2D.C.
References ASSERT, isParallel(), isPointOnLine(), isValid(), and point().
bool StraightLine2D::isOrthogonal | ( | const StraightLine2D & | other | ) | const |
whether this and other are orthogonal
Definition at line 401 of file Geometry2D.C.
References ASSERT, direction(), Vector2D::isOrthogonal(), and isValid().
bool StraightLine2D::isParallel | ( | const StraightLine2D & | other | ) | const |
whether this and other are parallel
Definition at line 393 of file Geometry2D.C.
References ASSERT, direction(), Vector2D::isCollinear(), and isValid().
Referenced by intersect(), and isIdentical().
bool StraightLine2D::isPointOnLine | ( | const Vector2D & | pt | ) | const |
whether pt is on the straight line
Definition at line 409 of file Geometry2D.C.
References ASSERT, isValid(), Vector2D::isValid(), Vector2D::x(), and Vector2D::y().
Referenced by isIdentical().
bool StraightLine2D::isValid | ( | ) | const |
whether this object is valid
Definition at line 430 of file Geometry2D.C.
Referenced by direction(), intersect(), isIdentical(), isOrthogonal(), isParallel(), isPointOnLine(), and point().
Vector2D StraightLine2D::point | ( | float | n = 0.0F |
) | const |
get a point on the line
n | get point point + n * direction; for n = 0 (default), this is the point entered in the constructor or in reset |
Definition at line 362 of file Geometry2D.C.
References ASSERT, and isValid().
Referenced by intersect(), and isIdentical().
void StraightLine2D::readFromStream | ( | std::istream & | is | ) |
read the StraightLine2D from the input stream is
Definition at line 353 of file Geometry2D.C.
References Vector2D::readFromStream().
Referenced by Token::readFromStream(), and StraightLine2D().
reset the straight line
point | vector determining a point on the line | |
direction | vector determing the direction if the line |
Definition at line 336 of file Geometry2D.C.
void StraightLine2D::writeToStream | ( | std::ostream & | os | ) | const |
write the entire StraightLine2D to the output stream os
Definition at line 344 of file Geometry2D.C.
References Vector2D::writeToStream().
Referenced by Token::writeToStream().