gKit3
Loading...
Searching...
No Matches
Files | Classes | Functions
manipulations de points, vecteur, matrices, transformations

Files

file  mat.h
 
file  vec.h
 

Classes

struct  Transform
 representation d'une transformation, une matrice 4x4, organisee par ligne / row major. More...
 
struct  Point
 representation d'un point 3d. More...
 
struct  Vector
 representation d'un vecteur 3d. More...
 
struct  vec2
 vecteur generique, utilitaire. More...
 
struct  vec3
 vecteur generique, utilitaire. More...
 
struct  vec4
 vecteur generique 4d, ou 3d homogene, utilitaire. More...
 

Functions

float radians (const float deg)
 conversion en radians.
 
float degrees (const float rad)
 conversion en degres.
 
Transform Identity ()
 construit la transformation identite.
 
Transform Transpose (const Transform &m)
 renvoie la transposee de la matrice.
 
Transform Inverse (const Transform &m)
 renvoie l'inverse de la matrice.
 
Transform Normal (const Transform &m)
 renvoie la transformation a appliquer aux normales d'un objet transforme par la matrice m.
 
Transform Scale (const float x, const float y, const float z)
 renvoie la matrice representant une mise a l'echelle / etirement.
 
Transform Scale (const float s)
 
Transform Translation (const Vector &v)
 renvoie la matrice representant une translation par un vecteur.
 
Transform Translation (const float x, const float y, const float z)
 renvoie la matrice representant une translation par un vecteur x y z.
 
Transform RotationX (const float angle)
 renvoie la matrice representation une rotation de angle degree autour de l'axe X.
 
Transform RotationY (const float angle)
 renvoie la matrice representation une rotation de a degree autour de l'axe Y.
 
Transform RotationZ (const float angle)
 renvoie la matrice representation une rotation de angle degree autour de l'axe Z.
 
Transform Rotation (const Vector &axis, const float angle)
 renvoie la matrice representation une rotation de angle degree autour de l'axe axis.
 
Transform Rotation (const Vector &u, const Vector &v)
 renvoie la matrice de rotation entre u et v.
 
Transform Viewport (const float width, const float height)
 renvoie la matrice representant une transformation viewport.
 
Transform Perspective (const float fov, const float aspect, const float znear, const float zfar)
 renvoie la matrice representant une transformation projection perspective.
 
Transform Ortho (const float left, const float right, const float bottom, const float top, const float znear, const float zfar)
 renvoie la matrice representant une transformation orthographique, passage d'un cube []x[]x[] vers [-1 1]x[-1 1]x[-1 1].
 
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.
 
Transform compose_transform (const Transform &a, const Transform &b)
 renvoie la composition des transformations a et b, t= a * b.
 
Transform operator* (const Transform &a, const Transform &b)
 renvoie la composition des transformations a et b, t = a * b.
 
std::ostream & operator<< (std::ostream &o, const Transform &t)
 
Point Origin ()
 renvoie le point origine (0, 0, 0)
 
float distance (const Point &a, const Point &b)
 renvoie la distance etre 2 points.
 
float distance2 (const Point &a, const Point &b)
 renvoie le carre de la distance etre 2 points.
 
Point center (const Point &a, const Point &b)
 renvoie le milieu du segment ab.
 
Point min (const Point &a, const Point &b)
 renvoie la plus petite composante de chaque point. x, y, z= min(a.x, b.x), min(a.y, b.y), min(a.z, b.z).
 
Point max (const Point &a, const Point &b)
 renvoie la plus grande composante de chaque point. x, y, z= max(a.x, b.x), max(a.y, b.y), max(a.z, b.z).
 
Vector normalize (const Vector &v)
 renvoie un vecteur unitaire / longueur == 1.
 
Vector cross (const Vector &u, const Vector &v)
 renvoie le produit vectoriel de 2 vecteurs.
 
float dot (const Vector &u, const Vector &v)
 renvoie le produit scalaire de 2 vecteurs.
 
float length (const Vector &v)
 renvoie la longueur d'un vecteur.
 
float length2 (const Vector &v)
 renvoie la carre de la longueur d'un vecteur.
 
Vector operator- (const Point &a, const Point &b)
 renvoie le vecteur a - b.
 
Point operator+ (const Point &a, const Point &b)
 renvoie le "point" a + b.
 
Point operator* (const float k, const Point &a)
 renvoie le "point" k*a;
 
Point operator* (const Point &a, const float k)
 renvoie le "point" a*k;
 
Point operator/ (const Point &a, const float k)
 renvoie le "point" v/k;
 
Vector operator- (const Vector &v)
 renvoie le vecteur -v.
 
Point operator+ (const Point &a, const Vector &v)
 renvoie le point a+v.
 
Point operator+ (const Vector &v, const Point &a)
 renvoie le point a+v.
 
Point operator- (const Vector &v, const Point &a)
 renvoie le point a-v.
 
Point operator- (const Point &a, const Vector &v)
 renvoie le point a-v.
 
Vector operator+ (const Vector &u, const Vector &v)
 renvoie le vecteur u+v.
 
Vector operator- (const Vector &u, const Vector &v)
 renvoie le vecteur u-v.
 
Vector operator+ (const float k, const Vector &v)
 renvoie le vecteur u+k;
 
Vector operator+ (const Vector &v, const float k)
 
Vector operator* (const float k, const Vector &v)
 renvoie le vecteur k*u;
 
Vector operator* (const Vector &v, const float k)
 renvoie le vecteur k*v;
 
Vector operator* (const Vector &a, const Vector &b)
 renvoie le vecteur (a.x*b.x, a.y*b.y, a.z*b.z ).
 
Vector operator/ (const Vector &v, const float k)
 renvoie le vecteur v/k;
 
std::ostream & operator<< (std::ostream &o, const Point &p)
 
std::ostream & operator<< (std::ostream &o, const Vector &v)
 
 Point::Point (const vec3 &v)
 cree un point a partir des coordonnees du vecteur generique (v.x, v.y, v.z).
 
 Point::Point (const vec4 &v)
 
 Point::Point (const Vector &v)
 cree un point a partir des coordonnes du vecteur (v.x, v.y, v.z).
 
 Vector::Vector (const vec3 &v)
 cree un vecteur a partir des coordonnees du vecteur generique (v.x, v.y, v.z).
 
 Vector::Vector (const vec4 &v)
 
 Vector::Vector (const Point &a)
 cree un vecteur a partir des coordonnes du point (a.x, a.y, a.z).
 
 vec3::vec3 (const Point &a)
 cree un vecteur generique a partir des coordonnees du point a.
 
 vec3::vec3 (const Vector &v)
 cree un vecteur generique a partir des coordonnees du vecteur v.
 
 vec4::vec4 (const Point &a)
 cree un vecteur generique a partir des coordonnees du point a, (a.x, a.y, a.z, 1).
 
 vec4::vec4 (const Vector &v)
 cree un vecteur generique a partir des coordonnees du vecteur v, (v.x, v.y, v.z, 0).
 
float Point::operator() (const unsigned int i) const
 renvoie la ieme composante du point.
 
float Vector::operator() (const unsigned int i) const
 renvoie la ieme composante du vecteur.
 
float & Point::operator() (const unsigned int i)
 
float & Vector::operator() (const unsigned int i)
 

Detailed Description

Function Documentation

◆ radians()

float radians ( const float  deg)

conversion en radians.

Definition at line 10 of file mat.cpp.

11{
12 return ((float) M_PI / 180) * deg;
13}

◆ degrees()

float degrees ( const float  rad)

conversion en degres.

Definition at line 15 of file mat.cpp.

16{
17 return (180 / (float) M_PI) * rad;
18}

◆ Identity()

Transform Identity ( )

construit la transformation identite.

Definition at line 153 of file mat.cpp.

154{
155 return Transform();
156}
representation d'une transformation, une matrice 4x4, organisee par ligne / row major.
Definition mat.h:21

◆ Transpose()

Transform Transpose ( const Transform m)

renvoie la transposee de la matrice.

Definition at line 158 of file mat.cpp.

159{
160 return m.transpose();
161}
Transform transpose() const
renvoie la transposee de la matrice.
Definition mat.cpp:131

◆ Inverse()

Transform Inverse ( const Transform m)

renvoie l'inverse de la matrice.

Definition at line 163 of file mat.cpp.

164{
165 return m.inverse();
166}
Transform inverse() const
renvoie l'inverse de la matrice.
Definition mat.cpp:365

◆ Normal()

Transform Normal ( const Transform m)

renvoie la transformation a appliquer aux normales d'un objet transforme par la matrice m.

Definition at line 168 of file mat.cpp.

169{
170 return m.normal();
171}
Transform normal() const
renvoie la transformation a appliquer aux normales d'un objet transforme par la matrice m.
Definition mat.cpp:147

◆ Scale() [1/2]

Transform Scale ( const float  x,
const float  y,
const float  z 
)

renvoie la matrice representant une mise a l'echelle / etirement.

Definition at line 173 of file mat.cpp.

174{
175 return Transform(
176 x, 0, 0, 0,
177 0, y, 0, 0,
178 0, 0, z, 0,
179 0, 0, 0, 1);
180}

◆ Scale() [2/2]

Transform Scale ( const float  s)
inline

Definition at line 82 of file mat.h.

82{ return Scale(s, s, s); }
Transform Scale(const float x, const float y, const float z)
renvoie la matrice representant une mise a l'echelle / etirement.
Definition mat.cpp:173

◆ Translation() [1/2]

Transform Translation ( const Vector v)

renvoie la matrice representant une translation par un vecteur.

Definition at line 182 of file mat.cpp.

183{
184 return Transform(
185 1, 0, 0, v.x,
186 0, 1, 0, v.y,
187 0, 0, 1, v.z,
188 0, 0, 0, 1);
189}

◆ Translation() [2/2]

Transform Translation ( const float  x,
const float  y,
const float  z 
)

renvoie la matrice representant une translation par un vecteur x y z.

Definition at line 191 of file mat.cpp.

192{
193 return Translation( Vector(x, y, z) );
194}
Transform Translation(const Vector &v)
renvoie la matrice representant une translation par un vecteur.
Definition mat.cpp:182
representation d'un vecteur 3d.
Definition vec.h:58

◆ RotationX()

Transform RotationX ( const float  angle)

renvoie la matrice representation une rotation de angle degree autour de l'axe X.

Definition at line 196 of file mat.cpp.

197{
198 float sin_t= sinf(radians(a));
199 float cos_t= cosf(radians(a));
200
201 return Transform(
202 1, 0, 0, 0,
203 0, cos_t, -sin_t, 0,
204 0, sin_t, cos_t, 0,
205 0, 0, 0, 1 );
206}
float radians(const float deg)
conversion en radians.
Definition mat.cpp:10

◆ RotationY()

Transform RotationY ( const float  angle)

renvoie la matrice representation une rotation de a degree autour de l'axe Y.

Definition at line 208 of file mat.cpp.

209{
210 float sin_t= sinf(radians(a));
211 float cos_t= cosf(radians(a));
212
213 return Transform(
214 cos_t, 0, sin_t, 0,
215 0, 1, 0, 0,
216 -sin_t, 0, cos_t, 0,
217 0, 0, 0, 1 );
218}

◆ RotationZ()

Transform RotationZ ( const float  angle)

renvoie la matrice representation une rotation de angle degree autour de l'axe Z.

Definition at line 220 of file mat.cpp.

221{
222 float sin_t= sinf(radians(a));
223 float cos_t= cosf(radians(a));
224
225 return Transform(
226 cos_t, -sin_t, 0, 0,
227 sin_t, cos_t, 0, 0,
228 0, 0, 1, 0,
229 0, 0, 0, 1 );
230}

◆ Rotation() [1/2]

Transform Rotation ( const Vector axis,
const float  angle 
)

renvoie la matrice representation une rotation de angle degree autour de l'axe axis.

Definition at line 232 of file mat.cpp.

233{
234 Vector a= normalize(axis);
235 float s= sinf(radians(angle));
236 float c= cosf(radians(angle));
237
238 return Transform(
239 a.x * a.x + (1 - a.x * a.x ) * c,
240 a.x * a.y * (1 - c ) - a.z * s,
241 a.x * a.z * (1 - c ) + a.y * s,
242 0,
243
244 a.x * a.y * (1 - c ) + a.z * s,
245 a.y * a.y + (1 - a.y * a.y ) * c,
246 a.y * a.z * (1 - c ) - a.x * s,
247 0,
248
249 a.x * a.z * (1 - c ) - a.y * s,
250 a.y * a.z * (1 - c ) + a.x * s,
251 a.z * a.z + (1 - a.z * a.z ) * c,
252 0,
253
254 0, 0, 0, 1);
255}
Vector normalize(const Vector &v)
renvoie un vecteur unitaire / longueur == 1.
Definition vec.cpp:133

◆ Rotation() [2/2]

Transform Rotation ( const Vector u,
const Vector v 
)

renvoie la matrice de rotation entre u et v.

Todo:
ajuster epsilon, ou trouver une autre formulation non degeneree...

Definition at line 258 of file mat.cpp.

259{
260 Vector a= normalize(u);
261 Vector b= normalize(v);
262 Vector w= cross(a, b); // rotation autour de w, un vecteur perpendiculaire a u et v
263 float s= length(w); // sin theta
264 float c= dot(a, b); // cos theta
265
266 // si u et v sont colineaires, pas d'axe de rotation, renvoyer +1 ou -1
267 if(s < float(0.00001))
269 return Scale(std::copysign(c, 1));
270
271 // normalise l'axe de rotation
272 w= w / s;
273
274 // meme matrice de rotation qu'au dessus , cf Rotation(axis, angle), l'axe est le vecteur w, s et c sont le sinus et le cosinus de l'angle
275 return Transform(
276 w.x * w.x + (1 - w.x * w.x ) * c,
277 w.x * w.y * (1 - c ) - w.z * s,
278 w.x * w.z * (1 - c ) + w.y * s,
279 0,
280
281 w.x * w.y * (1 - c ) + w.z * s,
282 w.y * w.y + (1 - w.y * w.y ) * c,
283 w.y * w.z * (1 - c ) - w.x * s,
284 0,
285
286 w.x * w.z * (1 - c ) - w.y * s,
287 w.y * w.z * (1 - c ) + w.x * s,
288 w.z * w.z + (1 - w.z * w.z ) * c,
289 0,
290
291 0, 0, 0, 1);
292}
float dot(const Vector &u, const Vector &v)
renvoie le produit scalaire de 2 vecteurs.
Definition vec.cpp:147
float length(const Vector &v)
renvoie la longueur d'un vecteur.
Definition vec.cpp:152
Vector cross(const Vector &u, const Vector &v)
renvoie le produit vectoriel de 2 vecteurs.
Definition vec.cpp:139

◆ Viewport()

Transform Viewport ( const float  width,
const float  height 
)

renvoie la matrice representant une transformation viewport.

Definition at line 323 of file mat.cpp.

324{
325 float w= width / 2.f;
326 float h= height / 2.f;
327
328 return Transform(
329 w, 0, 0, w,
330 0, h, 0, h,
331 0, 0, .5f, .5f,
332 0, 0, 0, 1);
333}

◆ Perspective()

Transform Perspective ( const float  fov,
const float  aspect,
const float  znear,
const float  zfar 
)

renvoie la matrice representant une transformation projection perspective.

Definition at line 295 of file mat.cpp.

296{
297 // perspective, openGL version
298 float itan= 1 / tanf(radians(fov) * 0.5f);
299 float id= 1 / (znear - zfar);
300
301 return Transform(
302 itan/aspect, 0, 0, 0,
303 0, itan, 0, 0,
304 0, 0, (zfar+znear)*id, 2.f*zfar*znear*id,
305 0, 0, -1, 0);
306}

◆ Ortho()

Transform Ortho ( const float  left,
const float  right,
const float  bottom,
const float  top,
const float  znear,
const float  zfar 
)

renvoie la matrice representant une transformation orthographique, passage d'un cube []x[]x[] vers [-1 1]x[-1 1]x[-1 1].

Definition at line 309 of file mat.cpp.

310{
311 float tx= - (right + left) / (right - left);
312 float ty= - (top + bottom) / (top - bottom);
313 float tz= - (zfar + znear) / (zfar - znear);
314
315 return Transform(
316 2.f / (right - left), 0, 0, tx,
317 0, 2.f / (top - bottom), 0, ty,
318 0, 0, -2.f / (zfar - znear), tz,
319 0, 0, 0, 1);
320}

◆ Lookat()

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 at line 335 of file mat.cpp.

336{
337 Vector dir= normalize( Vector(from, to) );
338 Vector right= normalize( cross(dir, normalize(up)) );
339 Vector newUp= normalize( cross(right, dir) );
340
341 Transform m(
342 right.x, newUp.x, -dir.x, from.x,
343 right.y, newUp.y, -dir.y, from.y,
344 right.z, newUp.z, -dir.z, from.z,
345 0, 0, 0, 1);
346
347 return m.inverse();
348}

◆ compose_transform()

Transform compose_transform ( const Transform a,
const Transform b 
)

renvoie la composition des transformations a et b, t= a * b.

Definition at line 350 of file mat.cpp.

351{
352 Transform m;
353 for(int i = 0; i < 4; i++)
354 for(int j = 0; j < 4; j++)
355 m.m[i][j]= a.m[i][0] * b.m[0][j] + a.m[i][1] * b.m[1][j] + a.m[i][2] * b.m[2][j] + a.m[i][3] * b.m[3][j];
356
357 return m;
358}

◆ operator*() [1/6]

Transform operator* ( const Transform a,
const Transform b 
)

renvoie la composition des transformations a et b, t = a * b.

Definition at line 360 of file mat.cpp.

361{
362 return compose_transform(a, b);
363}
Transform compose_transform(const Transform &a, const Transform &b)
renvoie la composition des transformations a et b, t= a * b.
Definition mat.cpp:350

◆ operator<<() [1/3]

std::ostream & operator<< ( std::ostream &  o,
const Transform t 
)
inline

Definition at line 117 of file mat.h.

118{
119 o << t.m[0][0] << " " << t.m[0][1] << " " << t.m[0][2] << " " << t.m[0][3] << " " << std::endl;
120 o << t.m[1][0] << " " << t.m[1][1] << " " << t.m[1][2] << " " << t.m[1][3] << " " << std::endl;
121 o << t.m[2][0] << " " << t.m[2][1] << " " << t.m[2][2] << " " << t.m[2][3] << " " << std::endl;
122 o << t.m[3][0] << " " << t.m[3][1] << " " << t.m[3][2] << " " << t.m[3][3] << " " << std::endl;
123 return o;
124}

◆ Origin()

Point Origin ( )

renvoie le point origine (0, 0, 0)

Definition at line 8 of file vec.cpp.

9{
10 return Point(0, 0, 0);
11}
representation d'un point 3d.
Definition vec.h:21

◆ distance()

float distance ( const Point a,
const Point b 
)

renvoie la distance etre 2 points.

Definition at line 14 of file vec.cpp.

15{
16 return length(a - b);
17}

◆ distance2()

float distance2 ( const Point a,
const Point b 
)

renvoie le carre de la distance etre 2 points.

Definition at line 19 of file vec.cpp.

20{
21 return length2(a - b);
22}
float length2(const Vector &v)
renvoie la carre de la longueur d'un vecteur.
Definition vec.cpp:157

◆ center()

Point center ( const Point a,
const Point b 
)

renvoie le milieu du segment ab.

Definition at line 24 of file vec.cpp.

25{
26 return Point((a.x + b.x) / 2, (a.y + b.y) / 2, (a.z + b.z) / 2);
27}

◆ min()

Point min ( const Point a,
const Point b 
)

renvoie la plus petite composante de chaque point. x, y, z= min(a.x, b.x), min(a.y, b.y), min(a.z, b.z).

Definition at line 30 of file vec.cpp.

31{
32 return Point( std::min(a.x, b.x), std::min(a.y, b.y), std::min(a.z, b.z) );
33}

◆ max()

Point max ( const Point a,
const Point b 
)

renvoie la plus grande composante de chaque point. x, y, z= max(a.x, b.x), max(a.y, b.y), max(a.z, b.z).

Definition at line 35 of file vec.cpp.

36{
37 return Point( std::max(a.x, b.x), std::max(a.y, b.y), std::max(a.z, b.z) );
38}

◆ normalize()

Vector normalize ( const Vector v)

renvoie un vecteur unitaire / longueur == 1.

Definition at line 133 of file vec.cpp.

134{
135 float kk= 1 / length(v);
136 return kk * v;
137}

◆ cross()

Vector cross ( const Vector u,
const Vector v 
)

renvoie le produit vectoriel de 2 vecteurs.

Definition at line 139 of file vec.cpp.

140{
141 return Vector(
142 (u.y * v.z) - (u.z * v.y),
143 (u.z * v.x) - (u.x * v.z),
144 (u.x * v.y) - (u.y * v.x));
145}

◆ dot()

float dot ( const Vector u,
const Vector v 
)

renvoie le produit scalaire de 2 vecteurs.

Definition at line 147 of file vec.cpp.

148{
149 return u.x * v.x + u.y * v.y + u.z * v.z;
150}

◆ length()

float length ( const Vector v)

renvoie la longueur d'un vecteur.

Definition at line 152 of file vec.cpp.

153{
154 return std::sqrt(length2(v));
155}

◆ length2()

float length2 ( const Vector v)

renvoie la carre de la longueur d'un vecteur.

Definition at line 157 of file vec.cpp.

158{
159 return v.x * v.x + v.y * v.y + v.z * v.z;
160}

◆ operator-() [1/5]

Vector operator- ( const Point a,
const Point b 
)

renvoie le vecteur a - b.

Definition at line 41 of file vec.cpp.

42{
43 return Vector(a.x - b.x, a.y - b.y, a.z - b.z);
44}

◆ operator+() [1/6]

Point operator+ ( const Point a,
const Point b 
)

renvoie le "point" a + b.

Definition at line 62 of file vec.cpp.

63{
64 return Point(a.x + b.x, a.y + b.y, a.z + b.z);
65}

◆ operator*() [2/6]

Point operator* ( const float  k,
const Point a 
)

renvoie le "point" k*a;

Definition at line 46 of file vec.cpp.

47{
48 return Point(k * a.x, k * a.y, k * a.z);
49}

◆ operator*() [3/6]

Point operator* ( const Point a,
const float  k 
)

renvoie le "point" a*k;

Definition at line 51 of file vec.cpp.

52{
53 return k * a;
54}

◆ operator/() [1/2]

Point operator/ ( const Point a,
const float  k 
)

renvoie le "point" v/k;

Definition at line 56 of file vec.cpp.

57{
58 float kk= 1.f / k;
59 return kk * a;
60}

◆ operator-() [2/5]

Vector operator- ( const Vector v)

renvoie le vecteur -v.

Definition at line 67 of file vec.cpp.

68{
69 return Vector(-v.x, -v.y, -v.z);
70}

◆ operator+() [2/6]

Point operator+ ( const Point a,
const Vector v 
)

renvoie le point a+v.

Definition at line 72 of file vec.cpp.

73{
74 return Point(a.x + v.x, a.y + v.y, a.z + v.z);
75}

◆ operator+() [3/6]

Point operator+ ( const Vector v,
const Point a 
)

renvoie le point a+v.

Definition at line 77 of file vec.cpp.

78{
79 return a + v;
80}

◆ operator-() [3/5]

Point operator- ( const Vector v,
const Point a 
)

renvoie le point a-v.

Definition at line 82 of file vec.cpp.

83{
84 return a + (-v);
85}

◆ operator-() [4/5]

Point operator- ( const Point a,
const Vector v 
)

renvoie le point a-v.

Definition at line 87 of file vec.cpp.

88{
89 return a + (-v);
90}

◆ operator+() [4/6]

Vector operator+ ( const Vector u,
const Vector v 
)

renvoie le vecteur u+v.

Definition at line 92 of file vec.cpp.

93{
94 return Vector(u.x + v.x, u.y + v.y, u.z + v.z);
95}

◆ operator-() [5/5]

Vector operator- ( const Vector u,
const Vector v 
)

renvoie le vecteur u-v.

Definition at line 97 of file vec.cpp.

98{
99 return Vector(u.x - v.x, u.y - v.y, u.z - v.z);
100}

◆ operator+() [5/6]

Vector operator+ ( const float  k,
const Vector v 
)

renvoie le vecteur u+k;

Definition at line 103 of file vec.cpp.

104{
105 return Vector(k + v.x, k + v.y, k + v.z);
106}

◆ operator+() [6/6]

Vector operator+ ( const Vector v,
const float  k 
)

Definition at line 107 of file vec.cpp.

108{
109 return Vector(k + v.x, k + v.y, k + v.z);
110}

◆ operator*() [4/6]

Vector operator* ( const float  k,
const Vector v 
)

renvoie le vecteur k*u;

Definition at line 112 of file vec.cpp.

113{
114 return Vector(k * v.x, k * v.y, k * v.z);
115}

◆ operator*() [5/6]

Vector operator* ( const Vector v,
const float  k 
)

renvoie le vecteur k*v;

Definition at line 117 of file vec.cpp.

118{
119 return k * v;
120}

◆ operator*() [6/6]

Vector operator* ( const Vector a,
const Vector b 
)

renvoie le vecteur (a.x*b.x, a.y*b.y, a.z*b.z ).

Definition at line 122 of file vec.cpp.

123{
124 return Vector(a.x * b.x, a.y * b.y, a.z * b.z);
125}

◆ operator/() [2/2]

Vector operator/ ( const Vector v,
const float  k 
)

renvoie le vecteur v/k;

Definition at line 127 of file vec.cpp.

128{
129 float kk= 1 / k;
130 return kk * v;
131}

◆ operator<<() [2/3]

std::ostream & operator<< ( std::ostream &  o,
const Point p 
)
inline

Definition at line 218 of file vec.h.

219{
220 o<<"p("<<p.x<<","<<p.y<<","<<p.z<<")";
221 return o;
222}

◆ operator<<() [3/3]

std::ostream & operator<< ( std::ostream &  o,
const Vector v 
)
inline

Definition at line 224 of file vec.h.

225{
226 o<<"v("<<v.x<<","<<v.y<<","<<v.z<<")";
227 return o;
228}

◆ Point() [1/3]

Point::Point ( const vec3 v)
inlineexplicit

cree un point a partir des coordonnees du vecteur generique (v.x, v.y, v.z).

Definition at line 194 of file vec.h.

194: x(v.x), y(v.y), z(v.z) {}

◆ Point() [2/3]

Point::Point ( const vec4 v)
inlineexplicit

Definition at line 195 of file vec.h.

195: x(v.x), y(v.y), z(v.z) {}

◆ Point() [3/3]

Point::Point ( const Vector v)
inlineexplicit

cree un point a partir des coordonnes du vecteur (v.x, v.y, v.z).

Definition at line 196 of file vec.h.

196: x(v.x), y(v.y), z(v.z) {}

◆ Vector() [1/3]

Vector::Vector ( const vec3 v)
inlineexplicit

cree un vecteur a partir des coordonnees du vecteur generique (v.x, v.y, v.z).

Definition at line 198 of file vec.h.

198: x(v.x), y(v.y), z(v.z) {}

◆ Vector() [2/3]

Vector::Vector ( const vec4 v)
inlineexplicit

Definition at line 199 of file vec.h.

199: x(v.x), y(v.y), z(v.z) {}

◆ Vector() [3/3]

Vector::Vector ( const Point a)
inlineexplicit

cree un vecteur a partir des coordonnes du point (a.x, a.y, a.z).

Definition at line 200 of file vec.h.

200: x(a.x), y(a.y), z(a.z) {}

◆ vec3() [1/2]

vec3::vec3 ( const Point a)
inline

cree un vecteur generique a partir des coordonnees du point a.

Definition at line 202 of file vec.h.

202: x(a.x), y(a.y), z(a.z) {}

◆ vec3() [2/2]

vec3::vec3 ( const Vector v)
inline

cree un vecteur generique a partir des coordonnees du vecteur v.

Definition at line 203 of file vec.h.

203: x(v.x), y(v.y), z(v.z) {}

◆ vec4() [1/2]

vec4::vec4 ( const Point a)
inline

cree un vecteur generique a partir des coordonnees du point a, (a.x, a.y, a.z, 1).

Definition at line 205 of file vec.h.

205: x(a.x), y(a.y), z(a.z), w(1.f) {}

◆ vec4() [2/2]

vec4::vec4 ( const Vector v)
inline

cree un vecteur generique a partir des coordonnees du vecteur v, (v.x, v.y, v.z, 0).

Definition at line 206 of file vec.h.

206: x(v.x), y(v.y), z(v.z), w(0.f) {}

◆ operator()() [1/4]

float Point::operator() ( const unsigned int  i) const
inline

renvoie la ieme composante du point.

Definition at line 209 of file vec.h.

209{ return (&x)[i]; }

◆ operator()() [2/4]

float Vector::operator() ( const unsigned int  i) const
inline

renvoie la ieme composante du vecteur.

Definition at line 210 of file vec.h.

210{ return (&x)[i]; }

◆ operator()() [3/4]

float & Point::operator() ( const unsigned int  i)
inline

Definition at line 212 of file vec.h.

212{ return (&x)[i]; }

◆ operator()() [4/4]

float & Vector::operator() ( const unsigned int  i)
inline

Definition at line 213 of file vec.h.

213{ return (&x)[i]; }