Mapper  0.9.0
API documentation
Public Member Functions | Static Public Member Functions | List of all members
OpenOrienteering::MapCoordF Class Reference

Map coordinates stored as floating point numbers. More...

#include <map_coord.h>

Inheritance diagram for OpenOrienteering::MapCoordF:
Inheritance graph
[legend]
Collaboration diagram for OpenOrienteering::MapCoordF:
Collaboration graph
[legend]

Public Member Functions

constexpr MapCoordF () noexcept
 Creates a MapCoordF with both values set to zero. More...
 
constexpr MapCoordF (qreal x, qreal y) noexcept
 Creates a MapCoordF with the given position in map coordinates. More...
 
constexpr MapCoordF (const MapCoord &coord) noexcept
 Creates a MapCoordF from a MapCoord, dropping its flags. More...
 
constexpr MapCoordF (const MapCoordF &) noexcept=default
 Copy constructor. More...
 
constexpr MapCoordF (const QPointF &point) noexcept
 Copy constructor for QPointF prototypes. More...
 
MapCoordFoperator= (const QPointF &point) noexcept
 Assignment operator. More...
 
qreal length () const
 Returns the length of the vector. More...
 
constexpr qreal lengthSquared () const
 Returns the square of the length of the vector. More...
 
qreal distanceTo (const MapCoordF &to) const
 Returns the distance of the coordinate to another coordinate. More...
 
constexpr qreal distanceSquaredTo (const MapCoordF &to) const
 Returns the square of the distance of this coordinate to another coordinate. More...
 
void setLength (qreal new_length)
 Changes the length of the vector. More...
 
void normalize ()
 Normalizes the length of the vector. More...
 
qreal angle () const
 Returns the angle of the vector relative to the vector (1, 0). More...
 
void rotate (qreal angle)
 Rotates the vector. More...
 
const MapCoordF rotated (qreal angle) const
 Returns a vector which is the result of rotating this vector. More...
 
constexpr const MapCoordF perpRight () const
 Returns a vector with the same length that is perpendicular to this vector. More...
 
constexpr const MapCoordF normalVector () const
 Returns a vector with the same length that is perpendicular to this vector. More...
 
constexpr const MapCoordF operator- () const
 Additive inverse. More...
 
MapCoordFoperator+= (const MapCoordF &rhs)
 Component-wise addition. More...
 
MapCoordFoperator-= (const MapCoordF &rhs)
 Component-wise subtraction. More...
 
MapCoordFoperator*= (qreal factor)
 Multiply with a scalar. More...
 
MapCoordFoperator/= (qreal divisor)
 Divide by a scalar. More...
 
- Public Member Functions inherited from QPointF
 QPointF ()
 
 QPointF (const QPoint &point)
 
 QPointF (qreal xpos, qreal ypos)
 
qreal manhattanLength () const const
 
bool isNull () const const
 
qreal x () const const
 
qreal y () const const
 
void setX (qreal x)
 
void setY (qreal y)
 
qreal & rx ()
 
qreal & ry ()
 
QPointFoperator+= (const QPointF &point)
 
QPointFoperator-= (const QPointF &point)
 
QPointFoperator*= (qreal factor)
 
QPointFoperator/= (qreal divisor)
 
QPoint toPoint () const const
 
CGPoint toCGPoint () const const
 
const QPointF operator+ (const QPointF &p1, const QPointF &p2)
 
const QPointF operator- (const QPointF &p1, const QPointF &p2)
 
const QPointF operator* (const QPointF &point, qreal factor)
 
const QPointF operator* (qreal factor, const QPointF &point)
 
const QPointF operator+ (const QPointF &point)
 
const QPointF operator- (const QPointF &point)
 
const QPointF operator/ (const QPointF &point, qreal divisor)
 
bool operator== (const QPointF &p1, const QPointF &p2)
 
bool operator!= (const QPointF &p1, const QPointF &p2)
 
QDataStreamoperator<< (QDataStream &stream, const QPointF &point)
 
QDataStreamoperator>> (QDataStream &stream, QPointF &point)
 

Static Public Member Functions

static const MapCoordF fromPolar (qreal length, qreal angle)
 Returns a vector with the given length and angle. More...
 
- Static Public Member Functions inherited from QPointF
qreal dotProduct (const QPointF &p1, const QPointF &p2)
 
QPointF fromCGPoint (CGPoint point)
 

Detailed Description

Map coordinates stored as floating point numbers.

The unit is millimeters on the map paper.

This type was initially meant as intermediate format for rendering but is currently used in a wide range of functions related to editing. In contrast to MapCoord, MapCoordF does not store flags.

The type is based on QPointF and provides additional methods for using it to represent 2D vectors. (Some of the methods do have counterparts in QLineF rather than QPointF.) Similar to QPointF, many operators return const values, although one might argue that it is no longer good practice in C++11.

Constructor & Destructor Documentation

◆ MapCoordF() [1/5]

constexpr OpenOrienteering::MapCoordF::MapCoordF ( )
noexcept

Creates a MapCoordF with both values set to zero.

◆ MapCoordF() [2/5]

constexpr OpenOrienteering::MapCoordF::MapCoordF ( qreal  x,
qreal  y 
)
noexcept

Creates a MapCoordF with the given position in map coordinates.

◆ MapCoordF() [3/5]

constexpr OpenOrienteering::MapCoordF::MapCoordF ( const MapCoord coord)
explicitnoexcept

Creates a MapCoordF from a MapCoord, dropping its flags.

◆ MapCoordF() [4/5]

constexpr OpenOrienteering::MapCoordF::MapCoordF ( const MapCoordF )
defaultnoexcept

Copy constructor.

◆ MapCoordF() [5/5]

constexpr OpenOrienteering::MapCoordF::MapCoordF ( const QPointF point)
explicitnoexcept

Copy constructor for QPointF prototypes.

Member Function Documentation

◆ angle()

qreal OpenOrienteering::MapCoordF::angle ( ) const
inline

Returns the angle of the vector relative to the vector (1, 0).

The returned value is in radians, in the range range [-PI; +PI]. MapCoordF { 0, 1 }.getAngle() returns +PI/2, MapCoordF { 0, -1 }.getAngle() returns -PI/2.

◆ distanceSquaredTo()

constexpr qreal OpenOrienteering::MapCoordF::distanceSquaredTo ( const MapCoordF to) const

Returns the square of the distance of this coordinate to another coordinate.

This is a silghtly faster alternative to MapCoordF::distanceTo() which preserves comparability.

◆ distanceTo()

qreal OpenOrienteering::MapCoordF::distanceTo ( const MapCoordF to) const
inline

Returns the distance of the coordinate to another coordinate.

◆ fromPolar()

const MapCoordF OpenOrienteering::MapCoordF::fromPolar ( qreal  length,
qreal  angle 
)
inlinestatic

Returns a vector with the given length and angle.

◆ length()

qreal OpenOrienteering::MapCoordF::length ( ) const
inline

Returns the length of the vector.

The value returned the from this function is the MapCoords distance to the origin of the coordinate system.

◆ lengthSquared()

constexpr qreal OpenOrienteering::MapCoordF::lengthSquared ( ) const

Returns the square of the length of the vector.

This is a slightly faster alternative to MapCoordF::length() which preserves comparability.

◆ normalize()

void OpenOrienteering::MapCoordF::normalize ( )
inline

Normalizes the length of the vector.

The MapCoordF is interpreted as a vector and adjusted to a vector of the same direction but length 1 (i.e. unit vector).

◆ normalVector()

constexpr const MapCoordF OpenOrienteering::MapCoordF::normalVector ( ) const

Returns a vector with the same length that is perpendicular to this vector.

See also
QLineF::normalVector()

◆ operator*=()

MapCoordF & OpenOrienteering::MapCoordF::operator*= ( qreal  factor)
inline

Multiply with a scalar.

◆ operator+=()

MapCoordF & OpenOrienteering::MapCoordF::operator+= ( const MapCoordF rhs)
inline

Component-wise addition.

◆ operator-()

constexpr const MapCoordF OpenOrienteering::MapCoordF::operator- ( ) const

Additive inverse.

◆ operator-=()

MapCoordF & OpenOrienteering::MapCoordF::operator-= ( const MapCoordF rhs)
inline

Component-wise subtraction.

◆ operator/=()

MapCoordF & OpenOrienteering::MapCoordF::operator/= ( qreal  divisor)
inline

Divide by a scalar.

◆ operator=()

MapCoordF & OpenOrienteering::MapCoordF::operator= ( const QPointF point)
inlinenoexcept

Assignment operator.

◆ perpRight()

constexpr const MapCoordF OpenOrienteering::MapCoordF::perpRight ( ) const

Returns a vector with the same length that is perpendicular to this vector.

Note that in contrast to normalVector(), this function returns a perpendicular vector pointing to the right.

Todo:
Replace with normalVector(), similar to QLineF API.

◆ rotate()

void OpenOrienteering::MapCoordF::rotate ( qreal  angle)
inline

Rotates the vector.

The argument is to be given in radians. Positive arguments result in a counter-clockwise rotation.

◆ rotated()

const MapCoordF OpenOrienteering::MapCoordF::rotated ( qreal  angle) const
inline

Returns a vector which is the result of rotating this vector.

The argument is to be given in radians. Positive arguments result in a counter-clockwise rotation.

◆ setLength()

void OpenOrienteering::MapCoordF::setLength ( qreal  new_length)
inline

Changes the length of the vector.

The MapCoordF is interpreted as a vector and adjusted to a vector of the same direction but having the given length. It does nothing if the vector is very close to (0, 0).


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