Brieg - 9 months ago 34

C++ Question

I can not put questions in one line also here they are:

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

Let:

- p1=(x1,y1) be the first point
- have to be line p2=(x2,y2) is the starting point of drawing the curve
- p3=(x3,y3) be the end point (mouse location)

Requirements:

- if P3 is going closer to p2, the larger the potential radius becomes
- p3 describes the drawing direction
- if p3 is pararel to p2 there nothing should be drawn (or drawn line p3>p2)
- if p3 is equal to p1 it should draw a relatively large wheel,

I think i found solution how to draw that part of circle, please look at that gifs below:

Answer

- Tangent
`A->B`

implies a normal-line`Q`

that passes through the (as-yet unfound) circle center`D`

- Find the midpoint
`M`

of chord`R`

(i.e., segment`B-C`

). - A line
`S`

perpendicular to`R`

passing through`M`

also passes through`D`

So: Construct lines `Q`

and `S`

and find their intersection `D`

. The length of segment `B-D`

is the radius of the circle. With the radius and center `D`

you should be able to calculate the arc `B->C`

.

_{in b4 9000 hours in mspaintpaint.net}

Source (Stackoverflow)