PDA

View Full Version : Ray-point intersection



vitaliy
07-10-2002, 05:18 AM
Hi, I am working on developing a tool that finds the same points in the same object viewed from different cameras. One of the objectives is to find a point and determine a vector that goes thru this point and the camera, that is easy. Then I have to translate the vector into another camera's view and find a point there. Translating a vector is easy, but what would be the best algorithm for finding a point that I want? Thanks,

BlackJack
07-10-2002, 10:33 AM
A ray point intersection is mathematical possible, but not on PCs http://www.opengl.org/discussion_boards/ubb/wink.gif.

If would propose following:

if( VAngle(VDifference(Point,StartCoord),Ray)<Tollerance )
return true;
else
return false;

Or you can use DistanceLinePoint and search for the nearest point.

All functions for this should be findeable all over the internet.

BlackJack

vitaliy
07-10-2002, 11:28 AM
Originally posted by BlackJack:
A ray point intersection is mathematical possible, but not on PCs http://www.opengl.org/discussion_boards/ubb/wink.gif.

If would propose following:

if( VAngle(VDifference(Point,StartCoord),Ray)<Tollerance )
return true;
else
return false;

Or you can use DistanceLinePoint and search for the nearest point.

All functions for this should be findeable all over the internet.

BlackJack

I am not sure if I am following you...

Mezz
07-10-2002, 02:10 PM
I think the imprecision of PC arithmatic units dictates that you can't find a perfectly exact intersection. This is why he included a "< tolerance" part to the if statement. This will provide an intersection within the tolerance you provide (a very small number - 0.0001 would probably do).

-Mezz

BlackJack
07-10-2002, 11:53 PM
Mess : Exactly... when using a 32 bit floating point variable anyway, hehe

vitality : Your topic sounds like you're searching for a routine testing if a ray "cuts" a point. What I posted is a possible way to do this. But your description was also a bit irritating.

BlackJack

[This message has been edited by BlackJack (edited 07-11-2002).]

vitaliy
07-11-2002, 03:24 AM
Originally posted by BlackJack:
Mess : Exactly... when using a 32 bit floating point variable anyway, hehe

vitality : Your topic sounds like you're searching for a routine testing if a ray "cuts" a point. What I posted is a possible way to do this. But your description was also a bit irritating.

BlackJack

Yeah, I am sorry. I know what you mean and I do understand the algorithm that you described. However I think that I stated my question a little bit incorrectly, my bad. Here is the deal. I have a cube and I have the same cube viewed from a different viewport. I want to be able to identify the same verticies in both of the cubes. I select on one cube and I want to find a corresponding one on the other cube. So I determine a ray that stretches from camera_1 to the first vertex on the cube. Then I translate the same ray into coordinates of the second viewport and I would like to find the closest point on the cube to that ray. Thank you for your help.

[This message has been edited by BlackJack (edited 07-11-2002).]

Mezz
07-11-2002, 06:31 AM
I never thought I'd catch myself doing this but...

BlackJack: I'm not a Mess, I'm a Mezz! http://www.opengl.org/discussion_boards/ubb/wink.gif

-Mezz