POV-Ray : Newsgroups : povray.general : Rotating an object : Re: Rotating an object Server Time
31 Jul 2024 06:15:53 EDT (-0400)
  Re: Rotating an object  
From: John VanSickle
Date: 6 Oct 2007 12:09:05
Message: <4707b321$1@news.povray.org>
Ger wrote:
> John VanSickle wrote:
> 
> 
>>You really don't need to do this arcsin and rotation stuff.
>>
>>The better way to do it is:
>>
>>#local vZ=vnormalize(Position2-Position1);
>>#local vX=vnormalize(vcross(y,vZ));
>>
>>and replace the rotate and translate with this:
>>
>>matrix < vX.x,        vX.y,        vX.z,
>>          0,           1,           0,
>>          vZ.x,        vZ.y,        vZ.z,
>>          Position1.x, Position1.y, Position1.z>
>>
>>It may help you with this to also read
>>
>>   http://www.geocities.com/evilsnack/matrix.htm ,
>>
>>which is tutorial I wrote about the matrix transform.
>>
>>Regards,
>>John
> 
> 
> I had it figured out with a lot of #if's in it, but I tried your solution
> anyway because it looks so much more elegant. 
> But now a wall is rotated y * 90 from where it is supposed to be.

If the wall is built along the x axis prior to is positioning, then use 
this code to calculate vX and vZ:

#local vX=vnormalize(Position2-Position1);
#local vZ=vnormalize(vcross(vX,y));

The matrix remains the same.

Regards,
John


Post a reply to this message

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