Advertisement

Relitive position questions

Started by April 23, 2003 01:06 AM
4 comments, last by RMan326 21 years, 9 months ago
I''ve dug through my math books trying to find an answer to this one, but its been no use so far, heres my problem. I have two objects in 3d space, and I need to draw a line to connect their midpoints. To do this, I need to know the sphereical coordnates between them (angle on the XY plane, angle from the Z axis, and distace from the orgin). I''ve tried using the cartiesian to spherical conversions my calc book gives, but the lines dont draw anywhere near right. Anyone have a solution to this problem? Thanks in advance
I''m confused. If you''re just drawing a line between the midpoints of objects whose position you already know, what are you doing messing with spherical coordinates?


How appropriate. You fight like a cow.
Advertisement
It was late when I posted that, lemme try explaining my problem better.

I have two spheres in space, and I want to draw a line between them. I know the locations of both spheres. I need to know the yaw, pitch, and roll (well, I dont think I need roll) angles between them.

Does that clarify the problem?

Thanks
It seems to me that what you want to do is this: you have two spheres, and you want to figure out the spherical coordinates of one, relative to the other. If this is the case, here''s your solution: to find coordinates of B (bx,by,bz) relative to A (ax,ay,az), translate both of them the same amount so that A'' is at the origin, then take point B'' (bx'',by'',bz'') and convert that to spherical coordinates according to your equations. Hope that helped. By the way, I think you should post your conversion equations, in case there''s a typo in your book.
You know what I never noticed before?
I still have to ask, why do you think you need spherical coordinates if you are only trying to draw a line? You have sphere 1 and sphere 2''s centers, just draw a line between the two cartesian points.

However, if you''re saying that you need to know the yaw, pitch of sphere 2 wrt sphere 1, then I agree with vanillacoke''s answer.

Regards,
Jeff
I''ll just say that I agree with Jeff that the problem of drawing a line between two known points isn''t as difficult as you''re making it. I too see no need to introduce spherical coordinates to draw a line between two known points. In OpenGL, for example, you could just do this:

glBegin(GL_LINES);
glVertex(midpoint_1.x, midpoint_1.y, midpoint_1.z);
glVertex(midpoint_2.x, midpoint_2.y, midpoint_2.z);
glEnd();


Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net

This topic is closed to new replies.

Advertisement