-3

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

Let:

  • A=(Ax,Ay)
  • B=(Bx,By)
  • C=(Cx,Cy)
  • BC(BCx, BC.y) are middle point between B and C
  • A and B are L1
  • B and C are L2

How do I get the point cross(Mx,My) from the perpendicular line (B->A) and (middleBC->C)?

Any ideas how to get it?

ChrisF
  • 134,786
  • 31
  • 255
  • 325
Brieg
  • 63
  • 13
  • Possible duplicate of [How do you detect where two line segments intersect?](http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect) – Saeid Sep 03 '16 at 12:52
  • 2
    These are basic geometry concepts. If you don't know these you should probably try to learn these before trying to code it. Anyway you can use geometry libraries do them for you. – Saeid Sep 03 '16 at 13:04

2 Answers2

2

Lets assume line l1 is the line perpendicular to AB from point B. You have one point from this line (B) and you have its slope (Because its perpendicular to AB). So you can simply write its equation.

And assume line l2 is the line perpendicular to BC from point middle BC. again you can write l2 equation similar to what explained above.

The desired point is intersection of l1 and l2. So you simply have to solve the system of equations of l1 and l2.

Saeid
  • 4,147
  • 7
  • 27
  • 43
2

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.

Community
  • 1
  • 1
md5
  • 23,373
  • 3
  • 44
  • 93
  • @Brieg: This is a description (a kind of parametrized equation, actually) of the line. It is just use for the purpose of mathematical notation, you don't have to code it really. In fact, you should rather check [this](https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection#Given_two_points_on_each_line) (the link in my answer is rather for line _segments_ intersections). So, given two points on each line (B and B'/I and I') you can compute the coordinates of M. – md5 Sep 04 '16 at 13:14
  • @Brieg: I can't reach your link. – md5 Sep 06 '16 at 13:03