Brieg Brieg - 4 months ago 53
C++ Question

How to get cross point from perpendicular line (B->A) and (middleBC->C)?

How can I draw a curve which is part of the circle (depending on the end point)?


  • A=(Ax,Ay) be the first point (A)

  • B=(Bx,By) be the second point (B)

  • C=(Cx,Cy) be the end point (mouse location) (C)

  • MBC(MBCx, MBC.y) are middle between B and C

  • p2 and p2 are line AB

  • p4 and p3 are line CD

How do I get the point
from the perpendicular line

-enter image description here

Any ideas how to code it?

md5 md5

Let I((B.x + C.x) / 2, (B.y + C.y) / 2) be the middle point of [BC] and I'(I.x + I.y - C.y, I.y + C.x - I.x) (90° rotation of C around I). Then the perpendicular to (BC) going through I is I + tII' (for any real number t). Likewise with B' be the 90° rotation of A around B, the perpendicular to (AB) going through B is B + uBB' (for any real number u).

enter image description here

Now you just have to find the intersection point of these two lines. See here for related issues.