Project

General

Profile

« Previous | Next » 

Revision 9a6394c2

Added by Leszek Koltunski about 21 hours ago

  • ID 9a6394c2954faf837847a126d8b62fb98eb80330
  • Parent 76e5897b

progress with Ghosts

View differences:

src/main/java/org/distorted/library/helpers/QuatHelper.java
154 154
    ret[index+3] = rw*qw - rz*qz - ry*qy - rx*qx;
155 155
    }
156 156

  
157
///////////////////////////////////////////////////////////////////////////////////////////////////
158
// rotate 'vector' by quat  ( i.e. return quat*vector*(quat^-1) )
159

  
160
  public static Static4D rotateVectorByQuat(Static4D vector, Static4D quat)
161
    {
162
    float qx = quat.get0();
163
    float qy = quat.get1();
164
    float qz = quat.get2();
165
    float qw = quat.get3();
166

  
167
    Static4D tmp = quatMultiply(qx,qy,qz,qw,vector);
168

  
169
    return quatMultiply(tmp,-qx,-qy,-qz,qw);
170
    }
171

  
172 157
///////////////////////////////////////////////////////////////////////////////////////////////////
173 158
// rotate (x1,x2,x3,x4) by quat  ( i.e. return quat*vector*(quat^-1) )
174 159

  
......
268 253
    quat[2] = -quat[2];
269 254
    }
270 255

  
256
///////////////////////////////////////////////////////////////////////////////////////////////////
257
// rotate 'vector' by quat  ( i.e. return quat*vector*(quat^-1) )
258

  
259
  public static Static4D rotateVectorByQuat(Static4D vector, Static4D quat)
260
    {
261
    float qx = quat.get0();
262
    float qy = quat.get1();
263
    float qz = quat.get2();
264
    float qw = quat.get3();
265

  
266
    Static4D tmp = quatMultiply(qx,qy,qz,qw,vector);
267

  
268
    return quatMultiply(tmp,-qx,-qy,-qz,qw);
269
    }
270

  
271 271
///////////////////////////////////////////////////////////////////////////////////////////////////
272 272
// rotate 'vector' by quat^(-1)  ( i.e. return (quat^-1)*vector*quat )
273 273

  
......
280 280

  
281 281
    Static4D tmp = quatMultiply(-qx,-qy,-qz,qw,vector);
282 282

  
283
    return quatMultiply(tmp,quat);
283
    return quatMultiply(tmp,qx,qy,qz,qw);
284 284
    }
285 285

  
286
///////////////////////////////////////////////////////////////////////////////////////////////////
287
// rotate 'vector' by quat^(-1)  ( i.e. return (quat^-1)*vector*quat )
288

  
289
    public static void rotateVectorByInvertedQuat(float[] output, float x, float y, float z, float w, float[] quat)
290
      {
291
      float[] tmp = new float[4];
292

  
293
      float qx = quat[0];
294
      float qy = quat[1];
295
      float qz = quat[2];
296
      float qw = quat[3];
297

  
298
      quatMultiply(tmp,-qx,-qy,-qz,qw,x,y,z,w);
299
      quatMultiply(output,tmp[0],tmp[1],tmp[2],tmp[3],qx,qy,qz,qw);
300
      }
301

  
286 302
///////////////////////////////////////////////////////////////////////////////////////////////////
287 303

  
288 304
  public static Static4D quatFromDrag(float dragX, float dragY)

Also available in: Unified diff