The task There is such a task in C #. The figure itself consisting of circles and straight lines I drew. It is necessary to circle it with a fat line. I plan to find the points of intersection of the circles using this algorithm. It is necessary to find the points of intersection of lines and circles, and then I think so it is necessary to draw arcs, or somehow make an array of points and draw points. How to do it better? If you draw arcs, how to draw an arc through 2 extreme points and knowing the radius of the circle along the border of which the arc will pass.

  • If you give a part of the code that needs to be processed, then the rest will be easier for you to help - lexxl
  • @lexxl is just the thing that the code is not yet. I just drew a general figure with three circles and three straight lines - Artem Kochegizov
  • What are you drawing then? If the task allows, you can use the built-in combination of primitives and get the result at the lowest cost. - Alex Krass
  • @AlexKrass I paint in paintbox in C Sharp - Artem Kochegizov
  • Well, at least winforms or wpf? - VladD

1 answer 1

There is a lot of options, depending on your desire to deal with trigonometry. I now have to break for such a task to consider angles and arcs. For me, for example, the simplest option seems to be this: absolutely all the points that are in the figure (points of lines and circles) are shoved into an array and drawn separately (because there must be a function "draw a thick point"). Next, we do a check: if the point is strictly inside a triangle or any circle, we make it normal fat, if not, then we do it fat. The points of lines and circles themselves can be found using the Bresenham algorithm . It is not necessary to take from Wikipedia, full of ready-made implementations on the network. It is clear that the proposed method is ineffective, but the essence of such stupid tasks is to pass the task. If the task were more interesting, I would calculate the angles and honestly draw the arcs.

  • one
    I'm afraid that the teacher will not appreciate this approach, but thanks for the hint - Artem Kochegizov
  • one
    In this case, I see no difficulty in calculating points, angles and drawing arcs using the method of the type DrawArc. A little math - and everything is ready. Or do you want to help you calculate? Another option: draw all the contours in bold, and make the figures themselves (circles and triangle) as if translucent and white inside (say, 50% transparency). With their translucency, they make the part of the points that is not so fat that it falls strictly inside them. Of course, if semi-transparency exists in language functions. - Zealint
  • so I ask how to calculate the arcs - Artem Kochegizov
  • Well, here the tasks are not solved for you. I can say an idea. You can find the points on the circle itself (you wrote it yourself). Now we transfer the frame to the center of the circle (subtract from the coordinates of the point the coordinates of the center of the circle). Now, let the point on the arc have coordinates (X, Y). The tangent of the angle is determined by the ratio Y / X (here we must also consider the number of the quarter in which the points lie and the case X = 0). Knowing the tangent, you know the angle of the first point (through arctangent) relative to the axis OX. Also with the second point. Then the arc drawing function should receive two angles to the input - from which to which to which to draw. - Zealint