0

I'm looking to get a point list of n points on an arc; I will know the start point, end point and radius.

The user would be building an arc with 3 mouse clicks, the first two to define the start and the end and the third to would set the size of the radius.

Thanks.

Edit: I don't just need to render it - I also need the point list, so using a rendering API to do this won't cut it.

Questioning
  • 1,903
  • 1
  • 29
  • 50
  • Possible duplicate of [Draw an arc based on 2 Points and radius](http://stackoverflow.com/questions/11387493/draw-an-arc-based-on-2-points-and-radius) – TaW Apr 26 '16 at 13:27
  • Typically with languages like C# and Java, the standard libraries include a drawing API, so you don't need to figure out the pixel coloring algorithm on your own; you just need to handle the user interaction and do the drawing via a library. – adv12 Apr 26 '16 at 13:28
  • @TaW I added Java and C# because I know both languages enough to convert from one and the other. And obviously the points would be based on a variable, something like segments. Honestly there's really no need to be so arrogant. – Questioning Apr 26 '16 at 13:31
  • @adv12 I specifically need the points to be manipulated at a later date. Just drawing them isn't the point. – Questioning Apr 26 '16 at 13:32
  • 2
    As I told you: there is an infinite number of points on an arc. You ought to rell us a lot more about what you want to __achieve__. What kind of manipulation are you talking about? And for what __purpose__..? And: This is a site for coding problems, __not__ for geometry. And of course your title __explicitly__ asks about __drawing__ the arc. You may want to have a look at [this post](http://stackoverflow.com/questions/36795556/how-to-draw-sql-server-circularstring-in-c-sharp/36799693#36799693) to get a hints about how to calculate.. – TaW Apr 26 '16 at 13:34
  • What about using a bezier line to draw the arc? that would probably be easier to manipulate afterwards – Pikoh Apr 26 '16 at 13:38
  • @Pikoh I've considered it for the rendering but I need the points on the arc to run calculations at a later point. – Questioning Apr 26 '16 at 13:41
  • Well, pointing out errors is a good attitude in my book; I didn't mean to hurt your feeling, though. To get n points: find the center and then the n crossings of the n lines going between the center and the two outer points, increasing the angle by (alph - beta)/n. So you need to write code to create a line from two points, from one point and an angle, find a perpendicular and the intersections between a line and a cricle. – TaW Apr 26 '16 at 13:42
  • 1
    You could look at a computational geometry library like the [JTS Topology Suite](http://tsusiatsoftware.net/jts/main.html) (Java) or its .NET counterpart, [NetTopologySuite](https://github.com/NetTopologySuite/NetTopologySuite). – adv12 Apr 26 '16 at 13:42
  • 1
    I think you're asking the wrong question. This is not a two-points-radius problem, but a three-points. –  Apr 26 '16 at 18:44
  • @YvesDaoust Most certainly you are correct. I phrased myself poorly twice, it seems. The radius would be the third point in my phrasing - the third click. – Questioning Apr 26 '16 at 20:30
  • @Questioning: this phrasing is still questionable. You want to click a third *point* on the circle, don't you ? –  Apr 26 '16 at 21:02

1 Answers1

2

Let h be the half distance between the start and end points. By Pythagoras, the distance from the midpoint and the center of the circle is w=√r²-h². You will find that center by drawing a line segment of length w perpendicularly from the midpoint.

The starting angle of the arc is given by tan(φ)=δy/δx, between the starting point and the center, and similary for the ending point.

Then your n points have the coordinates

Xc + r cos(φs + k (φe-φs)/(n-1))
Yc + r sin(φs + k (φe-φs)/(n-1))

for k= 0,1,...n-1.

enter image description here

  • Just to clarify; delta y and delta x are represented by the angle between S and C and E and C? If I were to increase the distance of C this would also increase the angle of the circle, correct? – Questioning Apr 26 '16 at 20:29
  • @Questioning: "increase the distance of C", what do you mean ? –  Apr 26 '16 at 20:57
  • I'll just reply to you here instead of the other place and tell you what I want. S and E are set with first and second click. Then the last click should set the angle of the curve, if that makes sense. A larger distance will net a larger angle. Example: If the third click is at the same spot as the second the angle should be 0 so the rendered arc should just be a straight line. So what I am looking for is which variable would control this. – Questioning Apr 26 '16 at 22:08
  • @Questioning: sorry, I don't understand. In particular "A larger distance will net a larger angle". –  Apr 26 '16 at 22:30
  • @YvesDaust Here is an image. Black is first click, orange is second, red is third. http://i.imgur.com/g6rUa75.png Does this help? – Questioning Apr 26 '16 at 22:56
  • @Questioning: well it suffices to compute the distance third point/segment. But this is a strange convention. Why not the arc through the third point ? –  Apr 27 '16 at 00:05
  • 1
    @Questioning Friendly user (mouse) interface cases: He designates 1. start and end arc points and circle center 2. start, end, some intermediate point 3. center,start point, end angle. The last point choice have to be interactive (dynamically build temporary arc when user moves mouse). – MBo Apr 27 '16 at 05:26
  • @mbo: for option 1, you need to constrain the center to lie on the bissectrix. –  Apr 27 '16 at 06:40
  • @Yves Daoust Yes, and would be nice to show to user calculated center point as projection of pointer to bisector. – MBo Apr 27 '16 at 06:46
  • @MBo Option 1 is basically what I had in mind. Thanks for all the help. – Questioning Apr 27 '16 at 09:58
  • I don't understand the answer. What is the spaghetti symbol? Looks like greek to me. – Garrett Jul 21 '22 at 20:45
  • @Garrett: yes, it is Greek. Apparently, spaghetti translates to μακαρόνια. –  Jul 22 '22 at 07:27