-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmotion.cpp
69 lines (41 loc) · 1.34 KB
/
motion.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
69
#include "motion.hpp"
bool Motion::process( FILE *fp ) {
fscanf(fp," Frames: %d",&this->frames);
fscanf(fp," Frame Time: %lf",&this->frametime);
// Set frame size
frame_set.resize(this->frames);
for(int i = 0; i < this->frames; i++ ) {
double next_double;
double position[3];
for( int j = 0; j < this->frame_data_size; j++ ) {
fscanf(fp," %lf",&next_double);
frame_set[i].push_back(next_double);
if ( j < 3 )
position[j] = next_double;
}
update_boundaries(position);
add_mean_vertex(position);
}
compute_mean_vertex();
return true;
}
void Motion::print( FILE *out_fp ) {
fprintf(out_fp,"Frames: %d\n",this->frames);
fprintf(out_fp,"Frame Time: %.7lf\n",this->frametime);
std::vector< frame_data >::iterator it_frameset;
for( it_frameset = frame_set.begin() ; it_frameset != frame_set.end() ; it_frameset++ ) {
frame_data::iterator it_frame;
for( it_frame = (*it_frameset).begin() ; it_frame != (*it_frameset).end() ; it_frame++ ) {
fprintf(out_fp,"%.4lf ",*it_frame);
}
fprintf(out_fp,"\n");
}
}
void Motion::update_boundaries(double *pos) {
max.x = pos[0] > max.x? pos[0] : max.x;
max.y = pos[1] > max.y? pos[1] : max.y;
max.z = pos[2] > max.z? pos[2] : max.z;
min.x = pos[0] < min.x? pos[0] : min.x;
min.y = pos[1] < min.y? pos[1] : min.y;
min.z = pos[2] < min.z? pos[2] : min.z;
}