• Advertisement


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

Point on line

This topic is 5439 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

  • Advertisement