![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
So there's this thing I want to do, simulating self-assembly of a few
dozen parts. The idea is that each part has a small number of nodes
that are attracted to corresponding nodes on other parts.
To find its proper place, a part will generally have to be both
translated and rotated. Translation is easy: for each node there's a
vector to its mate, and the part moves on each step by some fraction
(probably half) of the average of these vectors.
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.
So, have you done anything similar?
--
*\\* Anton Sherwood *\\* www.bendwavy.org
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
> 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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Le 25/02/2014 08:28, Anton Sherwood a écrit :
> So there's this thing I want to do, simulating self-assembly of a few
> dozen parts. The idea is that each part has a small number of nodes
> that are attracted to corresponding nodes on other parts.
>
> To find its proper place, a part will generally have to be both
> translated and rotated. Translation is easy: for each node there's a
> vector to its mate, and the part moves on each step by some fraction
> (probably half) of the average of these vectors.
>
> 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.
>
> So, have you done anything similar?
>
You should move from 3x3 matrices (X,Y,Z, homogeneous coordinates) to
represent rotation to 4x4 matrices (weighted projective coordinates:
t,u,v,w ; with x=t/w, y=u/w and z=v/w) to represent all affine
transformations (rotation & translation (and more, but you did not talk
of them)).
From all your transformations (R & T), you compute the combination of
them all (M = R.T, if you apply first the rotation then the
translation), then you can use a linear interpolation to have the
various steps at constant momentum: for k between 0 and 1, the
transformation is k.M
You can even have acceleration or deceleration effect by keeping k
regularly spaced, but using a power of k to multiply M (the power could
be fractional like 1/2 for a square root, or 2... )
In fact, you might even have a mapping curve via a function f(k) as long
as f(0) -> 0, f(1)-> 1 and f(k)-> [0,1) for k in [0,1) : the
transformation would be f(k).M
the change of momentum would then be the first derivative of f().
--
Just because nobody complains does not mean all parachutes are perfect.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
> From all your transformations (R & T), you compute the combination of
> them all (M = R.T, if you apply first the rotation then the
> translation), then you can use a linear interpolation to have the
> various steps at constant momentum: for k between 0 and 1, the
> transformation is k.M
The problem is you can't take a linear interpolation of a rotation
matrix and get a valid result.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Le 25/02/2014 10:14, scott a écrit :
>> From all your transformations (R & T), you compute the combination of
>> them all (M = R.T, if you apply first the rotation then the
>> translation), then you can use a linear interpolation to have the
>> various steps at constant momentum: for k between 0 and 1, the
>> transformation is k.M
>
> The problem is you can't take a linear interpolation of a rotation
> matrix and get a valid result.
Yep, my bad.
you just need a valid interpolation between the identity matrix and the
final transform matrix... which might take some sweat but is doable, as
long as you restrict yourself to rotation and translation. (as long as
the matrix is for a rigid transformation)
Computes the axis of final rotation and the final angle.
Apply the linear interpolation on the translation matrix, and generate a
rotation matrix for the same axis and an interpolated angle.
Everything in quaternion, of course (and stay away from Euler angles).
Interesting reading:
http://graphics.ucsd.edu/courses/cse167_f05/CSE167_03.ppt
and
http://www.inf.ethz.ch/personal/lballan/pdfs/RigidTransformations.pdf
--
Just because nobody complains does not mean all parachutes are perfect.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
On 25-2-2014 10:05, scott wrote:
> 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.
Just by chance, the other day, I was dusting of my collection of codes
and found this:
http://news.povray.org/povray.binaries.scene-files/thread/%3CXns940E6C1F42D3FNone%40204.213.191.226%3E/?ttop=391498&toff=550
Maybe that might help you?
Thomas
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
> you just need a valid interpolation between the identity matrix and the
> final transform matrix... which might take some sweat but is doable, as
> long as you restrict yourself to rotation and translation. (as long as
> the matrix is for a rigid transformation)
>
> Computes the axis of final rotation and the final angle.
> Apply the linear interpolation on the translation matrix, and generate a
> rotation matrix for the same axis and an interpolated angle.
Yeh, I think this amounts to pretty much the same as my first
recommendation as quaternions describe rotations as an axis and angle.
If the OP can calculate what the final orientation should be then this
seems the easiest way.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
On 2014-2-24 23:28, Anton Sherwood wrote:
> So there's this thing I want to do, simulating self-assembly
> of a few dozen parts. [....]
As usual I've done a fine job of making myself misunderstood.
This is not an animation project, to depict the movements of the parts
as they approach a known configuration; this is a design project, to
find that configuration.
I thought it likely that some of you might have appropriate knowledge,
but it has nothing to do with Povray, which is why I put it in p.off-topic.
--
*\\* Anton Sherwood *\\* www.bendwavy.org
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
> As usual I've done a fine job of making myself misunderstood.
> This is not an animation project, to depict the movements of the parts
> as they approach a known configuration; this is a design project, to
> find that configuration.
I think you'll have to explain a bit more what you are doing and what
you would like help with. Are the node positions already fixed, or is
that what you are trying to design?
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
>> As usual I've done a fine job of making myself misunderstood.
>> This is not an animation project, to depict the movements of
>> the parts as they approach a known configuration; this is a
>> design project, to find that configuration.
On 2014-2-26 01:11, scott wrote:
> I think you'll have to explain a bit more what you are doing
Non-spherical geodesic domes -- dual to figures like the attached --
where the pentagonal hubs are *not* arranged as the vertices of an
icosahedron. The "parts" I mentioned are the hubs, the "nodes" are the
tips of five or six radiating rods; each tip seeks a corresponding tip.
(In general the nodes won't exactly match, and even if they did there
would be an angle between rods; cubic splines will cover both flaws.)
> and what you would like help with.
I want to know how to generate, for each part, a rotation-translation
matrix that brings its nodes nearer to their mates.
At risk of repetition:
In my mental model, such as it is, the attraction between nodes puts a
"force" on each node, which in turn puts a "torque" on the hub.
(Scare-quotes because I don't want to give the body momentum, linear or
angular; I want it to jump to a new position and wait quietly for the
next cycle.)
Torque is a vector, and vectors can be added and rescaled.
But how do I turn the resulting torque vector into a rotation matrix?
> Are the node positions already fixed,
> or is that what you are trying to design?
Each part's nodes are fixed with respect to the part.
What I seek is the positions of the parts with respect to each other.
--
*\\* Anton Sherwood *\\* www.bendwavy.org
Post a reply to this message
Attachments:
Download 'sevenbyfive.jpg' (194 KB)
Preview of image 'sevenbyfive.jpg'
![sevenbyfive.jpg](/povray.off-topic/attachment/%3C530db7e8%40news.povray.org%3E/sevenbyfive.jpg?ttop=443812&toff=650&preview=1)
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |