OGLplus (0.52.0) a C++ wrapper for OpenGL

Basic template for vector types. More...

#include </home/chochlik/devel/oglplus/include/oglplus/math/vector.hpp>

Inheritance diagram for oglplus::Vector< T, N >:
Collaboration diagram for oglplus::Vector< T, N >:

Public Member Functions

 Vector (void)
 Default construction, initializes all components to zero.
 
template<typename U , size_t M>
 Vector (const Vector< U, M > &vector)
 Copy construction from a vector with different element type.
 
 Vector (const T(&v)[N])
 Initialization from C-array.
 
 Vector (const T *v, std::size_t n)
 Initialization from pointer and size.
 
 Vector (const T *v, std::size_t n, T def)
 Initialization from poiner, size and a default value.
 
 Vector (T v)
 Initialization of all components by v.
 
template<typename... P>
 Vector (P...vn)
 Initialization from N values.
 
template<typename... P>
 Vector (const Vector< T, M > &a, P...p)
 Initialization from a vector of smaller dimension and additional values.
 
 Vector (const Matrix< T, 1, N > &matrix)
 Construction from to Matrix-1xN.
 
 Vector (const Matrix< T, N, 1 > &matrix)
 Construction from to Matrix-Nx1.
 
T At (const Vector &vector, std::size_t i) const T x(void) const
 Returns the value of the i-th coordinate of the vector. More...
 
T y (void) const
 Returns the 1-st component.
 
T z (void) const
 Returns the 2-nd component.
 
T w (void) const
 Returns the 3-nd component.
 
Vector< T, 2 > xy (void) const
 Returns a subvector with the first two components.
 
Vector< T, 3 > xyz (void) const
 Returns a subvector with the first three components.
 
Vectoroperator+= (const Vector &v)
 Adds a vector to this vector.
 
Vectoroperator-= (const Vector &v)
 Subtracts a vector from this vector.
 
Vectoroperator*= (T v)
 Multiples this vector by a scalar value.
 
Vectoroperator/= (T v)
 Divides this vector by a scalar value.
 
TData (void)
 Pointer to the components of this vector.
 
const TData (void) const
 Pointer to the components of this vector.
 
T At (std::size_t i) const
 Access to the i-th component of this vector. More...
 
T At (std::size_t i, T fallback) const
 Access to the i-th component of this vector with a fallback. More...
 
Toperator[] (std::size_t i)
 Access to the i-th component of this vector. More...
 
const Toperator[] (std::size_t i) const
 Const access to the i-th component of this vector. More...
 
void Add (const VectorBase &v)
 Adds v to this vector.
 
void Subtract (const VectorBase &v)
 Subtracts v from this vector.
 
void Multiply (T v)
 Multiplies this vector by a scalar value.
 
void Multiply (const VectorBase &that)
 Multiplies the elements of this and that vector.
 
void Divide (T v)
 Divides this vector by a scalar value.
 
void Divide (const VectorBase &that)
 Divides the elements of this and that vector.
 
T Length (void) const
 Returns the lenght of this vector.
 
bool IsNormal (T eps=T(0)) const
 Returns true if the vector is normal.
 
void Normalize (void)
 Normalizes this vector.
 

Static Public Member Functions

static Vector Unit (std::size_t axis)
 Construction of a unit vector aligned with the specified axis.
 
static std::size_t Size (void)
 The size (the number of components) of this vector.
 
static T DotProduct (const VectorBase &a, const VectorBase &b)
 Computes the dot product of vectors a and b.
 

Friends

std::size_t Size (const Vector &a)
 Returns the dimension of the vector.
 
const TData (const Vector &vector)
 Returns a pointer to an array containing the vectors coordinates.
 
Vector Negated (const Vector &a)
 Returns a new vector that is a negation of vector a.
 
Vector operator+ (const Vector &a)
 Identity operator.
 
Vector operator- (const Vector &a)
 Negation operator.
 
Vector Added (const Vector &a, const Vector &b)
 Adds two vectors.
 
Vector operator+ (const Vector &a, const Vector &b)
 Vector addition operator.
 
Vector Subtracted (const Vector &a, const Vector &b)
 Subtracts two vectors.
 
Vector operator- (const Vector &a, const Vector &b)
 Vector subtration operator.
 
Vector Multiplied (const Vector &a, T v)
 Multiples a vector by a scalar value.
 
Vector operator* (const Vector &a, T v)
 Operator for multiplication by a scalar value.
 
Vector operator* (T v, const Vector &a)
 Operator for multiplication by a scalar value.
 
Vector Divided (const Vector &a, T v)
 Divides a vector by a scalar value.
 
Vector operator/ (const Vector &a, T v)
 Operator for division by a scalar value.
 
T Dot (const Vector &a, const Vector &b)
 Dot product of two vectors.
 
T Length (const Vector &a)
 Returns the length of a vector.
 
T Distance (const Vector &a, const Vector &b)
 Returns the distance between two vectors.
 
Vector Normalized (Vector a)
 Returns a normalized version of the vector passed as argument.
 
template<std::size_t Cols>
Vector< T, Cols > operator* (const Vector &v, const Matrix< T, N, Cols > &m)
 Vector by Matrix multiplication operator.
 
template<std::size_t Rows>
Vector< T, Rows > operator* (const Matrix< T, Rows, N > &m, const Vector &v)
 Matrix by Vector multiplication operator.
 

Detailed Description

template<typename T, std::size_t N>
class oglplus::Vector< T, N >

Basic template for vector types.

.file oglplus/math/vector_n.ipp .brief A generalized vector template

Author
Matus Chochlik

Copyright 2010-2014 Matus Chochlik. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Template Parameters
Tthe coordinate value type
Nthe dimension of the Vector
See Also
Matrix
Examples:
standalone/001_shape2dot.cpp, and standalone/026_blender_mesh_loader.cpp.

Member Function Documentation

template<typename T, std::size_t N>
T oglplus::Vector< T, N >::At ( const Vector< T, N > &  vector,
std::size_t  i 
) const

Returns the value of the i-th coordinate of the vector.

Parameters
vectorthe vector to operate on
ithe index of the coordinate to be retrieved
Precondition
(i < Size())Returns the 0-th component
template<typename T, std::size_t N>
T oglplus::VectorBase< T, N >::At ( std::size_t  i) const
inherited

Access to the i-th component of this vector.

Precondition
(i < Size())
template<typename T, std::size_t N>
T oglplus::VectorBase< T, N >::At ( std::size_t  i,
T  fallback 
) const
inherited

Access to the i-th component of this vector with a fallback.

Similar to At(i), but returns fallback if i is greater than or equal to Size().

template<typename T, std::size_t N>
T& oglplus::VectorBase< T, N >::operator[] ( std::size_t  i)
inherited

Access to the i-th component of this vector.

Precondition
(i < Size())
template<typename T, std::size_t N>
const T& oglplus::VectorBase< T, N >::operator[] ( std::size_t  i) const
inherited

Const access to the i-th component of this vector.

Precondition
(i < Size())

The documentation for this class was generated from the following files:
  • /home/chochlik/devel/oglplus/include/oglplus/fwd.hpp
  • /home/chochlik/devel/oglplus/include/oglplus/math/vector.hpp

Copyright © 2010-2014 Matúš Chochlík, University of Žilina, Žilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Mon Sep 22 2014 by Doxygen (version 1.8.6).