A vector in the 2D plane. More...
#include <MBARI/Geometry2D.H>
Public Member Functions | |
Vector2D () | |
default constructor, constructs an invalid Vector2D | |
Vector2D (float x, float y) | |
construct a Vector2D with coordinates x and y | |
Vector2D (const Point2D< int > &point) | |
construct a Vector2D from a Point2D<int> | |
Vector2D (const Point2D< double > &point) | |
construct a Vector2D from a Point2D<double> | |
Vector2D (std::istream &is) | |
Construct from the data contained in the input stream is. | |
void | reset (float x, float y) |
reset the entries of the vector | |
void | reset (const Point2D< int > &point) |
reset the entries of the vector from a Point2D<int> | |
void | writeToStream (std::ostream &os) const |
write the entire Vector2D to the output stream os | |
void | readFromStream (std::istream &is) |
read the Vector2D from the input stream is | |
float | x () const |
access the x coordinate | |
float | y () const |
access the y coordinate | |
Point2D< int > | getPoint2D () const |
return a Point2D<int> (rounding the coordinates to int) | |
float | dotProduct (const Vector2D &other) const |
compute the dot product of this with other | |
float | crossProduct (const Vector2D &other) const |
compute the cross product of this with other | |
float | length () const |
compute the length of the vector | |
float | normalize () |
normalize the vector to length 1 and return its old length | |
float | distance (const Vector2D &other) const |
compute the Euclildean distance of this from other | |
float | angle (const Vector2D &other) const |
compute the angle (in degrees) between this and other | |
bool | isCollinear (const Vector2D &other) const |
determine whether this and other are collinear | |
bool | isOrthogonal (const Vector2D &other) const |
determine whether this and and other are orthogonal | |
bool | isZero () const |
whether this vector is zero | |
bool | isValid () const |
whether this vector is valid | |
float | operator* (const Vector2D &v) const |
dot product | |
Vector2D | operator+ (const Vector2D &v) const |
component-based addition | |
Vector2D | operator- (const Vector2D &v) const |
component-based subtraction | |
Vector2D & | operator+= (const Vector2D &v) |
component-based addition | |
Vector2D & | operator-= (const Vector2D &v) |
Vector2D | operator+ (const float f) const |
scalar addition | |
Vector2D | operator- (const float f) const |
scalar subtraction | |
Vector2D | operator* (const float f) const |
scalar multiplication | |
Vector2D | operator/ (const float f) const |
scalar division | |
Vector2D & | operator+= (const float f) |
scalar addition | |
Vector2D & | operator-= (const float f) |
scalar subtraction | |
Vector2D & | operator*= (const float f) |
scalar multiplication | |
Vector2D & | operator/= (const float f) |
scalar division |
A vector in the 2D plane.
Definition at line 49 of file Geometry2D.H.
Vector2D::Vector2D | ( | ) |
default constructor, constructs an invalid Vector2D
Definition at line 51 of file Geometry2D.C.
Referenced by operator*(), operator+(), operator-(), and operator/().
Vector2D::Vector2D | ( | float | x, | |
float | y | |||
) |
construct a Vector2D with coordinates x and y
Definition at line 56 of file Geometry2D.C.
Vector2D::Vector2D | ( | const Point2D< int > & | point | ) |
construct a Vector2D from a Point2D<int>
Definition at line 61 of file Geometry2D.C.
Vector2D::Vector2D | ( | const Point2D< double > & | point | ) |
construct a Vector2D from a Point2D<double>
Definition at line 66 of file Geometry2D.C.
Vector2D::Vector2D | ( | std::istream & | is | ) |
Construct from the data contained in the input stream is.
Definition at line 71 of file Geometry2D.C.
References readFromStream().
float Vector2D::angle | ( | const Vector2D & | other | ) | const |
compute the angle (in degrees) between this and other
Definition at line 176 of file Geometry2D.C.
References ASSERT, dotProduct(), isValid(), and length().
Referenced by VisualEvent::assign(), and isCollinear().
float Vector2D::crossProduct | ( | const Vector2D & | other | ) | const |
float Vector2D::distance | ( | const Vector2D & | other | ) | const |
compute the Euclildean distance of this from other
Definition at line 167 of file Geometry2D.C.
float Vector2D::dotProduct | ( | const Vector2D & | other | ) | const |
compute the dot product of this with other
Definition at line 132 of file Geometry2D.C.
References ASSERT, isValid(), x(), and y().
Referenced by angle(), isOrthogonal(), length(), and operator*().
Point2D< int > Vector2D::getPoint2D | ( | ) | const |
return a Point2D<int> (rounding the coordinates to int)
Definition at line 125 of file Geometry2D.C.
References ASSERT, and isValid().
Referenced by VisualEventSet::drawTokens(), and BitObject::getCentroid().
bool Vector2D::isCollinear | ( | const Vector2D & | other | ) | const |
determine whether this and other are collinear
Definition at line 184 of file Geometry2D.C.
References angle(), ASSERT, and isValid().
Referenced by StraightLine2D::isParallel().
bool Vector2D::isOrthogonal | ( | const Vector2D & | other | ) | const |
determine whether this and and other are orthogonal
Definition at line 192 of file Geometry2D.C.
References ASSERT, dotProduct(), and isValid().
Referenced by StraightLine2D::isOrthogonal().
bool Vector2D::isValid | ( | ) | const |
whether this vector is valid
Definition at line 207 of file Geometry2D.C.
Referenced by angle(), VisualEvent::assign(), crossProduct(), distance(), dotProduct(), VisualEventSet::drawTokens(), getPoint2D(), isCollinear(), isOrthogonal(), StraightLine2D::isPointOnLine(), isZero(), normalize(), operator*(), operator+(), operator+=(), operator-(), operator/(), x(), and y().
bool Vector2D::isZero | ( | ) | const |
whether this vector is zero
Definition at line 200 of file Geometry2D.C.
float Vector2D::length | ( | ) | const |
compute the length of the vector
Definition at line 150 of file Geometry2D.C.
References dotProduct(), and sqrt().
Referenced by angle(), distance(), and normalize().
float Vector2D::normalize | ( | ) |
normalize the vector to length 1 and return its old length
Definition at line 154 of file Geometry2D.C.
Vector2D Vector2D::operator* | ( | const float | f | ) | const |
scalar multiplication
Definition at line 261 of file Geometry2D.C.
References isValid(), and Vector2D().
float Vector2D::operator* | ( | const Vector2D & | v | ) | const |
Vector2D & Vector2D::operator*= | ( | const float | f | ) |
scalar multiplication
Definition at line 291 of file Geometry2D.C.
Vector2D Vector2D::operator+ | ( | const float | f | ) | const |
component-based addition
Definition at line 217 of file Geometry2D.C.
References isValid(), Vector2D(), x(), and y().
Vector2D & Vector2D::operator+= | ( | const float | f | ) |
scalar addition
Definition at line 277 of file Geometry2D.C.
component-based addition
Definition at line 231 of file Geometry2D.C.
Vector2D Vector2D::operator- | ( | const float | f | ) | const |
scalar subtraction
Definition at line 254 of file Geometry2D.C.
References isValid(), and Vector2D().
component-based subtraction
Definition at line 224 of file Geometry2D.C.
References isValid(), Vector2D(), x(), and y().
Vector2D & Vector2D::operator-= | ( | const float | f | ) |
scalar subtraction
Definition at line 284 of file Geometry2D.C.
Vector2D Vector2D::operator/ | ( | const float | f | ) | const |
scalar division
Definition at line 268 of file Geometry2D.C.
References ASSERT, isValid(), and Vector2D().
Vector2D & Vector2D::operator/= | ( | const float | f | ) |
void Vector2D::readFromStream | ( | std::istream & | is | ) |
read the Vector2D from the input stream is
Definition at line 102 of file Geometry2D.C.
Referenced by Token::readFromStream(), StraightLine2D::readFromStream(), and Vector2D().
void Vector2D::reset | ( | const Point2D< int > & | point | ) |
reset the entries of the vector from a Point2D<int>
Definition at line 86 of file Geometry2D.C.
References Point2D< T >::i.
void Vector2D::reset | ( | float | x, | |
float | y | |||
) |
reset the entries of the vector
Definition at line 78 of file Geometry2D.C.
Referenced by BitObject::reset(), and FOEestimator::updateFOE().
void Vector2D::writeToStream | ( | std::ostream & | os | ) | const |
write the entire Vector2D to the output stream os
Definition at line 94 of file Geometry2D.C.
Referenced by Token::writePosition(), Token::writeToStream(), StraightLine2D::writeToStream(), and BitObject::writeToStream().
float Vector2D::x | ( | ) | const |
access the x coordinate
Definition at line 111 of file Geometry2D.C.
References ASSERT, and isValid().
Referenced by VisualEvent::assign(), crossProduct(), dotProduct(), VisualEvent::getCost(), StraightLine2D::intersect(), StraightLine2D::isPointOnLine(), operator!=(), operator+(), operator+=(), operator-(), operator==(), and VisualEvent::VisualEvent().
float Vector2D::y | ( | ) | const |
access the y coordinate
Definition at line 118 of file Geometry2D.C.
References ASSERT, and isValid().
Referenced by VisualEvent::assign(), crossProduct(), dotProduct(), VisualEvent::getCost(), StraightLine2D::intersect(), StraightLine2D::isPointOnLine(), operator!=(), operator+(), operator+=(), operator-(), operator==(), and VisualEvent::VisualEvent().