POV-Ray : Newsgroups : povray.advanced-users : Box pointing to target vector : Box pointing to target vector Server Time
2 Jul 2024 19:08:37 EDT (-0400)
  Box pointing to target vector  
From: MadKairon
Date: 28 Mar 2010 07:00:00
Message: <web.4baf35a774e65dc05e975f010@news.povray.org>
I have this box:

box { <-.025,0,-.025>, <.025,1,.025> pigment { rgb .2} }

And this 3D vector:

#declare vect = <1,1,-1>;

Question:

How do I rotate my box so that the top faces the vector "vect"?

I've been trying with some trigonometrical functions... atan2() helps but my
skills are failing me here :( this is as far as I could get

#declare rad = VDist(<0,0,0>,vect);
#declare cat1 = <0,rad,0>;
#declare cat2 = VDist(cat1,vect);
box { <-.025,0,-.025>, <.025,VDist(<0,0,0>, vect),.025> pigment { rgb <.2,0,0>}
    rotate <0,0,degrees( atan2( rad, cat2 ) )-90>
    }

but the arctan angle seems to be wrong and that's only a rotation around Z,
still need to rotate it again around either X or Y y guess...


Post a reply to this message

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