POV-Ray : Newsgroups : povray.animations : Vectors POV Server Time
28 Jul 2024 16:30:16 EDT (-0400)
  Vectors POV (Message 1 to 4 of 4)  
From: Nils Steinkamp
Subject: Vectors POV
Date: 25 May 1999 05:14:02
Message: <374a5bca.0@news.povray.org>
Hi there,

I have a little problem with the rotation of an object.

I have 2 points, < x1 , y1 , z1 > and < x2 , y2 , z2 > , and an object at
the origin orientated in x-axis.
Now I want to rotate the object that way that it has the same direction that
the line from point 1 to point 2 has. The translation is done by other math,
I only need to rotate the object about origin.

I tried much with vnormalize() and so on, but the results never looked like
they should...

Thanks,

Nils

http://www.steini.de


Post a reply to this message

From: Josh English
Subject: Re: Vectors POV
Date: 31 May 1999 13:33:43
Message: <3752B9DC.FD94C4E2@spiritone.com>
Try this: (untested at this point)


#declare p = <anynumber,0,0>;
#declare v1 = anyvector;
#declare v2 = anyothervector;

#declare v3 = v2 - v1;
#declare v4 = vnormalize(v3);
#declare zrot = degrees(atan2(v4.y,v4.x));
#declare yrot = degrees(atan2(v4.z,v4.x));

#declare p2 = vrotate(p,<0,yrot,zrot>);

p2 should have the new position of the object

You also might want to check out John VanSickle's Matrix page at
http://www.erols.com/vansickl/matrix.htm

Joshua
eng### [at] spiritonecom


Nils Steinkamp wrote:
> 
> Hi there,
> 
> I have a little problem with the rotation of an object.
> 
> I have 2 points, < x1 , y1 , z1 > and < x2 , y2 , z2 > , and an object at
> the origin orientated in x-axis.
> Now I want to rotate the object that way that it has the same direction that
> the line from point 1 to point 2 has. The translation is done by other math,
> I only need to rotate the object about origin.
> 
> I tried much with vnormalize() and so on, but the results never looked like
> they should...
> 
> Thanks,
> 
> Nils
> 
> http://www.steini.de


Post a reply to this message

From: Nils Steinkamp
Subject: Re: Vectors POV
Date: 1 Jun 1999 06:32:17
Message: <3753a8a1.0@news.povray.org>
Hi there !

I fixed the problem by using

    #declare NX = vnormalize( Punkt_naechster - Punkt_vorher );     // last
and next point
    #declare NZ = vnormalize(vcross(NX,y));
    #declare NY = vcross(NZ,NX);

    object { Test2               // has to declared before
       matrix < NX.x            , NX.y            , NX.z,
                NY.x            , NY.y            , NY.z,
                NZ.x            , NZ.y            , NZ.z,
                Punkt_aktuell.x , Punkt_aktuell.y , Punkt_aktuell.z >  //
the actuell translation
    }

where the basic object is orientated from -x to +x

In this case the x-axis is orientated to the right, y-axis to the top and
z-axis from camera away to the depth of the room. The full code is
downloadable on my site, see adress at the end of the mail.

It works fine, when putting the object on a spline, it is rotated to follow
the spline.

Next step is the proclivity of the object to rotate it in x-axis left when
"flying" a left turn or right when "driving" a left turn.
Not as easy as it seems, but I'm on my way ;-)

Nils

http://www.steini.de


Post a reply to this message

From: Bob Hughes
Subject: Re: Vectors POV
Date: 1 Jun 1999 20:47:26
Message: <375470F1.AF1B59DB@aol.com>
First off, I really like your web pages. Secondly, I'm just trying to do
something like you have shown here. Hopefully I can use your helpful
script to my benefit; that will of course depend on my ability to
understand it.


Nils Steinkamp wrote:
> 
> Hi there !
> 
> I fixed the problem by using
> 
>     #declare NX = vnormalize( Punkt_naechster - Punkt_vorher );     // last
> and next point
>     #declare NZ = vnormalize(vcross(NX,y));
>     #declare NY = vcross(NZ,NX);
> 
>     object { Test2               // has to declared before
>        matrix < NX.x            , NX.y            , NX.z,
>                 NY.x            , NY.y            , NY.z,
>                 NZ.x            , NZ.y            , NZ.z,
>                 Punkt_aktuell.x , Punkt_aktuell.y , Punkt_aktuell.z >  //
> the actuell translation
>     }
> 
> where the basic object is orientated from -x to +x
> 
> In this case the x-axis is orientated to the right, y-axis to the top and
> z-axis from camera away to the depth of the room. The full code is
> downloadable on my site, see adress at the end of the mail.
> 
> It works fine, when putting the object on a spline, it is rotated to follow
> the spline.
> 
> Next step is the proclivity of the object to rotate it in x-axis left when
> "flying" a left turn or right when "driving" a left turn.
> Not as easy as it seems, but I'm on my way ;-)
> 
> Nils
> 
> http://www.steini.de

-- 
 omniVERSE: beyond the universe
  http://members.aol.com/inversez/homepage.htm
 mailto://inversez@aol.com?Subject=PoV-News


Post a reply to this message

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