-
Notifications
You must be signed in to change notification settings - Fork 0
/
vxVector.cpp
68 lines (57 loc) · 1.2 KB
/
vxVector.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
*
* file vxVector.cpp
*
* This source file is a part of VoxelBrain software.
*
* (c) Nanyang Technological University
*
* Author: Konstantin Levinski
*
*/
#include <stdio.h>
#include "vxVector.h"
///stupid. but too much coffee already
V3f rot_x(V3f in, float r){
V3f res;
res.x = in.x;
res.y = cos(r)*in.y-sin(r)*in.z;
res.z = sin(r)*in.y+cos(r)*in.z;
return res;
};
V3f rot_y(V3f in, float r){
V3f res;
res.y = in.y;
res.z = cos(r)*in.z-sin(r)*in.x;
res.x = sin(r)*in.z+cos(r)*in.x;
return res;
};
V3f rot_z(V3f in, float r){
V3f res;
res.z = in.z;
res.x = cos(r)*in.x-sin(r)*in.y;
res.y = sin(r)*in.x+cos(r)*in.y;
return res;
};
//make basis ortonormal again.
void ortoNormalize(V3f & nnx, V3f & nny, V3f & nnz){
V3f newy; newy.cross(nnz, nnx);
V3f newz; newz.cross(nnx, newy);
newy /= newy.length();
newz /= newz.length();
nnx /= nnx.length();
nny = newy;
nnz = newz;
};
//Find minimal coordinate.
float min(const V3f & in){
if(in.x < in.y){
return (in.x < in.z)?in.x:in.z;
}else{ //in.x > in.y
return (in.y < in.z)?in.y:in.z;
};
};
void say(char *msg, const V3f & v){
printf("%s:%f:%f:%f\n", msg, v.x, v.y, v.z);
};
// End of vxVector.cpp