Revision c59fc52d
Added by Leszek Koltunski almost 6 years ago
| src/main/java/org/distorted/library/type/DynamicQuat.java | ||
|---|---|---|
| 27 | 27 |
* of Static4Ds. |
| 28 | 28 |
* Here, the Points are assumed to be Quaternions - thus we do the Spherical Linear Interpolation, aka |
| 29 | 29 |
* SLERP. Noise not supported (yet?). |
| 30 |
* |
|
| 31 |
* Only unit quaternions represent valid rotations in 3D - and interpolating through rotations is the |
|
| 32 |
* most common use case for this class. No effort is done to normalize the Points though. |
|
| 30 | 33 |
*/ |
| 31 | 34 |
|
| 32 | 35 |
public class DynamicQuat extends Dynamic implements Data4D |
| ... | ... | |
| 86 | 89 |
vq.vw = cu.w; |
| 87 | 90 |
|
| 88 | 91 |
vq.cosOmega = cu.x*ne.x + cu.y*ne.y + cu.z*ne.z + cu.w*ne.w; |
| 89 |
|
|
| 90 |
if( vq.cosOmega<0 && n!=0 ) // do not invert the last quaternion even if we'd have to go the long way around! |
|
| 91 |
{
|
|
| 92 |
vq.cosOmega = -vq.cosOmega; |
|
| 93 |
ne.x = -ne.x; |
|
| 94 |
ne.y = -ne.y; |
|
| 95 |
ne.z = -ne.z; |
|
| 96 |
ne.w = -ne.w; |
|
| 97 |
} |
|
| 98 |
|
|
| 99 | 92 |
vq.sinOmega = (float)Math.sqrt(1-vq.cosOmega*vq.cosOmega); |
| 100 |
vq.omega = arcCos(vq.cosOmega); |
|
| 93 |
vq.omega = arcCos(vq.cosOmega);
|
|
| 101 | 94 |
} |
| 102 | 95 |
} |
| 103 | 96 |
|
| ... | ... | |
| 154 | 147 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 155 | 148 |
/** |
| 156 | 149 |
* Resets the location'th Point. |
| 157 |
*
|
|
| 150 |
* |
|
| 158 | 151 |
* @param location the index of the Point we are setting. |
| 159 | 152 |
* @param x New value of its first float. |
| 160 | 153 |
*/ |
Also available in: Unified diff
Dynamics App: fix moving Quat Points
Library: remove negating the Quat Points in the DynamicQuat in order to always go the shortest route.