Stellarium  0.19.3
Public Member Functions | Data Fields
Vector2< T > Class Template Reference

A templatized 2d vector compatible with openGL. More...

#include <VecMath.hpp>

Public Member Functions

 Vector2 ()
 The vector is not initialized!
 
 Vector2 (T)
 Sets all components of the vector to the same value.
 
 Vector2 (const T *)
 Explicit conversion constructor from an array (copies values) More...
 
template<class T2 >
 Vector2 (const Vector2< T2 > &)
 Explicit conversion constructor from another Vec2 of any type. More...
 
 Vector2 (T, T)
 
Vector2< T > & operator= (const T *)
 Assignment from array. More...
 
void set (T, T)
 
bool operator== (const Vector2< T > &) const
 
bool operator!= (const Vector2< T > &) const
 
const T & operator[] (int x) const
 
T & operator[] (int)
 
 operator const T * () const
 
 operator T* ()
 
Vector2< T > & operator+= (const Vector2< T > &)
 
Vector2< T > & operator-= (const Vector2< T > &)
 
Vector2< T > & operator*= (T)
 Scalar multiplication.
 
Vector2< T > & operator*= (const Vector2< T > &)
 Component-wise multiplication.
 
Vector2< T > & operator/= (T)
 Scalar division.
 
Vector2< T > & operator/= (const Vector2< T > &)
 Component-wise division.
 
Vector2< T > operator- (const Vector2< T > &) const
 
Vector2< T > operator+ (const Vector2< T > &) const
 
Vector2< T > operator- () const
 
Vector2< T > operator+ () const
 
Vector2< T > operator* (T) const
 Scalar multiplication.
 
Vector2< T > operator* (const Vector2< T > &) const
 Component-wise multiplication.
 
Vector2< T > operator/ (T) const
 Scalar division.
 
Vector2< T > operator/ (const Vector2< T > &) const
 Component-wise division.
 
Vector2< T > min (const Vector2< T > &) const
 Component-wise minimum determination.
 
Vector2< T > max (const Vector2< T > &) const
 Component-wise maximum determination.
 
Vector2< T > clamp (const Vector2< T > &low, const Vector2< T > &high) const
 Component-wise clamping to the specified upper and lower bounds.
 
dot (const Vector2< T > &) const
 
length () const
 
lengthSquared () const
 
void normalize ()
 
QString toString () const
 

Data Fields

v [2]
 

Detailed Description

template<class T>
class Vector2< T >

Use Vec2d or Vec2f typdef for vectors of double and float respectively.

Constructor & Destructor Documentation

◆ Vector2() [1/2]

template<class T>
Vector2< T >::Vector2 ( const T *  x)
inlineexplicit
Warning
Does not check array size, make sure it has at least 2 elements

◆ Vector2() [2/2]

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

Uses default primitive type conversion

Member Function Documentation

◆ operator=()

template<class T>
Vector2< T > & Vector2< T >::operator= ( const T *  a)
inline
Warning
Does not check array size, make sure it has at least 2 elements