|
![](/i/fill.gif) |
I need to find the rotation angle (always counter clockwise) of a vector around
z axis. I have a script but too slow, no precise... and I'm sure some of you who
did pay attention at school will find an easier way to do this, here is the
script in case you want to check, it tries to make a box that points to vector
"vect":
#include "colors.inc"
#include "math.inc"
#declare vect = <1,-1,0>;
#declare ang = 0;
#declare hipo = VDist ( <0,0,0>, vect );
#declare vect2 = vect;
camera{
location <0, 0, -10>
look_at 0
angle 30
}
light_source{ <2,20,-20> White }
sphere { 0 .025 pigment { rgb <0,0,1> }} // ORIGIN
sphere { vect .025 pigment { rgb <1,0,0> }}
#while (VDist(<0,hipo,0>, vect2) > .1)
#declare vect2 = vrotate (vect2, <0,0,1>);
#declare ang = ang + 1;
sphere { vect2 .025 pigment { rgb .5 } }
#end
box { <-.25,0,.25>, .25 pigment { rgb .5}
scale <.25,1,.25>
rotate <0,0,ang * -1>
}
Post a reply to this message
|
![](/i/fill.gif) |