

Public Member Functions | |
| void | addSample (double t, double x, double y, double z) |
| Point3d | computePosition (double jd) const |
| double | getBoundingRadius () const |
| double | getPeriod () const |
| void | getValidRange (double &begin, double &end) const |
| bool | isPeriodic () const |
| virtual void | sample (double, double, int, OrbitSampleProc &proc) const |
| SampledOrbit () | |
| void | setPeriod () |
| virtual | ~SampledOrbit () |
Private Types | |
| enum | InterpolationType { Linear = 0, Cubic = 1 } |
Private Attributes | |
| double | boundingRadius |
| InterpolationType | interpolation |
| int | lastSample |
| double | period |
| vector< Sample > | samples |
|
|
Definition at line 69 of file samporbit.cpp.
|
|
|
Definition at line 79 of file samporbit.cpp. 00079 : 00080 boundingRadius(0.0), 00081 period(1.0), 00082 lastSample(0), 00083 interpolation(Cubic) 00084 { 00085 }
|
|
|
Definition at line 88 of file samporbit.cpp. 00089 {
00090 }
|
|
||||||||||||||||||||
|
Definition at line 93 of file samporbit.cpp. References boundingRadius, samples, sqrt(), Sample::t, Sample::x, Sample::y, and Sample::z. Referenced by LoadSampledOrbit(). 00094 {
00095 double r = sqrt(x * x + y * y + z * z);
00096 if (r > boundingRadius)
00097 boundingRadius = r;
00098
00099 Sample samp;
00100 samp.x = (float) x;
00101 samp.y = (float) y;
00102 samp.z = (float) z;
00103 samp.t = t;
00104 samples.insert(samples.end(), samp);
00105 }
|
|
|
Implements CachingOrbit. Definition at line 142 of file samporbit.cpp. References Cubic, cubicInterpolate(), interpolation, lastSample, Linear, samples, Sample::t, Point3< T >::x, Sample::x, Point3< T >::y, Sample::y, Point3< T >::z, and Sample::z. 00143 {
00144 Point3d pos;
00145 if (samples.size() == 0)
00146 {
00147 pos = Point3d(0.0, 0.0, 0.0);
00148 }
00149 else if (samples.size() == 1)
00150 {
00151 pos = Point3d(samples[0].x, samples[1].y, samples[2].z);
00152 }
00153 else
00154 {
00155 Sample samp;
00156 samp.t = jd;
00157 int n = lastSample;
00158
00159 if (n < 1 || jd < samples[n - 1].t || jd > samples[n].t)
00160 {
00161 vector<Sample>::const_iterator iter = lower_bound(samples.begin(),
00162 samples.end(),
00163 samp);
00164 n = iter - samples.begin();
00165 lastSample = n;
00166 }
00167
00168 if (n == 0)
00169 {
00170 pos = Point3d(samples[n].x, samples[n].y, samples[n].z);
00171 }
00172 else if (n < (int) samples.size())
00173 {
00174 if (interpolation == Linear)
00175 {
00176 Sample s0 = samples[n - 1];
00177 Sample s1 = samples[n];
00178
00179 double t = (jd - s0.t) / (s1.t - s0.t);
00180 pos = Point3d(Mathd::lerp(t, (double) s0.x, (double) s1.x),
00181 Mathd::lerp(t, (double) s0.y, (double) s1.y),
00182 Mathd::lerp(t, (double) s0.z, (double) s1.z));
00183 }
00184 else if (interpolation == Cubic)
00185 {
00186 Sample s0, s1, s2, s3;
00187 if (n > 1)
00188 s0 = samples[n - 2];
00189 else
00190 s0 = samples[n - 1];
00191 s1 = samples[n - 1];
00192 s2 = samples[n];
00193 if (n < (int) samples.size() - 1)
00194 s3 = samples[n + 1];
00195 else
00196 s3 = samples[n];
00197
00198 double t = (jd - s1.t) / (s2.t - s1.t);
00199 Point3d p0(s1.x, s1.y, s1.z);
00200 Point3d p1(s2.x, s2.y, s2.z);
00201
00202 Vec3d v0((double) s2.x - (double) s0.x,
00203 (double) s2.y - (double) s0.y,
00204 (double) s2.z - (double) s0.z);
00205 Vec3d v1((double) s3.x - (double) s1.x,
00206 (double) s3.y - (double) s1.y,
00207 (double) s3.z - (double) s1.z);
00208 v0 *= (s2.t - s1.t) / (s2.t - s0.t);
00209 v1 *= (s2.t - s1.t) / (s3.t - s1.t);
00210
00211 pos = cubicInterpolate(p0, v0, p1, v1, t);
00212 }
00213 else
00214 {
00215 // Unknown interpolation type
00216 pos = Point3d(0.0, 0.0, 0.0);
00217 }
00218 }
00219 else
00220 {
00221 pos = Point3d(samples[n - 1].x, samples[n - 1].y, samples[n - 1].z);
00222 }
00223 }
00224
00225 return Point3d(pos.x, pos.z, -pos.y);
00226 }
|
|
|
Implements CachingOrbit. Definition at line 126 of file samporbit.cpp. References boundingRadius. 00127 {
00128 return boundingRadius;
00129 }
|
|
|
Implements CachingOrbit. Definition at line 107 of file samporbit.cpp. References samples, and Sample::t.
|
|
||||||||||||
|
Reimplemented from Orbit. Definition at line 119 of file samporbit.cpp. References samples, and Sample::t.
|
|
|
Reimplemented from Orbit. Definition at line 113 of file samporbit.cpp. 00114 {
00115 return false;
00116 }
|
|
||||||||||||||||||||
|
Reimplemented from CachingOrbit. Definition at line 229 of file samporbit.cpp. References cos(), degToRad(), dot(), MaxSampleInterval, MinSampleInterval, Vector3< T >::normalize(), CachingOrbit::positionAtTime(), and SampleThresholdAngle. 00231 {
00232 double cosThresholdAngle = cos(degToRad(SampleThresholdAngle));
00233 double dt = MinSampleInterval;
00234 double end = start + t;
00235 double current = start;
00236
00237 proc.sample(current, positionAtTime(current));
00238
00239 while (current < end)
00240 {
00241 double dt2 = dt;
00242
00243 Point3d goodpt;
00244 double gooddt = dt;
00245 Point3d pos0 = positionAtTime(current);
00246 goodpt = positionAtTime(current + dt2);
00247 while (1)
00248 {
00249 Point3d pos1 = positionAtTime(current + dt2);
00250 Point3d pos2 = positionAtTime(current + dt2 * 2.0);
00251 Vec3d vec1 = pos1 - pos0;
00252 Vec3d vec2 = pos2 - pos0;
00253
00254 vec1.normalize();
00255 vec2.normalize();
00256 double dot = vec1 * vec2;
00257
00258 if (dot > 1.0)
00259 dot = 1.0;
00260 else if (dot < -1.0)
00261 dot = -1.0;
00262
00263 if (dot > cosThresholdAngle && dt2 < MaxSampleInterval)
00264 {
00265 gooddt = dt2;
00266 goodpt = pos1;
00267 dt2 *= 2.0;
00268 }
00269 else
00270 {
00271 proc.sample(current + gooddt, goodpt);
00272 break;
00273 }
00274 }
00275 current += gooddt;
00276 }
00277 }
|
|
|
|
|
|
Definition at line 65 of file samporbit.cpp. Referenced by addSample(), and getBoundingRadius(). |
|
|
Definition at line 75 of file samporbit.cpp. Referenced by computePosition(). |
|
|
Definition at line 67 of file samporbit.cpp. Referenced by computePosition(). |
|
|
Definition at line 66 of file samporbit.cpp. |
|
|
Definition at line 64 of file samporbit.cpp. Referenced by addSample(), computePosition(), getPeriod(), and getValidRange(). |
1.4.1