1

My question is probably more about maths rather than programming, but I hope that is not a problem. In my app, I am calculating some movement paths, consisting of pixel coordinates (only calculating, not displaying them). I am now trying to smoothen the turn, which are now too sharp, so I would like to use some arc here. I found how I could draw the exact arc I need, using code like this:

e.Graphics.DrawArc(myPen, myPoint.X, myPoints.Y, 50, 50, 180, 90);

Basically what I know are three points (the arc will be between two of these, third is now the turn's corner), the height and width of the arc, the initial and wanted course/heading/angle. I tried this in an app that visualizes the path later, and it works. However, I need to calculate some coordinates on the arc, to add to the array of Points that I save as the path. Anyone knows how? I would need about 5 points for an arc of this size (the number of points will change however) Thanks

BRAHIM Kamel
  • 13,117
  • 31
  • 46
Marek Buchtela
  • 943
  • 3
  • 18
  • 39
  • http://stackoverflow.com/questions/674225/calculating-point-on-a-circles-circumference-from-angle-in-c, http://stackoverflow.com/questions/839899/how-do-i-calculate-a-point-on-a-circle-s-circumference, http://stackoverflow.com/questions/5300938/calculating-the-position-of-points-in-a-circle – CodeCaster Sep 19 '14 at 13:42

1 Answers1

1

DrawArc draws a part of an ellipse or a circle in your case (regarding the 4th and 5th parameter.) The radius of your circle is 25. The math of a circle is: x^2 + y^2 = r^2. Therefore, I think you can calculate points on this circle by calculating:

Y = myPoint.Y + 25 +/- Sqrt(625 - (X - myPoint.X - 25)^2).

Let X run from myPoint.X to myPoint.X + 50 and you will find some corresponding Y's. Because it is a circle, each X has 2 Y values (Therefore, +/- in the formula; you need to calculate the + and the -).

John Alexiou
  • 26,060
  • 8
  • 73
  • 128
Sjips
  • 1,228
  • 1
  • 10
  • 20
  • Note I edited the post for readability with code formatting. Please see http://stackoverflow.com/help/formatting for help – John Alexiou Sep 19 '14 at 14:08
  • Hi, what if I need like a hundred points from the arc? How could I do it? I mean, how could I take only points from the arc, and not from the circle – bellotas Feb 24 '20 at 08:30