gKit2 light
mat.h
Go to the documentation of this file.
1 
2 #ifndef _MAT_H
3 #define _MAT_H
4 
5 #include "vec.h"
6 
7 
10 
13 
15 float radians( const float deg );
17 float degrees( const float rad );
18 
20 struct Transform
21 {
23  Transform (
24  const float t00=1.f, const float t01=0.f, const float t02=0.f, const float t03=0.f,
25  const float t10=0.f, const float t11=1.f, const float t12=0.f, const float t13=0.f,
26  const float t20=0.f, const float t21=0.f, const float t22=1.f, const float t23=0.f,
27  const float t30=0.f, const float t31=0.f, const float t32=0.f, const float t33=1.f );
28 
30  Point operator() ( const Point& p ) const;
32  Vector operator() ( const Vector& v ) const;
34  vec4 operator() ( const vec4& v ) const;
35 
37  Transform transpose( ) const;
39  Transform inverse( ) const;
41  Transform normal( ) const;
42 
44  const float *buffer( ) const { return &m[0][0]; }
45 
46  float m[4][4];
47 };
48 
51 
53 Transform Transpose( const Transform& m );
55 Transform Inverse( const Transform& m );
57 Transform Normal( const Transform& m );
58 
60 Transform Scale( const float x, const float y, const float z );
61 
63 Transform Translation( const Vector& v );
65 Transform Translation( const float x, const float y, const float z );
66 
68 Transform RotationX( const float angle );
70 Transform RotationY( const float angle );
72 Transform RotationZ( const float angle );
74 Transform Rotation( const Vector& axis, const float angle );
75 
77 Transform Viewport( const float width, const float height );
79 Transform Perspective( const float fov, const float aspect, const float znear, const float zfar );
81 Transform Lookat( const Point& from, const Point& to, const Vector& up );
82 
84 Transform compose_transform( const Transform& a, const Transform& b );
86 Transform operator* ( const Transform& a, const Transform& b );
87 
89 #endif
float degrees(const float rad)
conversion en degres.
Definition: mat.cpp:17
Transform(const float t00=1.f, const float t01=0.f, const float t02=0.f, const float t03=0.f, const float t10=0.f, const float t11=1.f, const float t12=0.f, const float t13=0.f, const float t20=0.f, const float t21=0.f, const float t22=1.f, const float t23=0.f, const float t30=0.f, const float t31=0.f, const float t32=0.f, const float t33=1.f)
constructeur.
Definition: mat.cpp:23
Transform inverse() const
renvoie l'inverse de la matrice.
Definition: mat.cpp:263
Transform Transpose(const Transform &m)
renvoie la transposee de la matrice.
Definition: mat.cpp:108
Transform normal() const
renvoie la transformation a appliquer aux normales d'un objet transforme par la matrice m...
Definition: mat.cpp:97
Transform operator*(const Transform &a, const Transform &b)
renvoie la composition des transformations a et b, t = a * b.
Definition: mat.cpp:258
Point operator()(const Point &p) const
renvoie le point transforme.
Definition: mat.cpp:36
Transform Identity()
construit la transformation identite.
Definition: mat.cpp:103
Transform Viewport(const float width, const float height)
renvoie la matrice representant une transformation viewport.
Definition: mat.cpp:221
vecteur generique 4d, ou 3d homogene, utilitaire.
Definition: vec.h:121
float radians(const float deg)
conversion en radians.
Definition: mat.cpp:11
Transform Normal(const Transform &m)
renvoie la transformation a appliquer aux normales d'un objet transforme par la matrice m...
Definition: mat.cpp:118
Transform Inverse(const Transform &m)
renvoie l'inverse de la matrice.
Definition: mat.cpp:113
representation d'un vecteur 3d.
Definition: vec.h:42
Transform transpose() const
renvoie la transposee de la matrice.
Definition: mat.cpp:87
Transform RotationX(const float angle)
renvoie la matrice representation une rotation de angle degree autour de l'axe X. ...
Definition: mat.cpp:146
Transform Lookat(const Point &from, const Point &to, const Vector &up)
renvoie la matrice representant le placement et l'orientation d'une camera pour observer le point to...
Definition: mat.cpp:233
Transform Rotation(const Vector &axis, const float angle)
renvoie la matrice representation une rotation de angle degree autour de l'axe axis.
Definition: mat.cpp:182
Transform compose_transform(const Transform &a, const Transform &b)
renvoie la composition des transformations a et b, t= a * b.
Definition: mat.cpp:248
const float * buffer() const
renvoie l'adresse de la premiere valeur de la matrice.
Definition: mat.h:44
Transform Scale(const float x, const float y, const float z)
renvoie la matrice representant une mise a l'echelle / etirement.
Definition: mat.cpp:123
Transform Translation(const Vector &v)
renvoie la matrice representant une translation par un vecteur.
Definition: mat.cpp:132
Transform RotationZ(const float angle)
renvoie la matrice representation une rotation de angle degree autour de l'axe Z. ...
Definition: mat.cpp:170
Transform Perspective(const float fov, const float aspect, const float znear, const float zfar)
renvoie la matrice representant une transformation projection perspective.
Definition: mat.cpp:208
representation d'une transformation, une matrice 4x4, organisee par ligne / row major.
Definition: mat.h:20
representation d'un point 3d.
Definition: vec.h:19
Transform RotationY(const float angle)
renvoie la matrice representation une rotation de a degree autour de l'axe Y.
Definition: mat.cpp:158