|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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] nlsnet
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hey Doug!
Perphaps the "Reorient_Trans"-macro from "transforms.inc" could help you?
Check out its description at http://www.povray.org/documentation/view/281/
HTH,
Florian
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Thanks for the response Florian. Not sure if that macro would work or
not... I may have found another solution. My mistake (I think) was in
revolving around the x-axis... no need to do that. Instead I do one
rotation on the z-axis, then another on the y-axis, then translate the
object. Basically, this seems to mimic spherical polar coordinates.
Testing it now to see if it works.
--
Doug Eichenberg
www.getinfo.net/douge
dou### [at] nlsnet
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Okay that doesn't seem to work either :P Gonna set it aside awhile and work
on something else.
--
Douglas C. Eichenberg
dou### [at] nlsnet
http://www.getinfo.net/douge
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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.
Without checking your trigonometry, I can see you have fallen prey to one of
the most popular - and my first - error of trigonometric transformation.
Try 'object { A rotate < degrees(atan2(Norm.y,Norm.z), ... etc.) > }'
The problem is the inverse trig functions return radians, and rotate
expects degrees. Forward trig functions also -take- radians, so, pretty much
any time you want to use the trig functions you have to constantly use the
radians() and degrees() functions as well.
Good luck!
--Chris
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hmm, I was thinking that atan2d returned degrees. Gonna have to go back and
check. Thanks for the reply!
--
Douglas C. Eichenberg
dou### [at] nlsnet
http://www.getinfo.net/douge
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Okay I tried it both ways, and I am getting the same result. I think I see
where my problem is though. If I only rotate on one axis, a view down that
axis looks right. As soon as I put another axis into the rotation, it gets
messed up. What I need to do is create a new axis after the first rotation
that is perpendicular to the vector after the initial rotation, then rotate
around that (if any of that makes any sense, my technical speaking skills
suck). Anyhow, off to try that approach now.
--
Douglas C. Eichenberg
dou### [at] nlsnet
http://www.getinfo.net/douge
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Check the Rotate_Around_Trans() macro in transforms.inc.
Section 7.19 of the help file.
--
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}// - Warp -
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Yeah I looked into that, but the object being rotated was already placed at
the origin, so I don't think that macro would make any difference. However,
in desperation, I tried Reorient_Trans... using the axis the object was
defined along (y-axis) as the first argument, and the surface normal as the
second argument. Running a test now, and it seems to work.
--
Doug Eichenberg
www.getinfo.net/douge
dou### [at] nlsnet
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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] nlsnet
>
>
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|