Revision f871c455
Added by Leszek Koltunski over 5 years ago
src/main/java/org/distorted/library/type/Dynamic.java | ||
---|---|---|
33 | 33 |
|
34 | 34 |
// The way Interpolation between more than 2 Points is done: |
35 | 35 |
// |
36 |
// Def: let w[i] = (w[i](x), w[i](y), w[i](z)) be the direction and speed we have to be flying at Point P[i] |
|
36 |
// Def: let V[i] = (V[i](x), V[i](y), V[i](z)) be the direction and speed (i.e. velocity) we have to |
|
37 |
// be flying at Point P[i] |
|
37 | 38 |
// |
38 |
// time it takes to fly though one segment v[i] --> v[i+1] : 0.0 --> 1.0 |
|
39 |
// w[i] should be parallel to v[i+1] - v[i-1] (cyclic notation) |
|
40 |
// |w[i]| proportional to | P[i]-P[i+1] | |
|
39 |
// Time it takes to fly though one segment P[i] --> P[i+1] : 0.0 --> 1.0 |
|
40 |
// |
|
41 |
// We arbitrarily decide that V[i] should be equal to (|curr|*prev + |prev|*curr) / min(|prev|,|curr|) |
|
42 |
// where prev = P[i]-P[i-1] and curr = P[i+1]-P[i] |
|
41 | 43 |
// |
42 | 44 |
// Given that the flight route (X(t), Y(t), Z(t)) from P(i) to P(i+1) (0<=t<=1) has to satisfy |
43 |
// X(0) = P[i ](x), Y(0)=P[i ](y), Z(0)=P[i ](z), X'(0) = w[i ](x), Y'(0) = w[i ](y), Z'(0) = w[i ](z)
|
|
44 |
// X(1) = P[i+1](x), Y(1)=P[i+1](y), Z(1)=P[i+1](z), X'(1) = w[i+1](x), Y'(1) = w[i+1](y), Z'(1) = w[i+1](z)
|
|
45 |
// X(0) = P[i ](x), Y(0)=P[i ](y), Z(0)=P[i ](z), X'(0) = V[i ](x), Y'(0) = V[i ](y), Z'(0) = V[i ](z)
|
|
46 |
// X(1) = P[i+1](x), Y(1)=P[i+1](y), Z(1)=P[i+1](z), X'(1) = V[i+1](x), Y'(1) = V[i+1](y), Z'(1) = V[i+1](z)
|
|
45 | 47 |
// |
46 | 48 |
// we have the solution: X(t) = at^3 + bt^2 + ct + d where |
47 |
// a = 2*P[i](x) + w[i](x) - 2*P[i+1](x) + w[i+1](x)
|
|
48 |
// b = -3*P[i](x) - 2*w[i](x) + 3*P[i+1](x) - w[i+1](x)
|
|
49 |
// c = w[i](x)
|
|
50 |
// d = P[i](x) |
|
49 |
// a = 2*P[i](x) + V[i](x) - 2*P[i+1](x) + V[i+1](x)
|
|
50 |
// b = -3*P[i](x) - 2*V[i](x) + 3*P[i+1](x) - V[i+1](x)
|
|
51 |
// c = V[i](x)
|
|
52 |
// d = P[i](x)
|
|
51 | 53 |
// |
52 | 54 |
// and similarly Y(t) and Z(t). |
53 | 55 |
|
src/main/java/org/distorted/library/type/Dynamic1D.java | ||
---|---|---|
35 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
36 | 36 |
// no array bounds checking! |
37 | 37 |
|
38 |
private void vec(int c)
|
|
38 |
private void computeVelocity(int c)
|
|
39 | 39 |
{ |
40 | 40 |
int p = c>0 ? c-1: numPoints-1; |
41 | 41 |
int n = c<numPoints-1 ? c+1: 0; |
... | ... | |
105 | 105 |
{ |
106 | 106 |
int i, n; |
107 | 107 |
|
108 |
for(i=0; i<numPoints; i++) vec(i);
|
|
108 |
for(i=0; i<numPoints; i++) computeVelocity(i);
|
|
109 | 109 |
|
110 | 110 |
for(i=0; i<numPoints; i++) |
111 | 111 |
{ |
src/main/java/org/distorted/library/type/Dynamic2D.java | ||
---|---|---|
35 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
36 | 36 |
// no array bounds checking! |
37 | 37 |
|
38 |
private void vec(int c)
|
|
38 |
private void computeVelocity(int c)
|
|
39 | 39 |
{ |
40 | 40 |
int p = c>0 ? c-1: numPoints-1; |
41 | 41 |
int n = c<numPoints-1 ? c+1: 0; |
... | ... | |
115 | 115 |
{ |
116 | 116 |
int i, n; |
117 | 117 |
|
118 |
for(i=0; i<numPoints; i++) vec(i);
|
|
118 |
for(i=0; i<numPoints; i++) computeVelocity(i);
|
|
119 | 119 |
|
120 | 120 |
for(i=0; i<numPoints; i++) |
121 | 121 |
{ |
src/main/java/org/distorted/library/type/Dynamic3D.java | ||
---|---|---|
35 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
36 | 36 |
// no array bounds checking! |
37 | 37 |
|
38 |
private void vec(int c)
|
|
38 |
private void computeVelocity(int c)
|
|
39 | 39 |
{ |
40 | 40 |
int p = c>0 ? c-1: numPoints-1; |
41 | 41 |
int n = c<numPoints-1 ? c+1: 0; |
... | ... | |
125 | 125 |
{ |
126 | 126 |
int i, n; |
127 | 127 |
|
128 |
for(i=0; i<numPoints; i++) vec(i);
|
|
128 |
for(i=0; i<numPoints; i++) computeVelocity(i);
|
|
129 | 129 |
|
130 | 130 |
for(i=0; i<numPoints; i++) |
131 | 131 |
{ |
src/main/java/org/distorted/library/type/Dynamic4D.java | ||
---|---|---|
35 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
36 | 36 |
// no array bounds checking! |
37 | 37 |
|
38 |
private void vec(int c)
|
|
38 |
private void computeVelocity(int c)
|
|
39 | 39 |
{ |
40 | 40 |
int p = c>0 ? c-1: numPoints-1; |
41 | 41 |
int n = c<numPoints-1 ? c+1: 0; |
... | ... | |
135 | 135 |
{ |
136 | 136 |
int i, n; |
137 | 137 |
|
138 |
for(i=0; i<numPoints; i++) vec(i);
|
|
138 |
for(i=0; i<numPoints; i++) computeVelocity(i);
|
|
139 | 139 |
|
140 | 140 |
for(i=0; i<numPoints; i++) |
141 | 141 |
{ |
src/main/java/org/distorted/library/type/Dynamic5D.java | ||
---|---|---|
35 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
36 | 36 |
// no array bounds checking! |
37 | 37 |
|
38 |
private void vec(int c)
|
|
38 |
private void computeVelocity(int c)
|
|
39 | 39 |
{ |
40 | 40 |
int p = c>0 ? c-1: numPoints-1; |
41 | 41 |
int n = c<numPoints-1 ? c+1: 0; |
... | ... | |
145 | 145 |
{ |
146 | 146 |
int i, n; |
147 | 147 |
|
148 |
for(i=0; i<numPoints; i++) vec(i);
|
|
148 |
for(i=0; i<numPoints; i++) computeVelocity(i);
|
|
149 | 149 |
|
150 | 150 |
for(i=0; i<numPoints; i++) |
151 | 151 |
{ |
src/main/java/org/distorted/library/type/DynamicQuat.java | ||
---|---|---|
52 | 52 |
private Static4D curr, next; |
53 | 53 |
|
54 | 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
55 |
//Abramowitz / Stegun |
|
55 |
// Abramowitz / Stegun
|
|
56 | 56 |
|
57 | 57 |
private static float arcCos(float x) |
58 | 58 |
{ |
Also available in: Unified diff
Improvements to comments and function names in Dynamics