POV-Ray : Newsgroups : povray.general : translation / rotation query : Re: translation / rotation query Server Time
20 Apr 2024 03:56:05 EDT (-0400)
  Re: translation / rotation query  
From: Bald Eagle
Date: 18 Sep 2019 15:55:01
Message: <web.5d828b0a4dd2969c4eec112d0@news.povray.org>
Bob Frew <bob### [at] ntlworldcom> wrote:
> Hi ,
> does anyone knows a way to achieve the following.
>
> For any line with p1 and p2 as the end points to translate/rotate as
> necessary to put
>          p1 at <0,0,0> and p2 on the x axis
> I need to then know necessary translate/rotate to be able to put them
> back.
>
> I can see how to do this by evaluating all possible orientations for p2
> after moving p1 to <0,0,0>
> This will end up very "heavy duty" so (as I know nothing of matrices
> etc.) I thought I would ask you guys if there is a more elegant way
> before going down that road.
>
> Hopeful     ... Bob
>
> A pointer in the right direction would be good (no pun intended)

You're going to first translate the line segment to the origin.

Then you can determine the angle of the p2 endpoint projected onto the x-z
plane.
an atan2 with that vector and <1,0,0> gives you a rotation around the y axis.

Then you do another atan2 with the resulting vector in the x-y plane to give the
rotation angle around the z axis necessary to place it coincident with the
x-axis.

You simply rotate around z by the negative angle, rotate around y by _that_
negative angle, and translate back to the original p1.

Just simple trig - no matrices.

Check out       http://f-lohmueller.de/pov_tut/a_geo/a_geo80e.htm


Post a reply to this message

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