POV-Ray : Newsgroups : povray.general : How to rotate an arbitrary object by a vector? Server Time
8 Oct 2024 16:31:47 EDT (-0400)
  How to rotate an arbitrary object by a vector? (Message 1 to 2 of 2)  
From: Kima
Subject: How to rotate an arbitrary object by a vector?
Date: 6 Jun 2020 08:05:00
Message: <web.5edb8551fe498ce0ecc0fada0@news.povray.org>
Consider an object centred at <0,0,0>

box{<-2,-1,-1>,<2,1,1>}

and a vector define by two points (V = P2 - P1). How we can rotate the object to
be along with the given vector?

My idea is to calculate the normalized vector of V, then calculate the arcsine
and arccosine for the corresponding axis.

However, I feel it is not the right way or at least an overkill. Seems like I've
missed my geometry class!


Post a reply to this message

From: Bald Eagle
Subject: Re: How to rotate an arbitrary object by a vector?
Date: 6 Jun 2020 09:15:01
Message: <web.5edb96b52426427afb0b41570@news.povray.org>
"Kima" <nomail@nomail> wrote:
> Consider an object centred at <0,0,0>
>
> box{<-2,-1,-1>,<2,1,1>}
>
> and a vector define by two points (V = P2 - P1). How we can rotate the object to
> be along with the given vector?
>
> My idea is to calculate the normalized vector of V, then calculate the arcsine
> and arccosine for the corresponding axis.
>
> However, I feel it is not the right way or at least an overkill. Seems like I've
> missed my geometry class!

This is a somewhat common need, and POV-Ray has some macros written to help.

Check out
Reorient_Trans( Axis_1, Axis_2 )
and
Point_At_Axis( New_Y_Axis )

in "transforms.inc"

http://www.f-lohmueller.de/pov_tut/trans/trans_470e.htm


Post a reply to this message

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