Easy3D 2.6.1
Loading...
Searching...
No Matches
Vec< N, T > Class Template Reference

Base class for vector types. It provides generic functionality for N dimensional vectors. More...

#include <easy3d/core/vec.h>

Public Types

typedef Vec< N, T > thisclass
 The type of this class.
 

Public Member Functions

 Vec ()
 Default constructor. All elements will be initialized to zero.
 
 Vec (const T &s)
 Constructs a vector from a scalar number.
 
template<class T2>
 Vec (const Vec< N, T2 > &rhs)
 Constructs a vector from another vector of the same dimension/size.
 
template<class T2, size_t M>
 Vec (const Vec< M, T2 > &rhs)
 Constructs a vector from another vector of the same dimension/size.
 
template<class T2>
 Vec (const T2 *rhs)
 Constructs a vector from an array of values.
 
thisclass & operator= (const thisclass &rhs)
 Assignment operator. It assigns the value of this vector from another vector.
 
T * data ()
 Returns the memory address of the vector.
 
const T * data () const
 Returns the constant memory address of the vector.
 
 operator const T * () const
 Conversion operator returning the constant memory address of the data. Very convenient to pass this vector as a data pointer to functions.
 
 operator T* ()
 Conversion operator returning the constant memory address of the data. Very convenient to pass this vector as a data pointer to functions.
 
T length2 () const
 Returns the squared length of this vector.
 
T length () const
 Returns the length of this vector.
 
T norm () const
 Returns the norm (i.e., length/magnitude) of this vector.
 
T distance2 (const thisclass &rhs) const
 Returns the squared Euclidean distance to another vector.
 
thisclass & normalize ()
 Normalizes this vector.
 
thisclass & operator+= (const thisclass &v)
 Compound addition with another vector.
 
thisclass & operator-= (const thisclass &v)
 Compound subtraction with another vector.
 
thisclass & operator*= (const thisclass &v)
 Compound component-wise multiplication with another vector.
 
thisclass & operator/= (const thisclass &v)
 Compound component-wise division with another vector.
 
template<class T2>
thisclass & operator*= (T2 s)
 Compound vector-scalar multiplication.
 
template<class T2>
thisclass & operator/= (T2 s)
 Compound vector-scalar division.
 
thisclass operator+ (const thisclass &v) const
 Addition with another vector.
 
thisclass operator- (const thisclass &v) const
 Subtraction with another vector.
 
template<class T2>
thisclass operator* (T2 s) const
 Vector-scalar multiplication.
 
template<class T2>
thisclass operator/ (T2 s) const
 Vector-scalar division.
 
thisclass operator- () const
 Negates this vector (i.e., adds a minus sign).
 

Static Public Member Functions

static size_t dimension ()
 Returns the dimension/size of this vector.
 
static size_t size ()
 Returns the dimension/size of this vector.
 

Detailed Description

template<size_t N, class T>
class easy3d::Vec< N, T >

Base class for vector types. It provides generic functionality for N dimensional vectors.

Template Parameters
NThe dimension/size of a vector.
TThe scalar type of vector elements.

Member Typedef Documentation

◆ thisclass

template<size_t N, class T>
typedef Vec<N, T> thisclass

The type of this class.

This typedef represents the type of the current class.

Constructor & Destructor Documentation

◆ Vec()

template<size_t N, class T>
Vec ( const T & s)
inlineexplicit

Constructs a vector from a scalar number.

Parameters
sThe scalar value to initialize all elements of the vector.

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