Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::math::VectorBase< Dimension, T > Class Template Reference

VectorBase. More...

#include "vector.h"

Inheritance diagram for ion::math::VectorBase< Dimension, T >:

Classes

struct  StaticHelper
 Helper struct to aid in Zero, Fill, and Axis functions. More...
 
struct  StaticHelper< 1, U >
 Specializations to help with static functions. More...
 
struct  StaticHelper< 2, U >
 
struct  StaticHelper< 3, U >
 
struct  StaticHelper< 4, U >
 

Public Types

enum  { kDimension = Dimension }
 The dimension of the vector (number of elements). More...
 
typedef T ValueType
 

Public Member Functions

void Set (T e0)
 Sets the vector values. More...
 
void Set (T e0, T e1)
 
void Set (T e0, T e1, T e2)
 
void Set (T e0, T e1, T e2, T e3)
 
Toperator[] (int index)
 Mutable element accessor. More...
 
const Toperator[] (int index) const
 Read-only element accessor. More...
 
TData ()
 Returns a pointer to the data for interfacing with other libraries. More...
 
const TData () const
 
void Print (std::ostream &out, const char tag) const
 This is used for printing Vectors and Points to a stream. More...
 
template<char tag>
void Read (std::istream &in)
 This is used for reading Vectors and Points from a stream. More...
 

Static Public Member Functions

static bool AreValuesEqual (const VectorBase &v0, const VectorBase &v1)
 Returns true if all values in two instances are equal. More...
 

Protected Member Functions

 VectorBase ()
 The default constructor zero-initializes all elements. More...
 
 VectorBase (T e0)
 VectorBase implementation. More...
 
 VectorBase (T e0, T e1)
 
 VectorBase (T e0, T e1, T e2)
 
 VectorBase (T e0, T e1, T e2, T e3)
 
 VectorBase (const VectorBase< Dimension-1, T > &v, T s)
 Constructor for an instance of dimension N from an instance of dimension N-1 and a scalar of the correct type. More...
 
template<typename U >
 VectorBase (const VectorBase< Dimension, U > &v)
 Copy constructor from an instance of the same Dimension and any value type that is compatible (via static_cast) with this instance's type. More...
 
void Add (const VectorBase &v)
 Derived classes use these protected functions to implement type-safe functions and operators. More...
 
void Subtract (const VectorBase &v)
 Self-modifying subtraction. More...
 
void Multiply (T s)
 Self-modifying multiplication by a scalar. More...
 
void Divide (T s)
 Self-modifying division by a scalar. More...
 
const VectorBase Negation () const
 Unary negation. More...
 

Static Protected Member Functions

static const VectorBase Zero ()
 Returns an instance containing all zeroes. More...
 
static const VectorBase Fill (T value)
 Returns an instance with all elements set to the given value. More...
 
static const VectorBase Product (const VectorBase &v0, const VectorBase &v1)
 Binary component-wise multiplication. More...
 
static const VectorBase Quotient (const VectorBase &v0, const VectorBase &v1)
 Binary component-wise division. More...
 
static const VectorBase Sum (const VectorBase &v0, const VectorBase &v1)
 Binary component-wise addition. More...
 
static const VectorBase Difference (const VectorBase &v0, const VectorBase &v1)
 Binary component-wise subtraction. More...
 
static const VectorBase Scale (const VectorBase &v, T s)
 Binary multiplication by a scalar. More...
 
static const VectorBase Divide (const VectorBase &v, T s)
 Binary division by a scalar. More...
 

Detailed Description

template<int Dimension, typename T>
class ion::math::VectorBase< Dimension, T >

VectorBase.

VectorBase is a base class for the Vector and Point classes.

Definition at line 43 of file vector.h.

Member Typedef Documentation

template<int Dimension, typename T>
typedef T ion::math::VectorBase< Dimension, T >::ValueType

Definition at line 47 of file vector.h.

Member Enumeration Documentation

template<int Dimension, typename T>
anonymous enum

The dimension of the vector (number of elements).

Enumerator
kDimension 

Definition at line 46 of file vector.h.

Constructor & Destructor Documentation

template<int Dimension, typename T>
ion::math::VectorBase< Dimension, T >::VectorBase ( )
inlineprotected
template<int Dimension, typename T >
ion::math::VectorBase< Dimension, T >::VectorBase ( T  e0)
explicitprotected

VectorBase implementation.

Definition at line 419 of file vector.h.

References ION_STATIC_ASSERT.

template<int Dimension, typename T >
ion::math::VectorBase< Dimension, T >::VectorBase ( T  e0,
T  e1 
)
protected

Definition at line 425 of file vector.h.

References ION_STATIC_ASSERT.

template<int Dimension, typename T >
ion::math::VectorBase< Dimension, T >::VectorBase ( T  e0,
T  e1,
T  e2 
)
protected

Definition at line 432 of file vector.h.

References ION_STATIC_ASSERT.

template<int Dimension, typename T >
ion::math::VectorBase< Dimension, T >::VectorBase ( T  e0,
T  e1,
T  e2,
T  e3 
)
protected

Definition at line 440 of file vector.h.

References ION_STATIC_ASSERT.

template<int Dimension, typename T >
ion::math::VectorBase< Dimension, T >::VectorBase ( const VectorBase< Dimension-1, T > &  v,
T  s 
)
protected

Constructor for an instance of dimension N from an instance of dimension N-1 and a scalar of the correct type.

This is defined only when Dimension is at least 2.

Definition at line 449 of file vector.h.

References ION_STATIC_ASSERT.

template<int Dimension, typename T >
template<typename U >
ion::math::VectorBase< Dimension, T >::VectorBase ( const VectorBase< Dimension, U > &  v)
explicitprotected

Copy constructor from an instance of the same Dimension and any value type that is compatible (via static_cast) with this instance's type.

Definition at line 458 of file vector.h.

Member Function Documentation

template<int Dimension, typename T >
void ion::math::VectorBase< Dimension, T >::Add ( const VectorBase< Dimension, T > &  v)
protected

Derived classes use these protected functions to implement type-safe functions and operators.

Self-modifying addition.

Definition at line 606 of file vector.h.

Referenced by ion::math::Vector< 4, T >::operator+=().

template<int Dimension, typename T >
bool ion::math::VectorBase< Dimension, T >::AreValuesEqual ( const VectorBase< Dimension, T > &  v0,
const VectorBase< Dimension, T > &  v1 
)
static

Returns true if all values in two instances are equal.

Definition at line 694 of file vector.h.

template<int Dimension, typename T>
T* ion::math::VectorBase< Dimension, T >::Data ( )
inline

Returns a pointer to the data for interfacing with other libraries.

Definition at line 79 of file vector.h.

template<int Dimension, typename T>
const T* ion::math::VectorBase< Dimension, T >::Data ( ) const
inline

Definition at line 80 of file vector.h.

template<int Dimension, typename T >
const VectorBase< Dimension, T > ion::math::VectorBase< Dimension, T >::Difference ( const VectorBase< Dimension, T > &  v0,
const VectorBase< Dimension, T > &  v1 
)
staticprotected

Binary component-wise subtraction.

Definition at line 667 of file vector.h.

template<int Dimension, typename T >
void ion::math::VectorBase< Dimension, T >::Divide ( T  s)
protected

Self-modifying division by a scalar.

Definition at line 624 of file vector.h.

Referenced by ion::math::Vector< 4, T >::operator/=().

template<int Dimension, typename T >
const VectorBase< Dimension, T > ion::math::VectorBase< Dimension, T >::Divide ( const VectorBase< Dimension, T > &  v,
T  s 
)
staticprotected

Binary division by a scalar.

Definition at line 685 of file vector.h.

template<int Dimension, typename T >
const VectorBase< Dimension, T > ion::math::VectorBase< Dimension, T >::Fill ( T  value)
staticprotected

Returns an instance with all elements set to the given value.

Definition at line 573 of file vector.h.

Referenced by ion::math::Vector< 4, T >::Fill().

template<int Dimension, typename T >
void ion::math::VectorBase< Dimension, T >::Multiply ( T  s)
protected

Self-modifying multiplication by a scalar.

Definition at line 618 of file vector.h.

Referenced by ion::math::Vector< 4, T >::operator*=().

template<int Dimension, typename T >
const VectorBase< Dimension, T > ion::math::VectorBase< Dimension, T >::Negation ( ) const
protected

Unary negation.

Definition at line 632 of file vector.h.

Referenced by ion::math::Vector< 4, T >::operator-().

template<int Dimension, typename T>
T& ion::math::VectorBase< Dimension, T >::operator[] ( int  index)
inline

Mutable element accessor.

Definition at line 56 of file vector.h.

References DCHECK.

template<int Dimension, typename T>
const T& ion::math::VectorBase< Dimension, T >::operator[] ( int  index) const
inline

Read-only element accessor.

Definition at line 66 of file vector.h.

References DCHECK.

template<int Dimension, typename T>
void ion::math::VectorBase< Dimension, T >::Print ( std::ostream &  out,
const char  tag 
) const
inline

This is used for printing Vectors and Points to a stream.

Definition at line 83 of file vector.h.

Referenced by ion::math::operator<<().

template<int Dimension, typename T >
const VectorBase< Dimension, T > ion::math::VectorBase< Dimension, T >::Product ( const VectorBase< Dimension, T > &  v0,
const VectorBase< Dimension, T > &  v1 
)
staticprotected

Binary component-wise multiplication.

Definition at line 640 of file vector.h.

template<int Dimension, typename T >
const VectorBase< Dimension, T > ion::math::VectorBase< Dimension, T >::Quotient ( const VectorBase< Dimension, T > &  v0,
const VectorBase< Dimension, T > &  v1 
)
staticprotected

Binary component-wise division.

Definition at line 649 of file vector.h.

template<int Dimension, typename T>
template<char tag>
void ion::math::VectorBase< Dimension, T >::Read ( std::istream &  in)
inline

This is used for reading Vectors and Points from a stream.

Definition at line 95 of file vector.h.

References ion::base::GetExpectedChar().

template<int Dimension, typename T >
const VectorBase< Dimension, T > ion::math::VectorBase< Dimension, T >::Scale ( const VectorBase< Dimension, T > &  v,
T  s 
)
staticprotected

Binary multiplication by a scalar.

Definition at line 676 of file vector.h.

template<int Dimension, typename T >
void ion::math::VectorBase< Dimension, T >::Set ( T  e0)

Sets the vector values.

Definition at line 464 of file vector.h.

References ION_STATIC_ASSERT.

Referenced by ion::math::Rotation< T >::Rotation(), and ion::math::ScaleRangeNonUniformly().

template<int Dimension, typename T >
void ion::math::VectorBase< Dimension, T >::Set ( T  e0,
T  e1 
)

Definition at line 470 of file vector.h.

References ION_STATIC_ASSERT.

template<int Dimension, typename T >
void ion::math::VectorBase< Dimension, T >::Set ( T  e0,
T  e1,
T  e2 
)

Definition at line 477 of file vector.h.

References ION_STATIC_ASSERT.

template<int Dimension, typename T >
void ion::math::VectorBase< Dimension, T >::Set ( T  e0,
T  e1,
T  e2,
T  e3 
)

Definition at line 485 of file vector.h.

References ION_STATIC_ASSERT.

template<int Dimension, typename T >
void ion::math::VectorBase< Dimension, T >::Subtract ( const VectorBase< Dimension, T > &  v)
protected

Self-modifying subtraction.

Definition at line 612 of file vector.h.

Referenced by ion::math::Vector< 4, T >::operator-=().

template<int Dimension, typename T >
const VectorBase< Dimension, T > ion::math::VectorBase< Dimension, T >::Sum ( const VectorBase< Dimension, T > &  v0,
const VectorBase< Dimension, T > &  v1 
)
staticprotected

Binary component-wise addition.

Definition at line 658 of file vector.h.

template<int Dimension, typename T >
const VectorBase< Dimension, T > ion::math::VectorBase< Dimension, T >::Zero ( )
staticprotected

Returns an instance containing all zeroes.

Zero, Fill, and the Vector::Axis? functions use the above static methods.

Definition at line 566 of file vector.h.

Referenced by ion::math::Vector< 4, T >::Zero().


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