14 #ifdef WITH_CXX_GUARDEDALLOC
40 template<
class T,
unsigned N>
class Vec {
47 for (
unsigned int i = 0; i <
N; i++) {
57 template<
class U>
explicit inline Vec(
const U tab[
N])
59 for (
unsigned int i = 0; i <
N; i++) {
64 template<
class U>
explicit inline Vec(
const std::vector<U> &tab)
66 for (
unsigned int i = 0; i <
N; i++) {
73 for (
unsigned int i = 0; i <
N; i++) {
89 static inline unsigned dim()
102 return (*
this) * (*this);
108 for (
unsigned int i = 0; i <
N; i++) {
118 for (
unsigned int i = 0; i <
N; i++) {
160 for (
unsigned int i = 0; i <
N; i++) {
161 sum += (*this)[i] *
v[i];
169 for (
unsigned int i = 0; i <
N; i++) {
178 for (
unsigned int i = 0; i <
N; i++) {
186 for (
unsigned int i = 0; i <
N; i++) {
194 for (
unsigned int i = 0; i <
N; i++) {
203 for (
unsigned int i = 0; i <
N; i++) {
212 for (
unsigned int i = 0; i <
N; i++) {
222 for (
unsigned int i = 0; i <
N; i++) {
232 for (
unsigned int i = 0; i <
N; i++) {
248 for (
unsigned int i = 0; i <
N; i++) {
268 #ifdef WITH_CXX_GUARDEDALLOC
269 MEM_CXX_CLASS_ALLOC_FUNCS(
"Freestyle:VecMat:Vec")
279 template<
class T>
class Vec2 :
public Vec<T, 2> {
287 template<
class U>
explicit inline Vec2(
const U tab[2]) :
Vec<
T, 2>(tab)
291 template<
class U>
explicit inline Vec2(
const std::vector<U> &tab) :
Vec<
T, 2>(tab)
301 this->_coord[0] = (
T)
x;
302 this->_coord[1] = (
T)
y;
307 return this->_coord[0];
312 return this->_coord[0];
317 return this->_coord[1];
322 return this->_coord[1];
370 for (
unsigned int i = 0; i < 2; i++) {
371 sum += (*this)[i] *
v[i];
391 template<
class U>
explicit inline HVec3(
const U tab[4]) :
Vec<
T, 4>(tab)
395 template<
class U>
explicit inline HVec3(
const std::vector<U> &tab) :
Vec<
T, 4>(tab)
408 this->_coord[0] =
sx;
409 this->_coord[1] =
sy;
410 this->_coord[2] =
sz;
416 this->_coord[0] = (
T)sv[0];
417 this->_coord[1] = (
T)sv[1];
418 this->_coord[2] = (
T)sv[2];
419 this->_coord[3] = (
T)
s;
424 return this->_coord[0];
429 return this->_coord[0];
434 return this->_coord[1];
439 return this->_coord[1];
444 return this->_coord[2];
449 return this->_coord[2];
454 return this->_coord[3];
459 return this->_coord[3];
465 return this->_coord[0] / this->_coord[3];
470 return this->_coord[1] / this->_coord[3];
475 return this->_coord[2] / this->_coord[3];
484 template<
class T>
class Vec3 :
public Vec<T, 3> {
492 template<
class U>
explicit inline Vec3(
const U tab[3]) :
Vec<
T, 3>(tab)
496 template<
class U>
explicit inline Vec3(
const std::vector<U> &tab) :
Vec<
T, 3>(tab)
506 this->_coord[0] = (
T)
v.x();
507 this->_coord[1] = (
T)
v.y();
508 this->_coord[2] = (
T)
v.z();
520 return this->_coord[0];
525 return this->_coord[0];
530 return this->_coord[1];
535 return this->_coord[1];
540 return this->_coord[2];
545 return this->_coord[2];
599 for (
unsigned int i = 0; i < 3; i++) {
600 sum += (*this)[i] *
v[i];
609 Vec3<T> res((*
this)[1] *
v[2] - (*
this)[2] *
v[1],
610 (*
this)[2] *
v[0] - (*
this)[0] *
v[2],
611 (*
this)[0] *
v[1] - (*
this)[1] *
v[0]);
618 Vec3<T> res((*
this)[1] *
v[2] - (*
this)[2] *
v[1],
619 (*
this)[2] *
v[0] - (*
this)[0] *
v[2],
620 (*
this)[0] *
v[1] - (*
this)[1] *
v[0]);
634 #define _SIZE (M * N)
636 template<
class T,
unsigned M,
unsigned N>
class Matrix {
642 for (
unsigned int i = 0; i <
_SIZE; i++) {
655 for (
unsigned int i = 0; i <
_SIZE; i++) {
656 this->_coord[i] = tab[i];
660 template<
class U>
explicit inline Matrix(
const std::vector<U> &tab)
662 for (
unsigned int i = 0; i <
_SIZE; i++) {
663 this->_coord[i] = tab[i];
669 for (
unsigned int i = 0; i <
M; i++) {
670 for (
unsigned int j = 0; j <
N; j++) {
671 this->_coord[i *
N + j] = (
T)m(i, j);
678 return this->_coord[i *
N + j];
683 return this->_coord[i *
N + j];
699 for (
unsigned int i = 0; i <
M; i++) {
700 for (
unsigned int j = 0; j <
N; j++) {
701 res(j, i) = this->_coord[i *
N + j];
711 for (
unsigned int i = 0; i <
M; i++) {
712 for (
unsigned int j = 0; j <
N; j++) {
713 this->_coord[i *
N + j] = (
T)m(i, j);
722 for (
unsigned int i = 0; i <
M; i++) {
723 for (
unsigned int j = 0; j <
N; j++) {
724 this->_coord[i *
N + j] += (
T)m(i, j);
732 for (
unsigned int i = 0; i <
M; i++) {
733 for (
unsigned int j = 0; j <
N; j++) {
734 this->_coord[i *
N + j] -= (
T)m(i, j);
742 for (
unsigned int i = 0; i <
M; i++) {
743 for (
unsigned int j = 0; j <
N; j++) {
744 this->_coord[i *
N + j] *= lambda;
753 for (
unsigned int i = 0; i <
M; i++) {
754 for (
unsigned int j = 0; j <
N; j++) {
755 this->_coord[i *
N + j] /= lambda;
765 #ifdef WITH_CXX_GUARDEDALLOC
766 MEM_CXX_CLASS_ALLOC_FUNCS(
"Freestyle:VecMat:Matrix")
780 #define _SIZE (N * N)
805 for (
unsigned int i = 0; i <
N; i++) {
820 template<
class T,
unsigned N>
inline Vec<T, N>
operator+(
const Vec<T, N> &
v1,
const Vec<T, N> &
v2)
827 template<
class T,
unsigned N>
inline Vec<T, N>
operator-(
const Vec<T, N> &
v1,
const Vec<T, N> &
v2)
834 template<
class T,
unsigned N>
843 template<
class T,
unsigned N>
852 template<
class T,
unsigned N>
863 template<
class T,
unsigned N>
867 for (
unsigned int i = 0; i <
N; i++) {
874 template<
typename T>
inline Vec3<T>
operator^(
const Vec<T, 3> &
v1,
const Vec<T, 3> &
v2)
887 for (i = 0; i <
N - 1; i++) {
899 template<
class T,
unsigned M,
unsigned N>
907 template<
class T,
unsigned M,
unsigned N>
915 template<
class T,
unsigned M,
unsigned N>
924 template<
class T,
unsigned M,
unsigned N>
933 template<
class T,
unsigned M,
unsigned N>
942 template<
class T,
unsigned M,
unsigned N,
unsigned P>
945 unsigned int i, j, k;
949 for (j = 0; j <
P; j++) {
950 for (k = 0; k <
N; k++) {
952 for (i = 0; i <
N; i++) {
953 res(i, j) += m1(i, k) * scale;
960 template<
class T,
unsigned M,
unsigned N>
966 for (
unsigned int j = 0; j <
M; j++) {
968 for (
unsigned int i = 0; i <
N; i++) {
969 res[i] += m(i, j) * scale;
976 template<
class T,
unsigned M,
unsigned N>
980 for (i = 0; i <
M; i++) {
982 for (j = 0; j <
N - 1; j++) {
983 s << m(i, j) <<
", ";
985 s << m(i, j) <<
"]" << std::endl;
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Read Guarded memory(de)allocation.
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
static T sum(const btAlignedObjectArray< T > &items)
HVec3(const Vec< U, 4 > &v)
HVec3(const std::vector< U > &tab)
HVec3(const Vec< U, 3 > &sv, const U s=1)
HVec3(const value_type sx, const value_type sy=0, const value_type sz=0, const value_type s=1)
Vec< T, 4 >::value_type value_type
Matrix< T, M, N > & operator+=(const Matrix< U, M, N > &m)
Matrix(const std::vector< U > &tab)
Matrix(const Matrix< U, M, N > &m)
Matrix< T, M, N > & operator=(const Matrix< U, M, N > &m)
Matrix< T, M, N > & operator-=(const Matrix< U, M, N > &m)
Matrix(const U tab[_SIZE])
Matrix< T, M, N > & transpose() const
Matrix< T, M, N > & operator/=(const U lambda)
Matrix< T, M, N > & operator*=(const U lambda)
value_type operator()(const unsigned i, const unsigned j) const
value_type & operator()(const unsigned i, const unsigned j)
static SquareMatrix< T, N > identity()
SquareMatrix(const std::vector< U > &tab)
SquareMatrix(const Matrix< U, N, N > &m)
SquareMatrix(const U tab[_SIZE])
value_type operator*(const Vec2< T > &v) const
void setX(const value_type v)
Vec2< T > operator*(const value_type r) const
Vec2< T > operator/(const value_type r) const
Vec2(const Vec< U, 2 > &v)
Vec2< T > operator-(const Vec2< T > &v) const
void setY(const value_type v)
Vec2< T > operator+(const Vec2< T > &v) const
Vec< T, 2 >::value_type value_type
Vec2(const value_type x, const value_type y=0)
Vec2(const std::vector< U > &tab)
Vec3< T > operator-(const Vec3< T > &v) const
Vec3(const std::vector< U > &tab)
void setX(const value_type v)
Vec3< T > operator^(const Vec< U, 3 > &v) const
value_type operator*(const Vec3< T > &v) const
void setY(const value_type v)
Vec< T, 3 >::value_type value_type
Vec3< T > operator*(const value_type r) const
Vec3(const value_type x, const value_type y=0, const value_type z=0)
Vec3(const HVec3< U > &v)
void setZ(const value_type v)
Vec3< T > operator+(const Vec3< T > &v) const
Vec3< T > operator^(const Vec3< T > &v) const
Vec3(const Vec< U, 3 > &v)
Vec3< T > operator/(const value_type r) const
value_type squareNorm() const
Vec< T, N > operator+(const Vec< T, N > &v) const
Vec< T, N > & operator/=(const U r)
Vec< T, N > & operator-=(const Vec< U, N > &v)
Vec< T, N > operator-(const Vec< T, N > &v) const
value_type operator[](const unsigned i) const
Vec< T, N > & normalizeSafe()
Vec< T, N > & operator+=(const Vec< U, N > &v)
Vec< T, N > & operator=(const Vec< U, N > &v)
Vec< T, N > & operator*=(const U r)
value_type & operator[](const unsigned i)
bool operator>(const Vec< T, N > &v) const
Vec< T, N > operator*(const typename Vec< T, N >::value_type r) const
Vec(const Vec< U, N > &v)
bool operator!=(const Vec< T, N > &v) const
Vec< T, N > operator/(const typename Vec< T, N >::value_type r) const
bool operator==(const Vec< T, N > &v) const
value_type operator*(const Vec< T, N > &v) const
Vec(const std::vector< U > &tab)
bool operator<(const Vec< T, N > &v) const
Vec< T, N > & normalize()
Matrix< T, M, N > operator-(const Matrix< T, M, N > &m1, const Matrix< T, M, N > &m2)
std::ostream & operator<<(std::ostream &s, const Vec< T, N > &v)
Matrix< T, M, N > operator/(const Matrix< T, M, N > &m1, const typename Matrix< T, M, N >::value_type lambda)
Vec< T, N > operator*(const typename Vec< T, N >::value_type r, const Vec< T, N > &v)
Matrix< T, M, N > operator+(const Matrix< T, M, N > &m1, const Matrix< T, M, N > &m2)
GPUState operator^(const GPUState &a, const GPUState &b)