I am writing a Win32 application in Visual C ++ using Direct2D. I drew two lines, at the first coordinate (x1, y1) , and at the second - (x2, y2) . CompareWithGeometry function to determine if these lines intersect. The function replied that they do not overlap. Turned the first line by 20 degrees. Again called CompareWithGeometry . She said that now intersect.

I need to know the coordinates (x, y) of the intersection point. How can I do this in Direct2D?

    1 answer 1

     BOOL isIntersectLine(const LPPOINT a1, const LPPOINT a2, const LPPOINT b1, const LPPOINT b2){ float t, dot; POINT c; POINT b = { a2->x - a1->x, a2->y - a1->y }; POINT d = { b2->x - b1->x, b2->y - b1->y }; dot = (float)(bx * dy - by * dx); if(dot == 0.0f) return FALSE; cx = b1->x - a1->x; cy = b1->y - a1->y; t = (float)(cx * dy - cy * dx) / dot; if((t < 0.0f) || (t > 1.0f)) return FALSE; t = (float)(cx * by - cy * bx) / dot; if((t < 0.0f) || (t > 1.0f)) return FALSE; return TRUE; }