Stellarium  HEAD
Public Member Functions | Static Public Member Functions | Data Fields
Vector3< T > Class Template Reference

A templatized 3d vector compatible with OpenGL. More...

#include <VecMath.hpp>

Public Member Functions

 Vector3 (T x=0)
 The vector is not initialized! More...
 Vector3 (const T *)
 Explicit conversion constructor from an array (copies values) More...
 Vector3 (T, T, T)
 Vector3 (QString s)
 Constructor from a comma-separated QString like "2,4,6" or "2.1,4.2,6.3".
 Vector3 (QStringList s)
 Constructor from a QStringList like { "2", "4", "6" } or { "2.1", "4.2", "6.3" }.
 Vector3 (QColor c)
 Constructor from a QColor.
void set (T, T, T)
Vector3 setFromHtmlColor (QString s)
 Assign from HTML color The Vec3i type will have values 0...255 Vec3f and Vec3d will have [0...[1.
bool operator== (const Vector3< T > &) const
bool operator!= (const Vector3< T > &) const
bool fuzzyEquals (const Vector3< T > &, T epsilon=std::numeric_limits< T >::epsilon()) const
 allows for a fuzzy comparison using some epsilon value
T & operator[] (int)
const T & operator[] (int) const
 operator const T * () const
 operator T* ()
const T * data () const
T * data ()
void operator+= (const Vector3< T > &)
void operator-= (const Vector3< T > &)
void operator*= (T)
void operator/= (T)
Vector3 operator- (const Vector3< T > &) const
Vector3 operator+ (const Vector3< T > &) const
Vector3 operator- () const
Vector3 operator+ () const
Vector3 operator* (T) const
Vector3 operator/ (T) const
dot (const Vector3< T > &) const
Vector3 operator^ (const Vector3< T > &) const
latitude () const
longitude () const
angle (const Vector3< T > &) const
angleNormalized (const Vector3< T > &) const
length () const =delete
lengthSquared () const =delete
norm () const
 Norm of the vector, also known as length.
normSquared () const
 Square of the norm of the vector, same as dot product with itself.
void normalize ()
void transfo4d (const Mat4d &)
void transfo4d (const Mat4f &)
Vec3f toVec3f () const
Vec3d toVec3d () const
QString toString () const
 Formatted string with brackets.
QString toStr () const
 Compact comma-separated string without brackets and spaces. More...
QString toStringLonLat () const
QString toHtmlColor () const
 Convert a Vec3i/Vec3f/Vec3d to HTML color notation. In case of Vec3i, components are 0...255, else 0...1.
QColor toQColor () const
 Convert to a QColor.
QVector3D toQVector () const
 Convert to a QVector3D.

Static Public Member Functions

static Vector3< T > fromBracketedString (QString s)
 converters to be registered in StelCore (may not work!)
static Vector3< T > fromQVector3D (QVector3D v)
 convert from a QVector3D

Data Fields

v [3]

Detailed Description

template<class T>
class Vector3< T >

A templatized 3d vector compatible with OpenGL.

Use Vec3i for integer and Vec3d or Vec3f typedef for vectors of double and float respectively.

Constructor & Destructor Documentation

◆ Vector3() [1/2]

template<class T >
Vector3< T >::Vector3 ( x = 0)

The vector is not initialized!

Sets all components of the vector to the same value

◆ Vector3() [2/2]

template<class T >
Vector3< T >::Vector3 ( const T *  x)

Explicit conversion constructor from an array (copies values)

Does not check array size, make sure it has at least 3 elements

Member Function Documentation

◆ toStr()

template<class T >
QString Vector3< T >::toStr ( ) const

Compact comma-separated string without brackets and spaces.

The result can be restored into a Vector2 by the Vector3(QString s) constructors.