Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 01 Jan 2004
Offline Last Active Today, 10:12 AM

Topics I've Started

Interpolating (slerp) between large rotation angles

01 July 2010 - 04:06 AM

Let's say I have two rotations, A(t) and B(t) that vary over time t. B(t) happens to be an extrapolation of an original rotation so B(t) = B(0) + t * dBdt, where dBdt is the original/constant rate of change of B.

What I want to calculate is a slerp between A and B:

Result(t) = slerp(A(t), B(t), T)

for T increasing from 0 and 1 (i.e. T = someConstant * t).

However, if A and B are represented by quaternions, then even if they start off in the same hemisphere, then after a while the direction of the slerp can (does!) flip, making the result discontinuous. In fact, if dBdt is big enough then B(t) needs to actually represent a rotation that is multiple complete revolutions. Quaternions obviously don't manage this.

Can anyone suggest a solution to this (e.g. involving intermediate representation using rotation vectors)?

One improvement would/might be to add on a fraction of the extrapolation after the slerp:

C(t) = slerp(A(t), B(0), T)
result(t) = C(t) + (1 - T) * t * dBdt

So long as A(t) and B(0) don't diverge much, then this should make result continuous, though it wouldn't be a "proper" large-angle slerp. I just wonder if anyone has a better idea :)

JigLib physics - new version

13 August 2005 - 10:41 AM

I promised b34r I'd post a new demo of my physics stuff - so http://www.rowlhouse.co.uk/jiglib None of the demos use a shock step, so consequently they actually feel a little bit slower than my previous demo versions. The reason they don't use it (and this is quite amusing) - it only worked quite nicely before because it had a bug in it, and now I fixed the bug it produces significant artifacts! I want to fix it properly... You can configure the demos by modifying the config files - if you want to play around or if they run too slowly on your machine. Anyway, I made a whole load of changes. See the readme.txt for how to use the demo. The significant changes to the algorithm are these: 1. During collision detection penetration depth is recorded at each point - but the penetration depth (PD) is calculated (in some cases estimated) for the beginning of the collision sweep. This means that during a collision -ve penetration depths get recorded. Also, the position gets recorded relative to the positions of the objects at the beginning of the collision sweep. 2. collision/contact impulses all get applied to the objects in the position they were at the beginning of the step. 3. If PD > 0 then an extra term is added to the impulse calculation to make the penetration relax to 0 over a number of timesteps. 4. If PD < 0 and the elasticity = 0 (actually, that's not quite the criterion I use, but anyway...), then an extra term is added to the impulse calculation to make the penetration relax to 0 over a number (1) of timesteps - i.e. using the same code as in 3. What this means is that if there is an inelastic collision between an object and the world between T and T + dt then: 1. at time T an impulse gets applied that slows the object down just enough so that at time T + dt it will be touching the world. 2. at time T + dt another impulse gets applied that brings the object to a complete stop. So - no more objects stopping short of the ground when they fall, etc. Lots more to do to make it useful - at the very least I need to refactor the collision system (currently you can't have composites of different primitives, which is a really dumb thing!), and b34r demonstrated how excellent contact caching can be. I'm anticipating this will solve the drift that you can see in the walls - apart from the drift there's very little jitter. Edit: Yes, I know the ragdoll's limbs separate from his body if you pick him up and swing him around hard, but then I say the same would happen to you!

New physics SDK

16 February 2005 - 08:03 AM

Nothing to do with me, but I thought it's worth posting this, in case people missed it from the main gamedev page: http://www.gamedev.net/community/forums/topic.asp?topic_id=301155

Physics demo

06 November 2004 - 05:00 PM

I've been working on a rigid-body library for the last couple of weeks - if you're interested you can download my test application that uses it from here: http://www.rowlhouse.co.uk/jiglib/ I'm happy to discuss how it's implemented, though I'm not in a position to post the code (at the moment). In any case, it's quite fun playing with it :) Cheers - Danny