POV-Ray : Newsgroups : povray.advanced-users : math quiz Server Time
30 Jul 2024 10:20:36 EDT (-0400)
  math quiz (Message 1 to 5 of 5)  
From: Sigmund Kyrre Ås
Subject: math quiz
Date: 7 Dec 1999 15:29:34
Message: <384D6DDA.51142915@stud.ntnu.no>
Any idea how I can rotate a torus for instance so it's aligned with a
vector? This doesn't quite do the trick, but illustrates what I'm after
(and how stupid I am):

rotate
   x*degrees(atan2(n.z,n.y))+
   y*degrees(atan2(n.x,n.z))+
   z*degrees(atan2(n.x,n.y))

Where n would be the new "normalvector" for the torus.

sig


Post a reply to this message

From: Josh English
Subject: Re: math quiz
Date: 7 Dec 1999 16:31:18
Message: <384D7C83.5A721635@spiritone.com>
There is a standard orientation macro that looks like this:

#macro Orient(v1,v2)
  #local nx = vnormalize(v2 - v1);
  #local nz = vnormalize(vcross(nx,y));
  #local ny = vcross(nz,nx);
  matrix <nx.x,nx.y,nx.z,
          ny.x,ny.y,ny.z,
          nz.x,nz.y,nz.z,
          v1.x,v1.y,v1.z>
#end

This only works if the object "faces" the positive x axis... so you might
want to rotate your torus by 90*z before including the macro:

torus { 1, 0.25 // or whatever
            rotate 90*z
            Orient(thisvector, thatvector) }

It is possible (and I've don't it before but I don't have the file handy)
to rearrange the first three lines of the macro that will make the
rotation command unnecessary.

Good Luck




> Any idea how I can rotate a torus for instance so it's aligned with a
> vector? This doesn't quite do the trick, but illustrates what I'm after
> (and how stupid I am):
>
> rotate
>    x*degrees(atan2(n.z,n.y))+
>    y*degrees(atan2(n.x,n.z))+
>    z*degrees(atan2(n.x,n.y))
>
> Where n would be the new "normalvector" for the torus.
>
> sig

--

Josh English
eng### [at] spiritonecom
ICQ: 1946299
"Stress is when you wake up screaming and realize you haven't fallen
asleep yet."


Post a reply to this message

From: Sigmund Kyrre Ås
Subject: Re: math quiz
Date: 8 Dec 1999 11:45:02
Message: <384E8B06.B4EF5A47@stud.ntnu.no>
Thanks a bunch! I finally understand the transformation matrix. The
documentation isn't very good.

Josh English wrote:

> There is a standard orientation macro that looks like this:
>
> #macro Orient(v1,v2)
>   #local nx = vnormalize(v2 - v1);
>   #local nz = vnormalize(vcross(nx,y));
>   #local ny = vcross(nz,nx);
>   matrix <nx.x,nx.y,nx.z,
>           ny.x,ny.y,ny.z,
>           nz.x,nz.y,nz.z,
>           v1.x,v1.y,v1.z>
> #end
>
> This only works if the object "faces" the positive x axis... so you might
> want to rotate your torus by 90*z before including the macro:
>
> torus { 1, 0.25 // or whatever
>             rotate 90*z
>             Orient(thisvector, thatvector) }
>
> It is possible (and I've don't it before but I don't have the file handy)
> to rearrange the first three lines of the macro that will make the
> rotation command unnecessary.
>
> Good Luck
>


Post a reply to this message

From: Josh English
Subject: Re: math quiz
Date: 8 Dec 1999 18:11:49
Message: <384EE5B4.3AE4265E@spiritone.com>
I pride myself on being able to explain anything, but John VanSickle explains
the Matrix better than I ever could. Take a look at
http://users.erols.com/vansickl/matrik.htm for more details



> Thanks a bunch! I finally understand the transformation matrix. The
> documentation isn't very good.
>
> Josh English wrote:
>
> > There is a standard orientation macro that looks like this:
> >
> > #macro Orient(v1,v2)
> >   #local nx = vnormalize(v2 - v1);
> >   #local nz = vnormalize(vcross(nx,y));
> >   #local ny = vcross(nz,nx);
> >   matrix <nx.x,nx.y,nx.z,
> >           ny.x,ny.y,ny.z,
> >           nz.x,nz.y,nz.z,
> >           v1.x,v1.y,v1.z>
> > #end
> >
> > This only works if the object "faces" the positive x axis... so you might
> > want to rotate your torus by 90*z before including the macro:
> >
> > torus { 1, 0.25 // or whatever
> >             rotate 90*z
> >             Orient(thisvector, thatvector) }
> >
> > It is possible (and I've don't it before but I don't have the file handy)
> > to rearrange the first three lines of the macro that will make the
> > rotation command unnecessary.
> >
> > Good Luck
> >

--

Josh English
eng### [at] spiritonecom
ICQ: 1946299
"Stress is when you wake up screaming and realize you haven't fallen asleep
yet."


Post a reply to this message

From: Remco de Korte
Subject: Re: math quiz
Date: 8 Dec 1999 19:38:53
Message: <384EF9C8.AB4F4490@xs4all.nl>
Josh English wrote:
> 
> I pride myself on being able to explain anything, but John VanSickle
> explains
> the Matrix better than I ever could. Take a look at
> http://users.erols.com/vansickl/matrik.htm for more details
> 

Very educational!

(http://users.erols.com/vansickl/matrix.htm)

Remco


Post a reply to this message

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