# Ray-point intersection

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,

A ray point intersection is mathematical possible, but not on PCs .

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

Originally posted by BlackJack:
[b]A ray point intersection is mathematical possible, but not on PCs .

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[/b]

I am not sure if I am following you…

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

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).]

Originally posted by BlackJack:
[b]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).][/b]

I never thought I’d catch myself doing this but…

BlackJack: I’m not a Mess, I’m a Mezz!

-Mezz