POV-Ray : Newsgroups : povray.advanced-users : Speaking of Mathematics : Re: Speaking of Mathematics Server Time
28 Jul 2024 16:22:03 EDT (-0400)
  Re: Speaking of Mathematics  
From: Mike Raiford
Date: 7 Dec 2004 07:49:03
Message: <41b5a6bf@news.povray.org>
Slime wrote:

>>#local rx = degrees(acos(vdot(d, <0, d.y, d.z>)));
>>#local ry = degrees(acos(vdot(d, <d.x, 0, d.z>)));
>>#local rz = degrees(acos(vdot(d, <d.x, d.y, 0>)));
> 
> 
> I'm not sure exactly what you were trying to do here (I'm sure there's logic
> to it but I'm just not following it), but chances are after you do the
> rotate rx*x (if that's what you're doing), the ry and rz rotations are no
> longer useful for the object's new position.
> 
> Another thing to consider is that only two rotations should be needed to
> make an object point in a certain direction. (This is because a direction
> can be represented as a point on the surface of the unit sphere, and the
> surface of a sphere is 2 dimensional.) For instance, if an object is
> pointing in the positive x direction, a rotation between -90 and +90 degrees
> around the z axis, followed by a rotation between -180 and +180 degrees
> around the y axis is enough to orient the object in any direction. (A
> rotation around the x axis could be done before either of these to have
> control over how the object is rotated around the axis it's going to point
> in.)
> 
> In any case, there's no point (besides educational reasons) to go through
> all this work, since you can just use the Reorient_Trans macro in
> transforms.inc to do what you want. (The macro doesn't use rotations, it
> instead creates a matrix transformation; this is a more straightforward way
> of approaching the problem if you understand the math.)
> 
>  - Slime
>  [ http://www.slimeland.com/ ]
> 
> 
The macro did work for me, except one small problem: there's a "twist" 
at one part in the spline that doesn't seem to make sense. Other than 
that, it worked as expected. I might have been overthinking the problem 
a bit, and .. yeah, it was a bit of an accedemic exercise for me, but, 
It started to bug me that there seemed to be no solution. (The rotations 
being null and void after a rotation occurred to me, but for some reason 
I felt that the effect could be negated by some mathematical "magic"

What I had done, or think I had done was get the angles from the X, Y 
and Z axes. The two other coordinates were left so the angle would be 
calculated from the same pane (axis, oriented in the direction of the 
remaining coordinates, that should get the angle from the plane, right?)

I've done similar stuff at work, but due to the nature of what I was 
doing it was always in 2-space, and thus doesn't suffer the exponential 
increase in problems that 3-space tends to.  (There's really only 1 axis 
of rotation in 2D, unless you consider perspective transforms to be 
another "axis")

-- 
~Mike


Post a reply to this message

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