POV-Ray : Newsgroups : povray.off-topic : discrete torque : Re: discrete torque Server Time
28 Jul 2024 12:32:25 EDT (-0400)
  Re: discrete torque  
From: scott
Date: 25 Feb 2014 04:05:04
Message: <530c5cc0@news.povray.org>
> Rotation is where I'm stuck.  The obvious metaphor is torque: cross that
> node-to-node translation vector with the center-to-node vector, and you
> get a torque vector, and all the torque vectors for each part can be
> averaged together ...
>
> But wait, I don't want to give the part some angular momentum, I want it
> to *step* by the needed rotation.  I want a function that translates
> (pardon the pun) the sum of these pseudo-torque vectors into a rotation
> matrix -- and I never did study 3D rotation matrices.

I don't think it will work doing it that way. The problem is with 
rotations of rigid bodies that the nodes won't usually follow a straight 
line between their current position and the final position. You can't 
just move the node along a straight line towards its destination, 
because this would result in the body deforming.

I can think of two ways around this, depending on whether you can/want 
to calculate the final desired position and rotation initially:

1 - If you can calculate the final position and rotation then use 
quaternions to represent the rotation and use simple linear 
interpolation of the position and rotation of the body throughout the 
animation. Quaternions have the benefit of making interpolation between 
two rotation states easy, you don't have to worry about angles or 
rotation matrices etc. It's how most physics engines work. Wikipedia and 
google are your friends here:

http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation
http://en.wikipedia.org/wiki/Slerp

2 - If not then I think you'll have to use torques and angular momentum. 
I don't think it's any harder than the other option. You'll need to use 
quaternions here too anyway. You would then apply a force directly to 
each node in the direction to its mate, when summed up this would give 
you an overall force and torque on the body. The formulas for applying a 
torque to an angular momentum quaternion and updating the rotation with 
the angular momentum are almost as simple as the ones for linear motion. 
That's why quaternions are used. No 3D rotation matrices in sight!

You'll probably also want to apply some damping to the linear velocity 
and angular momentum to avoid it overshooting the target. Again with 
quaternions this is just as easy for rotation as it is for linear 
motion. This page has some good information to get started: 
gafferongames.com/game-physics/‎


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.