|
![](/i/fill.gif) |
I wrote this code to work with the geodesic macro. it takes a position
vector and rotateds an object (here a torus) so it's y axis is along
that vector. the position vector is on a sphere centered at the origin,
so it is exactly the same as a surface normal. Uses trig to get z and y
euler angles.
#macro do_corner(position)
#local a = position.x;
#local b = position.y;
#local c = position.z;
// union
// {
torus
{
.08,.035
pigment {color rgb <1,1,0>}
// }
// cylinder
// {
// <0,-.2,0>,<0,.2,0>,.04
// pigment {color rgb <1,0,0>}
// }
#local thetaz = asin(b);
#local thetay = asin(c);
#if (a<0)
#local thetaz = pi-thetaz;
#end
#if (a>0)
#local thetay = -thetay;
#end
rotate 90*z
rotate z*thetaz*(180/pi)
rotate y*thetay*(180/pi)
translate position
}
#end
Doug Eichenberg wrote:
> Let's say I have an object "A" at the origin, and a known surface normal
> <x,y,z>. I want to find the rotation vector <Rx,Ry,Rz> of the surface
> normal <x,y,z>, such that when I rotate "A":
>
> object{ A rotate<Rx,Ry,Rz> }
>
> it lies along the surface normal.
>
> I tried doing this as follows:
>
> object{ A rotate<atan2d(Norm.y,Norm.z), atan2d(Norm.x,Norm.z),
> atan2d(Norm.x,Norm.y)>
>
> but I seem to be getting strange results.
>
> Anyone have code they used for doing this? Or know how in general?
> Thanks for the help.
>
> --
> Doug Eichenberg
> www.getinfo.net/douge
> dou### [at] nls net
>
>
Post a reply to this message
|
![](/i/fill.gif) |