POV-Ray : Newsgroups : povray.general : help with rotation, gimbal lock? quaternions? Server Time
6 Aug 2024 17:01:13 EDT (-0400)
  help with rotation, gimbal lock? quaternions? (Message 1 to 9 of 9)  
From: =Bob=
Subject: help with rotation, gimbal lock? quaternions?
Date: 8 Mar 2002 17:24:41
Message: <3c893a29@news.povray.org>
I'm afraid I just don't have the background to
understand this yet. But I have need to know
the angles for x,y and z of a tangent to a sphere
that has been rotated on all axes. From what I
have read, quaternions are the answer to this.
Could someone point me to a way to implement
this in Pov? Maybe someone has already made
a set of macros?

Thanks for all your kind help!
=Bob=


Post a reply to this message

From: Peter Popov
Subject: Re: help with rotation, gimbal lock? quaternions?
Date: 9 Mar 2002 09:56:07
Message: <6slj8u4c7c2sjefvbsajhvhkga0889vv54@4ax.com>
On Fri, 8 Mar 2002 14:25:40 -0800, "=Bob=" <bob### [at] threestrandscom>
wrote:

>I'm afraid I just don't have the background to
>understand this yet. But I have need to know
>the angles for x,y and z of a tangent to a sphere
>that has been rotated on all axes. From what I
>have read, quaternions are the answer to this.
>Could someone point me to a way to implement
>this in Pov? Maybe someone has already made
>a set of macros?

Do it the POV way. Compute the transformation that would transform a
unit sphere into your sphere, then take the point you want to find the
tangent at, inverse-transform it to the unit sphere, find the normal
at that point (for a sphere it's easy -- vnormalize(point) :)) and
transform that normal back to your sphere. And the tangent is easy
when you have the normal.

Hope I didn't mess this up.


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: chaps
Subject: Re: help with rotation, gimbal lock? quaternions?
Date: 12 Mar 2002 07:33:17
Message: <3c8df58d@news.povray.org>
Hi Bob,

Do you know the value of tangent before all rotation?

If yes, you only need the same transform to this tangent and you get the new
value. (I'm not sure that it is true if scaling with non isotropic value,
for example <1,2,1>. What doe's news group think about this.).

Chaps.

"=Bob=" <bob### [at] threestrandscom> wrote in message
news:3c893a29@news.povray.org...
> I'm afraid I just don't have the background to
> understand this yet. But I have need to know
> the angles for x,y and z of a tangent to a sphere
> that has been rotated on all axes. From what I
> have read, quaternions are the answer to this.
> Could someone point me to a way to implement
> this in Pov? Maybe someone has already made
> a set of macros?
>
> Thanks for all your kind help!
> =Bob=
>
>
>


Post a reply to this message

From: Ron Parker
Subject: Re: help with rotation, gimbal lock? quaternions?
Date: 12 Mar 2002 10:26:02
Message: <slrna8s7gc.cge.ron.parker@fwi.com>
On Tue, 12 Mar 2002 13:33:35 +0100, chaps wrote:
> Hi Bob,
> 
> Do you know the value of tangent before all rotation?
> 
> If yes, you only need the same transform to this tangent and you get the new
> value. (I'm not sure that it is true if scaling with non isotropic value,
> for example <1,2,1>. What doe's news group think about this.).

Transforming vectors is different from transforming points.  I think the
transpose of the transformation matrix is involved somehow; I'd have to check
the code to be sure.

-- 
#local R=rgb 99;#local P=R-R;#local F=pigment{gradient x}box{0,1pigment{gradient
y pigment_map{[.5F pigment_map{[.3R][.3F color_map{[.15red 99][.15P]}rotate z*45
translate x]}]#local H=pigment{gradient y color_map{[.5P][.5R]}scale 1/3}[.5F
pigment_map{[.3R][.3H][.7H][.7R]}]}}}camera{location.5-3*z}//only my opinions


Post a reply to this message

From: Christopher James Huff
Subject: Re: help with rotation, gimbal lock? quaternions?
Date: 12 Mar 2002 12:04:57
Message: <chrishuff-C84B87.12042912032002@netplex.aussie.org>
In article <slr### [at] fwicom>,
 Ron Parker <ron### [at] povrayorg> wrote:

> Transforming vectors is different from transforming points.  I think the
> transpose of the transformation matrix is involved somehow; I'd have to check
> the code to be sure.

For directions, you transform using the inner 3*3 portion of the matrix 
(basically dropping translation). For normals, you have to transform by 
the transpose of this matrix.

(I recently had to do exactly this, so it is fairly fresh in my mind)

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

From: Peter Popov
Subject: Re: help with rotation, gimbal lock? quaternions?
Date: 14 Mar 2002 00:07:22
Message: <glb09ucfqm2gani7cmill9q035608e2rtg@4ax.com>
On Tue, 12 Mar 2002 12:04:29 -0600, Christopher James Huff
<chr### [at] maccom> wrote:

>For normals, you have to transform by the transpose of this matrix.

You know, I've never done it that way. Doesn't make much sense unless
some tangents are involved. A normal is, after all, a vector. The only
thing you might want to do is to normalize the result if you need a
unit-length normal. So I don't get the transpose idea.


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Christopher James Huff
Subject: Re: help with rotation, gimbal lock? quaternions?
Date: 14 Mar 2002 09:40:54
Message: <chrishuff-E5217F.09403614032002@netplex.aussie.org>
In article <glb09ucfqm2gani7cmill9q035608e2rtg@4ax.com>,
 Peter Popov <pet### [at] vipbg> wrote:

> You know, I've never done it that way. Doesn't make much sense unless
> some tangents are involved. A normal is, after all, a vector. The only
> thing you might want to do is to normalize the result if you need a
> unit-length normal. So I don't get the transpose idea.

Try unevenly scaling a sphere. A vector from the center to a point on 
the surface (the normal of an unscaled sphere) goes one way, but the 
normal goes the opposite direction. And how about shearing a box? You 
will end up slanting the normal of the sides which don't change 
orientation.
I don't really understand the reason the transpose does what it does, 
but it is needed. This was discussed in some of the old Ray Tracing News 
articles.

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

From: Peter Popov
Subject: Re: help with rotation, gimbal lock? quaternions?
Date: 15 Mar 2002 02:17:44
Message: <7k739u4hvrtp1um8nhc8n77d554ohj92ch@4ax.com>
On Thu, 14 Mar 2002 09:40:37 -0600, Christopher James Huff
<chr### [at] maccom> wrote:

>Try unevenly scaling a sphere. A vector from the center to a point on 
>the surface (the normal of an unscaled sphere) goes one way, but the 
>normal goes the opposite direction. And how about shearing a box? You 
>will end up slanting the normal of the sides which don't change 
>orientation.

Well, what I do is inverse-transform the point of intersection
(accounting for translation) so that it is in the object's own
coordinate sphere, then use a simple formula to determine the normal
of a unit object, then transform that normal back to global space
(ignoring translation, of course). This works. And of course it might
just turn out that I am doing what you're doing, only slower <g>. I
need to explore this better.


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Christopher James Huff
Subject: Re: help with rotation, gimbal lock? quaternions?
Date: 15 Mar 2002 10:06:32
Message: <chrishuff-8FB571.10061615032002@netplex.aussie.org>
In article <7k739u4hvrtp1um8nhc8n77d554ohj92ch@4ax.com>,
 Peter Popov <pet### [at] vipbg> wrote:

> Well, what I do is inverse-transform the point of intersection
> (accounting for translation) so that it is in the object's own
> coordinate sphere, then use a simple formula to determine the normal
> of a unit object,

This is the usual way of doing this part.


> then transform that normal back to global space (ignoring 
> translation, of course). This works. And of course it might just turn 
> out that I am doing what you're doing, only slower <g>. I need to 
> explore this better.

It doesn't work. Think about what it's doing...
Assume the translation is scale < 1, 0.5, 1>. When you transform the 
normal back into the global space as a direction, you end up halving the 
y component, making it more perpendicular to the y axis. This is the 
opposite of what you want to do...the normal should point *more* along 
the y axis.

And again with the sheared box...say you shear the +y axis in the +x 
direction. You inverse-transform the intersection point and compute the 
normal of an intersection on the top of the box as < 0, 1, 0>. Your 
method will shear this vector, when it should remain < 0, 1, 0>.

I don't fully understand why using the transpose here works, but it does 
in my own experiments, and POV seems to use it.

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

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