Collision Detection
How to know the smaller distance between a line segment and a point? I need it to make my collision detection!
Thanks, Arthur(rockslave)
import money.*;#include "cas.h"uses bucks;
ola!
first, you get one point from the line segment (one of the extremes).
then you get the vector that goes from that point of the line segment to the other point you want to know the distance(let''s call it a).
now you make the projection of that vector over the line vector.
(call it b)
know you use h^2 = c1^2 + c2^2, where h is the length of a and c1 is the length of b.
c2=sqrt( h2^2-c1^2 )
first, you get one point from the line segment (one of the extremes).
then you get the vector that goes from that point of the line segment to the other point you want to know the distance(let''s call it a).
now you make the projection of that vector over the line vector.
(call it b)
know you use h^2 = c1^2 + c2^2, where h is the length of a and c1 is the length of b.
c2=sqrt( h2^2-c1^2 )
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement