|
|
"kurtz le pirate" <kur### [at] yahoofr> wrote in message
news:kurtzlepirate-B3CE05.17471210112008@news.povray.org...
>
> i have 3 points in space. the plan goes through these three points can
> be defined as :
>
> plane {vcross (P2-P1,P3-P1),0 translate P1}
>
> ok... but now, how to find angles beteewn "standard (0,x,y,z)" and this
> new "coordinate system" ?
>
> eulers's angles seem to be the solution but I do not see how to compute
> it :(
>
> any help ?
The example below shows one way, using transforms.inc to work out the
transformation necessary.
It looks a lot of SDL, but the transform calculation is only the short bit
in the middle, the rest is just a mass of cylinders, spheres and a plane to
illustrate what's going on (though be prepared for the rendered image to
look a bit messy :-) ).
The transformation is worked out in two steps. The first bit works out the
rotation required to align the Z-axis with the new Z-axis, which I've
assumed to be pointing from P1 to P2. The second works out the rotation
around the Z-axis to align the Y-axis with an adjusted copy of the new
Y-axis (derived from your calculated plane normal). After that you just need
to assemble a complete transform (which can also include the translation to
P1) and you've got an easy way of transposing stuff from the POV-Ray
coordinate system to your new coordinate system. You can also use the
'inverse' keyword to reverse the transformation if you need to.
Regards,
Chris B.
camera {location <1,1,-4> look_at 1}
light_source { <0,100,-10>, 1 }
#include "transforms.inc"
cylinder {-10*x,10*x,0.01 pigment {rgb <1,0.5,0.5>}}
cylinder {-10*y,10*y,0.01 pigment {rgb <0.5,1,0.5>}}
cylinder {-10*z,10*z,0.01 pigment {rgb <0.5,0.5,1>}}
#declare P1 = <1,1,1>;
#declare P2 = <2,1,2>;
#declare P3 = <2,0.2,0>;
#declare NewY = vnormalize(vcross(P2-P1,P3-P1));
#declare NewZ = vnormalize(P2-P1);
// Start calculating transform
#declare ZTransform = transform {Reorient_Trans(z, NewZ)}
#declare YTransform = transform {Reorient_Trans(y,
vinv_transform(NewY,ZTransform))}
// Construct a single transform
#declare TotalTransform = transform {
transform {YTransform}
transform {ZTransform}
translate P1
}
// End calculating transform
cylinder {0,NewY,0.008 pigment {rgb <0,10,0>}}
cylinder {0,NewZ,0.008 pigment {rgb <0,0,10>}}
plane {y,0.000001
transform {TotalTransform}
pigment {rgbt <1,1,1,0.8>}
}
sphere {P1,0.08 pigment {rgb <1,1,1>}}
sphere {P2,0.05 pigment {rgb <1,1,0>}}
sphere {P3,0.05 pigment {rgb <0,1,1>}}
cylinder {-10*x,10*x,0.03 pigment {rgb <1,0,0>} transform {TotalTransform}}
cylinder {-10*y,10*y,0.03 pigment {rgb <0,1,0>} transform {TotalTransform}}
cylinder {-10*z,10*z,0.03 pigment {rgb <0,0,1>} transform {TotalTransform}}
box {0,0.4 pigment {rgb <1,1,0>} transform {TotalTransform}}
Post a reply to this message
|
|
|
|
In article <491886ec$1@news.povray.org>, "Chris B" <nom### [at] nomailcom>
wrote:
> "kurtz le pirate" <kur### [at] yahoofr> wrote in message
> news:kurtzlepirate-B3CE05.17471210112008@news.povray.org...
> >
> > i have 3 points in space. the plan goes through these three points can
> > be defined as :
> >
> > plane {vcross (P2-P1,P3-P1),0 translate P1}
> >
> > ok... but now, how to find angles beteewn "standard (0,x,y,z)" and this
> > new "coordinate system" ?
> >
> > eulers's angles seem to be the solution but I do not see how to compute
> > it :(
> >
> > any help ?
>
> The example below shows one way, using transforms.inc to work out the
> transformation necessary.
> It looks a lot of SDL, but the transform calculation is only the short bit
> in the middle, the rest is just a mass of cylinders, spheres and a plane to
> illustrate what's going on (though be prepared for the rendered image to
> look a bit messy :-) ).
>
> The transformation is worked out in two steps. The first bit works out the
> rotation required to align the Z-axis with the new Z-axis, which I've
> assumed to be pointing from P1 to P2. The second works out the rotation
> around the Z-axis to align the Y-axis with an adjusted copy of the new
> Y-axis (derived from your calculated plane normal). After that you just need
> to assemble a complete transform (which can also include the translation to
> P1) and you've got an easy way of transposing stuff from the POV-Ray
> coordinate system to your new coordinate system. You can also use the
> 'inverse' keyword to reverse the transformation if you need to.
>
> Regards,
> Chris B.
>
> [code]
hello chris,
excellent example but it is not quite what I wanted. in fact i just
wanted to "put" this three points in space on the plane {y, 0} for
"landing" objects.
from your code, I do some modifications and I get what I want.
#declare newY=vnormalize(vcross(p2-p1,p3-p1));
// just convert from rectengular to polar
// angle -> <distance, azimut,height>
#declare angles=r2p(-newY,true);
and i just add this transforms to my object :
object {
...
...
rotate -angles.y*y
rotate -(90-angles.z)*z
}
of course, 'p1.y' is always zero.
thanks too :)
--
klp
Post a reply to this message
|
|