ipe::Vector Class Reference
Ipe Geometry

`#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)

## Detailed Description

Two-dimensional vector.

Unlike some other libraries, I don't make a difference between points and vectors.

## Constructor & Destructor Documentation

ipe::Vector::Vector | ( |  | ) |

inline

Uninitialized vector.

Referenced by ipe::Angle::liesBetween().

Vector::Vector | ( | Angle | alpha | ) |

explicit

Construct a unit vector with this direction.

ipe::Vector::Vector | ( | double | x0,
|  | double | y0
| ) |  |

inline explicit

Construct a vector.

## Member Function Documentation

double ipe::Vector::sqLen | ( |  | ) | const

inline

Return square of Euclidean length.

Return square of vector's length.

Referenced by ipe::TransformTool::compute(), ipe::Line::Line(), and ipe::Snap::snap().

double Vector::len | ( |  | ) | const

Referenced by ipe::Line::distance(), and ipe::Snap::getLine().

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.

References ipe::Angle::Angle(), and ZERO.

Referenced by ipe::TransformTool::compute(), ipe::Arc::distance(), ipe::Snap::getLine(), ipe::Arc::intersect(), and ipe::Snap::setEdge().

Vector Vector::normalized | ( |  | ) | const

Return this vector normalized (with length one).

Normalizing the zero vector returns the vector (1,0).

Referenced by ipe::Arc::distance().

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).

Referenced by ipe::Segment::distance(), and ipe::Segment::project().

bool Vector::snap | ( | const Vector & | mouse,
|  | Vector & | pos,
|  | double & | bound
| ) |  | const

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`.

References ipe::Rect::Rect(), x, and y.

Referenced by ipe::Segment::snap(), ipe::Bezier::snap(), and ipe::CanvasBase::snapToPaperAndFrame().

bool ipe::Vector::operator== | ( | const Vector & | rhs | ) | const

inline

Equality.

References x, and y.

bool ipe::Vector::operator!= | ( | const Vector & | rhs | ) | const

inline

Inequality.

References x, and y.

void ipe::Vector::operator+= | ( | const Vector & | rhs | ) |

inline

Vector-addition.

References x, and y.

void ipe::Vector::operator-= | ( | const Vector & | rhs | ) |

inline

Vector-subtraction.

References x, and y.

void ipe::Vector::operator*= | ( | double | rhs | ) |

inline

Multiply vector by scalar.

Vector ipe::Vector::operator+ | ( | const Vector & | rhs | ) | const

inline

Vector-addition.

Vector ipe::Vector::operator- | ( | const Vector & | rhs | ) | const

inline

Vector-subtraction.

Vector ipe::Vector::operator* | ( | double | rhs | ) | const

inline

Vector * scalar.

Vector ipe::Vector::operator- | ( |  | ) | const

inline

Unary minus for Vector.

## Friends And Related Function Documentation

Stream & operator<< | ( | Stream & | stream,
|  | const Vector & | rhs
| ) |  |

related

Vector operator* | ( | double | lhs,
|  | const Vector & | rhs
| ) |  |

related

Scalar * vector.

References x, and y.

double dot | ( | const Vector & | lhs,
|  | const Vector & | rhs
| ) |  |

related

Dotproduct of two vectors.

References x, and y.

## Member Data Documentation

Vector Vector::ZERO = Vector(0.0, 0.0)

static

The origin (zero vector).

Referenced by angle(), ipe::CanvasObserver::canvasObserverSizeChanged(), ipe::CairoPainter::doDrawText(), ipe::CanvasBase::drawGrid(), ipe::PanTool::PanTool(), ipe::Reference::Reference(), ipe::Reference::saveAsXml(), and ipe::CanvasBase::snapToPaperAndFrame().

double ipe::Vector::x

Coordinates are public.

Referenced by ipe::Rect::addPoint(), ipe::Rect::addRect(), ipe::Text::align(), ipe::Rect::certainClearance(), ipe::Rect::clipTo(), ipe::TransformTool::compute(), ipe::CanvasBase::computeFifi(), ipe::Rect::contains(), ipe::CanvasBase::devToUser(), ipe::Line::distance(), ipe::CairoPainter::doCurveTo(), ipe::CairoPainter::doDrawPath(), ipe::CairoPainter::doDrawText(), ipe::CairoPainter::doLineTo(), ipe::CairoPainter::doMoveTo(), dot(), ipe::Image::draw(), ipe::SelectTool::draw(), ipe::Shape::draw(), ipe::CanvasBase::drawAxes(), ipe::CanvasBase::drawFrame(), ipe::CanvasBase::drawGrid(), ipe::CanvasBase::drawObjects(), ipe::CanvasBase::drawPaper(), ipe::Image::Image(), ipe::Rect::intersects(), ipe::Matrix::Matrix(), ipe::SelectTool::mouseButton(), operator!=(), operator*(), ipe::Linear::operator*(), ipe::Matrix::operator*(), operator+=(), operator-=(), operator==(), ipe::ImlParser::parseStyle(), ipe::QPt(), ipe::Reference::Reference(), ipe::Thumbnail::render(), ipe::Text::saveAsXml(), ipe::Group::saveAsXml(), ipe::Thumbnail::saveRender(), ipe::Shape::Shape(), ipe::Snap::simpleSnap(), snap(), ipe::Text::Text(), ipe::TransformTool::TransformTool(), ipe::Painter::translate(), and ipe::CanvasBase::userToDev().

double ipe::Vector::y

Coordinates are public.

Referenced by ipe::Rect::addPoint(), ipe::Rect::addRect(), ipe::Text::align(), ipe::Rect::certainClearance(), ipe::Rect::clipTo(), ipe::TransformTool::compute(), ipe::CanvasBase::computeFifi(), ipe::Rect::contains(), ipe::CanvasBase::devToUser(), ipe::Line::distance(), ipe::CairoPainter::doCurveTo(), ipe::CairoPainter::doDrawPath(), ipe::CairoPainter::doDrawText(), ipe::CairoPainter::doLineTo(), ipe::CairoPainter::doMoveTo(), dot(), ipe::Image::draw(), ipe::SelectTool::draw(), ipe::Shape::draw(), ipe::CanvasBase::drawAxes(), ipe::CanvasBase::drawFrame(), ipe::CanvasBase::drawGrid(), ipe::CanvasBase::drawObjects(), ipe::CanvasBase::drawPaper(), ipe::Image::Image(), ipe::Rect::intersects(), ipe::Matrix::Matrix(), operator!=(), operator*(), ipe::Linear::operator*(), ipe::Matrix::operator*(), operator+=(), operator-=(), operator==(), ipe::ImlParser::parseStyle(), ipe::QPt(), ipe::Reference::Reference(), ipe::Thumbnail::render(), ipe::Text::saveAsXml(), ipe::Group::saveAsXml(), ipe::Thumbnail::saveRender(), ipe::Shape::Shape(), ipe::Snap::simpleSnap(), snap(), ipe::Text::Text(), ipe::TransformTool::TransformTool(), ipe::Painter::translate(), and ipe::CanvasBase::userToDev().

The documentation for this class was generated from the following files:

- ipegeo.h
- ipegeo.cpp