Class Vector3

Class Documentation

class Vector3

This class represents a three-dimensional vector.

The three-dimensional vector can be used to represent a translation in three-dimensional space or to represent the attitude of an object using Euler angle.

Public Functions

inline Vector3()

Default constructor.

inline Vector3(const Vector3 &other)

Copy constructor.

Parameters:

other – a vector of dimension 3

inline Vector3(float x, float y, float z)

Constructor.

Constructs a three-dimensional vector from three single values x, y, z or roll, pitch, yaw

inline Vector3 &operator=(const Vector3 &other)

Assignment operator.

Parameters:

other – a vector of dimension 3

inline Vector3 cross(const Vector3 &other) const

Three-dimensional vector (cross) product.

Calculates the tree-dimensional cross product, which represents the vector orthogonal to the plane defined by this and other.

Returns:

this x other

inline double dot(const Vector3 &other) const

dot product

inline const float &operator()(unsigned int i) const
inline float &operator()(unsigned int i)
inline float &x()
inline float &y()
inline float &z()
inline const float &x() const
inline const float &y() const
inline const float &z() const
inline float &roll()
inline float &pitch()
inline float &yaw()
inline const float &roll() const
inline const float &pitch() const
inline const float &yaw() const
inline Vector3 operator-() const
inline Vector3 operator+(const Vector3 &other) const
inline Vector3 operator*(float x) const
inline Vector3 operator-(const Vector3 &other) const
inline void operator+=(const Vector3 &other)
inline void operator-=(const Vector3 &other)
inline void operator/=(float x)
inline void operator*=(float x)
inline bool operator==(const Vector3 &other) const
inline bool operator<(const Vector3 &other) const
inline double norm() const
Returns:

length of the vector (“L2 norm”)

inline double norm_sq() const
Returns:

squared length (“L2 norm”) of the vector

inline Vector3 &normalize()

normalizes this vector, so that it has norm=1.0

inline Vector3 normalized() const
Returns:

normalized vector, this one remains unchanged

inline double angleTo(const Vector3 &other) const
inline double distance(const Vector3 &other) const
inline double distanceXY(const Vector3 &other) const
Vector3 &rotate_IP(double roll, double pitch, double yaw)
std::istream &read(std::istream &s)
std::ostream &write(std::ostream &s) const
std::istream &readBinary(std::istream &s)
std::ostream &writeBinary(std::ostream &s) const

Protected Attributes

float data[3]