Stellarium  24.4
Public Member Functions | Static Public Member Functions | Data Fields
Vector4< T > Class Template Reference

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

#include <VecMath.hpp>

Public Member Functions

 Vector4 (T x=0)
 The vector is not initialized! More...
 
 Vector4 (const T *)
 Explicit conversion constructor from an array. More...
 
template<class T2 >
 Vector4 (const Vector4< T2 > &)
 Explicit conversion constructor from another Vec4 of any type. More...
 
 Vector4 (const Vector3< T > &)
 Creates an Vector4 with xyz set to the given Vector3, and w set to 1.0.
 
 Vector4 (T, T, T)
 Creates an Vector4 with xyz set to the given values, and w set to 1.0.
 
 Vector4 (const Vector3< T > &, T)
 Creates an Vector4 with xyz set to the given Vector3, and given last value as w.
 
 Vector4 (T, T, T, T)
 
 Vector4 (QString s)
 Constructor from a comma-separated QString like "2,4,6,8" or "2.1,4.2,6.3,8.4".
 
 Vector4 (QStringList s)
 Constructor from a QStringList like { "2", "4", "6", "8" } or { "2.1", "4.2", "6.3", "8.4" }.
 
 Vector4 (QColor c)
 Constructor from a QColor.
 
void set (T, T, T, T)
 
bool operator== (const Vector4< T > &) const
 
bool operator!= (const Vector4< T > &) const
 
T & operator[] (int)
 
const T & operator[] (int) const
 
 operator T* ()
 
 operator const T * () const
 
void operator+= (const Vector4< T > &)
 
void operator-= (const Vector4< T > &)
 
void operator*= (T)
 
void operator/= (T)
 
Vector4 operator- (const Vector4< T > &) const
 
Vector4 operator+ (const Vector4< T > &) const
 
Vector4 operator- () const
 
Vector4 operator+ () const
 
Vector4 operator* (T) const
 
Vector4 operator/ (T) const
 
dot (const Vector4< 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 &)
 
QString toString () const
 Formatted string with brackets.
 
QString toStr () const
 Compact comma-separated string without brackets and spaces. More...
 
QColor toQColor () const
 Convert to a QColor.
 
QVector4D toQVector () const
 Convert to a QVector4D.
 

Static Public Member Functions

static Vector4< T > fromBracketedString (QString s)
 converters to be registered in StelCore
 

Data Fields

v [4]
 

Detailed Description

template<class T>
class Vector4< T >

A templatized 4d vector compatible with OpenGL.

Use Vec4i for integer and Vec4d or Vec4f typedef for vectors of double and float respectively.

Constructor & Destructor Documentation

◆ Vector4() [1/3]

template<class T >
Vector4< T >::Vector4 ( x = 0)
inlineexplicit

The vector is not initialized!

Sets all components of the vector to the same value

◆ Vector4() [2/3]

template<class T >
Vector4< T >::Vector4 ( const T *  x)
inlineexplicit

Explicit conversion constructor from an array.

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

◆ Vector4() [3/3]

template<class T >
template<class T2 >
Vector4< T >::Vector4 ( const Vector4< T2 > &  other)
inlineexplicit

Explicit conversion constructor from another Vec4 of any type.

Uses default primitive type conversion

Member Function Documentation

◆ toStr()

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

Compact comma-separated string without brackets and spaces.

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