MythTV master
v3d.h
Go to the documentation of this file.
1#ifndef V3D_H
2#define V3D_H
3
4#include <cmath>
5#include <cstdio>
6#include <cstdlib>
7
8#include "mathtools.h"
9
10struct v3d {
11 float x,y,z;
12};
13
14struct v2d {
15 int x,y;
16};
17
18/*
19 * projete le vertex 3D sur le plan d'affichage
20 * retourne (0,0) si le point ne doit pas etre affiche.
21 *
22 * bonne valeur pour distance : 256
23 */
24#define V3D_TO_V2D(v3,v2,width,height,distance) \
25{ \
26 int Xp; \
27 int Yp; \
28 if ((v3).z > 2) { \
29 F2I(((distance) * (v3).x / (v3).z),Xp) ; \
30 F2I(((distance) * (v3).y / (v3).z),Yp) ; \
31 (v2).x = Xp + ((width)>>1); \
32 (v2).y = -Yp + ((height)>>1); \
33 } \
34 else (v2).x=(v2).y=-666; \
35}
36
37/*
38 * rotation selon Y du v3d vi d'angle a (cosa=cos(a), sina=sin(a))
39 * centerz = centre de rotation en z
40 */
41#define Y_ROTATE_V3D(vi,vf,sina,cosa)\
42{\
43 (vf).x = ((vi).x * (cosa)) - ((vi).z * (sina));\
44 (vf).z = ((vi).x * (sina)) + ((vi).z * (cosa));\
45 (vf).y = (vi).y;\
46}
47
48/*
49 * translation
50 */
51#define TRANSLATE_V3D(vsrc,vdest)\
52{\
53 (vdest).x += (vsrc).x;\
54 (vdest).y += (vsrc).y;\
55 (vdest).z += (vsrc).z;\
56}
57
58#define MUL_V3D(lf,v) {(v).x*=(lf);(v).y*=(lf);(v).z*=(lf);}
59
60#endif // V3D_H
Definition: v3d.h:14
int y
Definition: v3d.h:15
int x
Definition: v3d.h:15
Definition: v3d.h:10
float x
Definition: v3d.h:11
float z
Definition: v3d.h:11
float y
Definition: v3d.h:11