POV-Ray : Newsgroups : povray.general : translation / rotation query : Re: translation / rotation query Server Time
25 Apr 2024 18:14:13 EDT (-0400)
  Re: translation / rotation query  
From: Bob Frew
Date: 19 Sep 2019 07:04:14
Message: <5d8360ae$1@news.povray.org>
On 18/09/2019 19:51, Bob Frew 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)
> 
Hi and thanks for those replies.

After I posted the query I remembered a piece of code from years ago I 
had used. So I dug it out this morning. Someone else may need this

#macro placeObj(obj,V1,V2)
    #local mp = <(V1.x + V2.x)/2,(V1.y + V2.y)/2,(V1.z + V2.z)/2>;  // 
mid point
    #local V2N = V2 - mp;
    #local V3 = VPerp_To_Plane(V1, V2);

    #declare newxdir = vnormalize(V2N);
    #declare newydir = vnormalize(V3);
    #declare newzdir = vcross(newxdir, newydir);
    #declare transamnt = mp;

    #declare placedObj = object {obj
            matrix < newxdir.x, newxdir.y, newxdir.z,
                     newydir.x, newydir.y, newydir.z,
                     newzdir.x, newzdir.y, newzdir.z,
                     transamnt.x, transamnt.y, transamnt.z >
               }
#end

I may have tweaked this, but I did not write it (anyone know who did ?)
It seems to work well.

The problem is I don't understand it so I will probably write my own as 
per Bald Eagle suggestion.
My subconscious must have known there was a matrix in there somewhere.

Thanks again    .... Bob


Post a reply to this message


Attachments:
Download 'smiley3.png' (2 KB)

Preview of image 'smiley3.png'
smiley3.png


 

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