-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFlyingSaucersVol4D.cpp
More file actions
146 lines (129 loc) · 4.27 KB
/
FlyingSaucersVol4D.cpp
File metadata and controls
146 lines (129 loc) · 4.27 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
* File: FlyingSaucersVol4D.cpp
* Author: zoizoi
*
* Created on 23 February 2011, 20:04
*/
#include "FlyingSaucersVol4D.h"
FlyingSaucersVol4D::FlyingSaucersVol4D(OVASControl* oc, int numSaucers) : ImplicitVolume4D(oc) {
saucers=new vector<MovingAAElipsoid*>();
srand(28);
for (int i=0;i<numSaucers;i++){
float x,y,z;
//float x=((float)rand())/RAND_MAX,y=((float)rand())/RAND_MAX,z=((float)rand())/RAND_MAX,vx=(((float)rand())/RAND_MAX)/2-0.25,vy=(vx/5)*((float)rand())/RAND_MAX,vz=(vx/5)*((float)rand())/RAND_MAX;
if(i==0){
x=0.1;y=0.2;z=0.5;
}
if(i==1){
x=0.3;y=0.5;z=0.5;
}
if(i==2){
x=0.6;y=0.7;z=0.7;
}
if(i==3){
x=0.8;y=0.7;z=0.5;
}
float sx,sy,sz;
float vx,vy,vz;
// sy=sz=10;
// sx=400;
sx=sy=sz=50;
vx=vy=vz=0;
float w=4;
saucers->push_back(new MovingAAElipsoid(oc,x,y,z,vx,vy,vz,sx,sy,sz,w));
cout<<" add saucer "<<i<<" "<<x*oc->xDim<<" "<<y*oc->yDim<<" "<<z*oc->zDim<<endl;
}
}
FlyingSaucersVol4D::FlyingSaucersVol4D(const FlyingSaucersVol4D& orig) {
}
FlyingSaucersVol4D::~FlyingSaucersVol4D() {
}
//float FlyingSaucersVol4D::getVoxelValue(int x, int y, int z, int step) {
//
// float time = oc->stepToParamConverter->getParamForStep(step);
// float tFraction = oc->stepToParamConverter->getParamFractionForStep(step);
// int noCenters = 3;
// float spread = 0.3;
//
// vector<float> centres(3 * noCenters);
//
// float fieldVal = 0;
// float cx, cy, cz;
// float weight = 3.9;
// for (size_t i = 0; i < noCenters; i++) {
// cy = 0.3 + 0.25*i;
// cx = 0.3 + 0.2*i;
// cz = 0.3 + 0.2*i;
// // cx=cy=cz=0.5;
// float sx, sy, sz;
// float sinVal=sin(tFraction*(4*3.14152));
//
// sy = 350+sinVal*300;
// if(x==16&&y==16&&z==16){
// cout<<"sinv "<<sinVal<<" sy: "<<sy<<endl;
// }
// sx = 3;
// sz = 3;
//
// float xv = (float) x / oc->xDim;
// float yv = (float) y / oc->yDim;
// float zv = (float) z / oc->zDim;
// fieldVal += (exp(-1 * (pow(xv - cx, 2) * sx + pow(yv - cy, 2) * sy + pow(zv - cz, 2) * sz))) * weight;
// //cout<<" for "<<x<<" "<<y<<" "<<z<<" "<<(exp(-1 * (pow(xv - cx, 2))*sx))<<endl;
// }
// //cout<<" for "<<x<<" "<<y<<" "<<z<<" "<<fieldVal<<endl;
// return fieldVal;
//
//}
//
//float FlyingSaucersVol4D::getVoxelValue(int x, int y, int z, int step) {
//
// float time = oc->stepToParamConverter->getParamForStep(step);
// float tFraction = oc->stepToParamConverter->getParamFractionForStep(step);
// int noCenters = 3;
// float spread = 0.3;
//
// vector<float> centres(3 * noCenters);
//
// float fieldVal = 0;
// float cx, cy, cz;
// float weight = 3.9;
// for (size_t i = 0; i < noCenters; i++) {
// cy = 0.3 + 0.25*i;
// cx = 0.3 + 0.2*i;
// cz = 0.3 + 0.2*i;
// // cx=cy=cz=0.5;
// float sx, sy, sz;
// float sinVal=sin(tFraction*(4*3.14152));
//
// sy = 350+sinVal*300;
//// if(x==16&&y==16&&z==16){
//// cout<<"sinv "<<sinVal<<" sy: "<<sy<<endl;
//// }
// sx = 3;
// sz = 3;
//
// float xv = (float) x / oc->xDim;
// float yv = (float) y / oc->yDim;
// float zv = (float) z / oc->zDim;
// fieldVal += (exp(-1 * (pow(xv - cx, 2) * sx + pow(yv - cy, 2) * sy + pow(zv - cz, 2) * sz))) * weight;
// //cout<<" for "<<x<<" "<<y<<" "<<z<<" "<<(exp(-1 * (pow(xv - cx, 2))*sx))<<endl;
// }
// //cout<<" for "<<x<<" "<<y<<" "<<z<<" "<<fieldVal<<endl;
// return fieldVal;
//
//}
//
float FlyingSaucersVol4D::getVoxelValue(int x, int y, int z, int step) {
float time = oc->stepToParamConverter->getParamForStep(step);
float tFraction = oc->stepToParamConverter->getParamFractionForStep(step);
vector<MovingAAElipsoid*>::iterator it;
float totalVal=0;
for (it=saucers->begin();it!=saucers->end();it++){
MovingAAElipsoid* saucer=*(it);
totalVal+=saucer->getContribAt(x,y,z,step);//*(0.9+0.2*((float)rand())/RAND_MAX);
}
//cout<<"returning tv "<<totalVal<<endl;
//return 0;
return totalVal;
}