[PD] Gem: trigonometry in 3D space

gml at xs4all.nl gml at xs4all.nl
Fri Jul 11 18:39:34 CEST 2003


First to base everything on sphere1 S(x1,y1,z1) as the origin and
transalate later.

that means S2 is centered on (x2-x1,y2-y1,z2-z1)
which is also the direction and length of the cylinder.
(So I get a length of
             2         2         2
sqrt( (x2-x1) + (y2-y1) + (z2-z1) )

How you get your length formula is interesting, it looks like using the
in-product without the angle component.

angle with respect to the xy plane: arctan((y2-y1)/(x2-x1))
                          xz plane  arctan ((z2-z1)/(x2-x1)).

This is what is needed to calculate the angles.
And  transalate over (x1,x2,x3) when you are done.

Or you can use [rotate] with the (x2-x1, y2-y1,z2-z1) vector. No need to
calculate the angles. And then translate to S1.

Hope this helps

Gerard










> Hi,
>
> I'm having a little trouble conceptually with trigonometric concepts in
> gem. Any hints of tutorials or examples that could help me with the
> following problem would be really useful.
>
> Imagine that I have two spheres, translated in XYZ to random positions
> (let's assume (x1,y1,x1) and (x2,y2,z2).
>
> I want to put a cylinder to join the two, and make the cylinder move
> with the spheres (in other words, imagine the cylinder is a rubber band
> stretched between the two spheres.)
>
> Calculating the length of the cylinder (which I change with scaleXYZ) is
> not very difficult, I can obtain it with sqrt (x2 * x1 + y2 * y1 + z2 *
> z1).
>
> The tricky part, on the other hand is finding the correct amount of
> rotation in xyz for the cylinder, and the correct displacement.
>
> Thanks in advance.
>
> - martin
>
>
>
> _______________________________________________
> PD-list mailing list
> PD-list at iem.at
> http://iem.at/cgi-bin/mailman/listinfo/pd-list
>





More information about the Pd-list mailing list