Archived

This topic is now archived and is closed to further replies.

steg

Point on line

Recommended Posts

steg    390
Hi all, I''m using this formula to detect whenever the mouse icon is over a line (writing a map editor in directx) : Y - Y1 = m ( X - X1) where m = (Y2 - Y1)/(X2 - X1) and the code: BOOL CGeometry:ointOnLine(int x, int y, CLine* pLine) { int slope = (pLine->m_y2 - y1) / (pLine->m_x2 - x1); int yf = y - y1; int xf = slope * (x - x1); return yf = yf == xf; } The more slope on the line, the worse the detection is ? Any ideas ? Kind regards, Steve

Share this post


Link to post
Share on other sites