Point on a line a given distance from another point

Started by
12 comments, last by CGameProgrammer 21 years, 5 months ago
As I said I got it working even before you wrote your first post... but I'm calculating mindistance completely differently from you; you keep saying it's (endpoint - point) dot direction, but it's the size of the cross-product. I initially used the dot-product and it turned out to be incorrect.

~CGameProgrammer( );

EDIT: You do know that A . B indicates a dot product, right? A x B means a cross-product.

[edited by - CGameProgrammer on November 2, 2002 6:28:12 PM]
~CGameProgrammer( );Developer Image Exchange -- New Features: Upload screenshots of your games (size is unlimited) and upload the game itself (up to 10MB). Free. No registration needed.
Advertisement
The other side of the right triangle. The magnitude of the cross product is one side, i.e. c*sin(theta), and the other side is the dot product, i.e. c*cos(theta).
Keys to success: Ability, ambition and opportunity.
Oh, you mean the distance from the nearest point to the circle-intersection point? I just used the Pyathagorean Theorem to find that. It works at any rate.

~CGameProgrammer( );

EDIT: Oh so I see what you were saying. With "(p-p0).d" you found the distance from the nearest point to the line's endpoint and got the point that way, and used Pythagorean's to get the distance from the external point to the nearest point. Whereas I did it the other way, using (p-p0)xd to find the distance from the external point to the nearest point, and using Pythagorean's to get the distance from the line's endpoint to the nearest point.

Of course that would mean the fastest thing would in fact be not using Pythagorean's at all and using the dot and cross products to get both vectors, since square root is slow. I'll have to try that.

[edited by - CGameProgrammer on November 2, 2002 6:54:33 PM]
~CGameProgrammer( );Developer Image Exchange -- New Features: Upload screenshots of your games (size is unlimited) and upload the game itself (up to 10MB). Free. No registration needed.
((p-p0)xd)xd+p=((p-p0).d)*d+p0=np and |(np-p)|=|(p-p0)xd|. Either way you are going to have to find the magnitude of a vector. You can find the nearest point without a square root, but not the distance of the point from the line. If you actually want to know where the intersections of the line and circle are you need the nearest point and the dot product is an easier way to find that.
Keys to success: Ability, ambition and opportunity.

This topic is closed to new replies.

Advertisement