This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > VRML > February 2005 > How to extract Y component of a rotation
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to extract Y component of a rotation
|
|
| Steve Smith 2005-01-23, 12:25 pm |
| Can anynone give me some javascript which extracts just the rotation about
the Y axis from a rotation.
Thanks in Advance
Steve Smith
| |
|
| Steve Smith a écrit :
> Can anynone give me some javascript which extracts just the rotation about
> the Y axis from a rotation.
>
>
>
> Thanks in Advance
>
> Steve Smith
NewRotation = new SFRotation(0, MyRotation.y, 0, MyRotation.angle);
But I'm not sure that it is what you're looking for :-S
Bye
O.L.
--
Ceci est une signature automatique de MesNews.
Site : http://mesnews.no-ip.com
| |
| Brian Hay 2005-01-28, 7:42 pm |
| Steve Smith wrote:
> Can anynone give me some javascript which extracts just the rotation about
> the Y axis from a rotation.
Hi Steve,
This works:
Script {
eventIn SFRotation set_rotation IS set_rotation
eventOut SFRotation rotation_changed IS rotation_changed
url "java script:
function set_rotation (r) {
angle = -Math.atan2(r.x*r.z*(1 - Math.cos(r.angle)) +
r.y*Math.sin(r.angle), r.z*r.z*(1 - Math.cos(r.angle)) +
Math.cos(r.angle) );
rotation_changed = (new SFRotation ( 0,1,0,angle )).inverse();
}
"
}
Regards,
Brian Hay.
| |
| Brian Hay 2005-01-28, 7:42 pm |
| Steve Smith wrote:
> Can anynone give me some javascript which extracts just the rotation about
> the Y axis from a rotation.
Oops, sorry, here's the whole PROTO. Now the Script cade makes more sense.
#VRML V2.0 utf8
PROTO C3D_ExtractYRotation [
eventIn SFRotation set_rotation
eventOut SFRotation rotation_changed
]
{
Script {
eventIn SFRotation set_rotation IS set_rotation
eventOut SFRotation rotation_changed IS rotation_changed
url "java script:
function set_rotation (r) {
angle = -Math.atan2(r.x*r.z*(1 - Math.cos(r.angle)) +
r.y*Math.sin(r.angle), r.z*r.z*(1 - Math.cos(r.angle)) +
Math.cos(r.angle) );
rotation_changed = (new SFRotation ( 0,1,0,angle )).inverse();
}
"
}
}
Regards,
Brian Hay.
| |
| Steve Smith 2005-01-29, 7:19 pm |
| Thanks !
This is exactly what I needed.
"O.L." <nowhere@invalid.net> wrote in message
news:mn.d3877d51fcbeba76.18740@invalid.net...
> Steve Smith a écrit :
about[color=darkred]
>
> NewRotation = new SFRotation(0, MyRotation.y, 0, MyRotation.angle);
>
> But I'm not sure that it is what you're looking for :-S
>
> Bye
> O.L.
>
> --
> Ceci est une signature automatique de MesNews.
> Site : http://mesnews.no-ip.com
>
| |
| Steve Smith 2005-02-05, 6:22 pm |
| Thanks !
This is exactly what I needed.
"O.L." <nowhere@invalid.net> wrote in message
news:mn.d3877d51fcbeba76.18740@invalid.net...
> Steve Smith a écrit :
about[color=darkred]
>
> NewRotation = new SFRotation(0, MyRotation.y, 0, MyRotation.angle);
>
> But I'm not sure that it is what you're looking for :-S
>
> Bye
> O.L.
>
> --
> Ceci est une signature automatique de MesNews.
> Site : http://mesnews.no-ip.com
>
| |
| Brian Hay 2005-02-19, 11:17 pm |
| Steve Smith wrote:
> Thanks !
> This is exactly what I needed.
[color=darkred]
> about
Although a simpler formula, this doesn't properly account for pitch and
roll so the more extreme the X and Z components, the bigger the "jump"
in the calculated Y rotation.
I don't fully understand the math really, so my explanation is probably
overly simplistic. All I know is that the complex formula I posted was
created by some math professors many years back and in practice it works
perfectly for ALL rotations.
Can't find original post but here's another discussion:
http://groups.google.com.au/groups?...6435d2%2540post
ing.google.com%26rnum%3D2
Brian.
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|