Ipelib
|
#include <ipegeo.h>
Public Member Functions | |
Vector () | |
Vector (Angle alpha) | |
Vector (double x0, double y0) | |
double | sqLen () const |
double | len () const |
Angle | angle () const |
Vector | normalized () const |
Vector | orthogonal () const |
double | factorize (Vector &unit) const |
bool | snap (const Vector &mouse, Vector &pos, double &bound) const |
bool | operator== (const Vector &rhs) const |
bool | operator!= (const Vector &rhs) const |
void | operator+= (const Vector &rhs) |
void | operator-= (const Vector &rhs) |
void | operator*= (double rhs) |
Vector | operator+ (const Vector &rhs) const |
Vector | operator- (const Vector &rhs) const |
Vector | operator* (double rhs) const |
Vector | operator- () const |
Public Attributes | |
double | x |
double | y |
Static Public Attributes | |
static Vector | ZERO = Vector(0.0, 0.0) |
Related Functions | |
(Note that these are not member functions.) | |
Stream & | operator<< (Stream &stream, const Vector &rhs) |
Vector | operator* (double lhs, const Vector &rhs) |
double | dot (const Vector &lhs, const Vector &rhs) |
Two-dimensional vector.
Unlike some other libraries, I don't make a difference between points and vectors.
|
inline |
Uninitialized vector.
|
explicit |
Construct a unit vector with this direction.
|
inlineexplicit |
Construct a vector.
|
inline |
Return square of Euclidean length.
Return square of vector's length.
double Vector::len | ( | ) | const |
Angle Vector::angle | ( | ) | const |
Return angle of the vector (with positive x-direction).
The returned angle lies between -pi and +pi. Returns zero for the zero vector.
Vector Vector::normalized | ( | ) | const |
Return this vector normalized (with length one).
Normalizing the zero vector returns the vector (1,0).
Vector Vector::orthogonal | ( | ) | const |
Return this vector turned 90 degrees to the left.
double Vector::factorize | ( | Vector & | unit | ) | const |
Normalizes this vector into unit and returns length. If this is the zero vector, unit is set to (1,0).
Snap to nearby vertex.
If distance between mouse and this vector is less than bound, set pos to this vector and bound to the distance, and return true
.
|
inline |
Equality.
|
inline |
Inequality.
|
inline |
Vector-addition.
|
inline |
Vector-subtraction.
|
inline |
Multiply vector by scalar.
double ipe::Vector::x |
Coordinates are public.
double ipe::Vector::y |
Coordinates are public.