the maths is tricky enough that i don't have time to work it out right now. however, if you are just placing the spheres in random positions, it would be much easier to construct the sphere-cycliner-sphere contruction along an axis, with perhaps a random length for the cylinder, and then randomly rotate and translate the whole construction.
pix.
On Fri, 11 Jul 2003 16:08:39 +0100 "Martin Dupras" martin.dupras@uwe.ac.uk wrote:
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@iem.at http://iem.at/cgi-bin/mailman/listinfo/pd-list