28 #ifdef WITH_CXX_GUARDEDALLOC
54 template<
class T,
unsigned N>
class Vec {
61 for (
unsigned int i = 0; i <
N; i++) {
71 template<
class U>
explicit inline Vec(
const U tab[
N])
73 for (
unsigned int i = 0; i <
N; i++) {
78 template<
class U>
explicit inline Vec(
const std::vector<U> &tab)
80 for (
unsigned int i = 0; i <
N; i++) {
87 for (
unsigned int i = 0; i <
N; i++) {
103 static inline unsigned dim()
116 return (*
this) * (*this);
122 for (
unsigned int i = 0; i <
N; i++) {
132 for (
unsigned int i = 0; i <
N; i++) {
174 for (
unsigned int i = 0; i <
N; i++) {
175 sum += (*this)[i] *
v[i];
183 for (
unsigned int i = 0; i <
N; i++) {
192 for (
unsigned int i = 0; i <
N; i++) {
200 for (
unsigned int i = 0; i <
N; i++) {
208 for (
unsigned int i = 0; i <
N; i++) {
217 for (
unsigned int i = 0; i <
N; i++) {
226 for (
unsigned int i = 0; i <
N; i++) {
236 for (
unsigned int i = 0; i <
N; i++) {
246 for (
unsigned int i = 0; i <
N; i++) {
262 for (
unsigned int i = 0; i <
N; i++) {
282 #ifdef WITH_CXX_GUARDEDALLOC
283 MEM_CXX_CLASS_ALLOC_FUNCS(
"Freestyle:VecMat:Vec")
293 template<
class T>
class Vec2 :
public Vec<T, 2> {
301 template<
class U>
explicit inline Vec2(
const U tab[2]) :
Vec<
T, 2>(tab)
305 template<
class U>
explicit inline Vec2(
const std::vector<U> &tab) :
Vec<
T, 2>(tab)
315 this->_coord[0] = (
T)
x;
316 this->_coord[1] = (
T)
y;
321 return this->_coord[0];
326 return this->_coord[0];
331 return this->_coord[1];
336 return this->_coord[1];
384 for (
unsigned int i = 0; i < 2; i++) {
385 sum += (*this)[i] *
v[i];
405 template<
class U>
explicit inline HVec3(
const U tab[4]) :
Vec<
T, 4>(tab)
409 template<
class U>
explicit inline HVec3(
const std::vector<U> &tab) :
Vec<
T, 4>(tab)
422 this->_coord[0] =
sx;
423 this->_coord[1] =
sy;
424 this->_coord[2] =
sz;
430 this->_coord[0] = (
T)sv[0];
431 this->_coord[1] = (
T)sv[1];
432 this->_coord[2] = (
T)sv[2];
433 this->_coord[3] = (
T)
s;
438 return this->_coord[0];
443 return this->_coord[0];
448 return this->_coord[1];
453 return this->_coord[1];
458 return this->_coord[2];
463 return this->_coord[2];
468 return this->_coord[3];
473 return this->_coord[3];
479 return this->_coord[0] / this->_coord[3];
484 return this->_coord[1] / this->_coord[3];
489 return this->_coord[2] / this->_coord[3];
498 template<
class T>
class Vec3 :
public Vec<T, 3> {
506 template<
class U>
explicit inline Vec3(
const U tab[3]) :
Vec<
T, 3>(tab)
510 template<
class U>
explicit inline Vec3(
const std::vector<U> &tab) :
Vec<
T, 3>(tab)
520 this->_coord[0] = (
T)
v.x();
521 this->_coord[1] = (
T)
v.y();
522 this->_coord[2] = (
T)
v.z();
534 return this->_coord[0];
539 return this->_coord[0];
544 return this->_coord[1];
549 return this->_coord[1];
554 return this->_coord[2];
559 return this->_coord[2];
613 for (
unsigned int i = 0; i < 3; i++) {
614 sum += (*this)[i] *
v[i];
623 Vec3<T> res((*
this)[1] *
v[2] - (*
this)[2] *
v[1],
624 (*
this)[2] *
v[0] - (*
this)[0] *
v[2],
625 (*
this)[0] *
v[1] - (*
this)[1] *
v[0]);
632 Vec3<T> res((*
this)[1] *
v[2] - (*
this)[2] *
v[1],
633 (*
this)[2] *
v[0] - (*
this)[0] *
v[2],
634 (*
this)[0] *
v[1] - (*
this)[1] *
v[0]);
648 #define _SIZE (M * N)
650 template<
class T,
unsigned M,
unsigned N>
class Matrix {
656 for (
unsigned int i = 0; i <
_SIZE; i++) {
669 for (
unsigned int i = 0; i <
_SIZE; i++) {
670 this->_coord[i] = tab[i];
674 template<
class U>
explicit inline Matrix(
const std::vector<U> &tab)
676 for (
unsigned int i = 0; i <
_SIZE; i++) {
677 this->_coord[i] = tab[i];
683 for (
unsigned int i = 0; i <
M; i++) {
684 for (
unsigned int j = 0; j <
N; j++) {
685 this->_coord[i *
N + j] = (
T)m(i, j);
692 return this->_coord[i *
N + j];
697 return this->_coord[i *
N + j];
713 for (
unsigned int i = 0; i <
M; i++) {
714 for (
unsigned int j = 0; j <
N; j++) {
715 res(j, i) = this->_coord[i *
N + j];
725 for (
unsigned int i = 0; i <
M; i++) {
726 for (
unsigned int j = 0; j <
N; j++) {
727 this->_coord[i *
N + j] = (
T)m(i, j);
736 for (
unsigned int i = 0; i <
M; i++) {
737 for (
unsigned int j = 0; j <
N; j++) {
738 this->_coord[i *
N + j] += (
T)m(i, j);
746 for (
unsigned int i = 0; i <
M; i++) {
747 for (
unsigned int j = 0; j <
N; j++) {
748 this->_coord[i *
N + j] -= (
T)m(i, j);
756 for (
unsigned int i = 0; i <
M; i++) {
757 for (
unsigned int j = 0; j <
N; j++) {
758 this->_coord[i *
N + j] *= lambda;
767 for (
unsigned int i = 0; i <
M; i++) {
768 for (
unsigned int j = 0; j <
N; j++) {
769 this->_coord[i *
N + j] /= lambda;
779 #ifdef WITH_CXX_GUARDEDALLOC
780 MEM_CXX_CLASS_ALLOC_FUNCS(
"Freestyle:VecMat:Matrix")
794 #define _SIZE (N * N)
819 for (
unsigned int i = 0; i <
N; i++) {
834 template<
class T,
unsigned N>
inline Vec<T, N>
operator+(
const Vec<T, N> &
v1,
const Vec<T, N> &
v2)
841 template<
class T,
unsigned N>
inline Vec<T, N>
operator-(
const Vec<T, N> &
v1,
const Vec<T, N> &
v2)
848 template<
class T,
unsigned N>
857 template<
class T,
unsigned N>
866 template<
class T,
unsigned N>
877 template<
class T,
unsigned N>
881 for (
unsigned int i = 0; i <
N; i++) {
888 template<
typename T>
inline Vec3<T>
operator^(
const Vec<T, 3> &
v1,
const Vec<T, 3> &
v2)
901 for (i = 0; i <
N - 1; i++) {
913 template<
class T,
unsigned M,
unsigned N>
921 template<
class T,
unsigned M,
unsigned N>
929 template<
class T,
unsigned M,
unsigned N>
938 template<
class T,
unsigned M,
unsigned N>
947 template<
class T,
unsigned M,
unsigned N>
956 template<
class T,
unsigned M,
unsigned N,
unsigned P>
959 unsigned int i, j, k;
963 for (j = 0; j <
P; j++) {
964 for (k = 0; k <
N; k++) {
966 for (i = 0; i <
N; i++) {
967 res(i, j) += m1(i, k) * scale;
974 template<
class T,
unsigned M,
unsigned N>
980 for (
unsigned int j = 0; j <
M; j++) {
982 for (
unsigned int i = 0; i <
N; i++) {
983 res[i] += m(i, j) * scale;
990 template<
class T,
unsigned M,
unsigned N>
994 for (i = 0; i <
M; i++) {
996 for (j = 0; j <
N - 1; j++) {
997 s << m(i, j) <<
", ";
999 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)