|
I have been playing around with PaperJS for the last couple of days, and I have some questions - none of which seem to be in the docs (which are still spotty.) First, it has a built in for describing an Arc. As in - a part of a circle. So common sense (or at least MY common sense) would mean it would look something like: code:
code:
code:
To which my response is: what in the actual gently caress? Who thinks of an Arc that way? So I only got as far as Algebra 2 in HS, and I'm sure there's some mathematical reason why you can specify an Arc that way, but I have no idea what it is. Playing around with the numbers is not shedding any light on it. More importantly, can someone tell me how to translate from (center, radius, degrees) to (from, through, to)?
|
# ? Oct 22, 2014 12:54 |
|
|
# ? May 10, 2024 03:21 |
|
Given any three distinct points in the plane, either those three points are on the same straight line, or there's a unique circle that passes through them all. In the case where you want an arc of a circle, there's still a unique arc, provided you distinguish one of the points as being "the one in the middle". So at least mathematically you can specify an arc of a circle in that way. Why the library creators chose to have you specify it in that way I don't know. You say you want to specify an arc using (radius, center, degrees), but what is degrees here? The angle at the centre of the circle? That doesn't tell us where the arc should start or end, unless you mean it to start at North (0 degrees) or something. In other words, if you say you want a circular arc where degrees is 90, how am I to know whether that's the arc that goes from north to east, or from southwest to northwest, or some other arc? Another parameter is needed to tell me (say) where the arc starts. If the centre of a circle is at (a, b) and it has radius r, and you want the arc that starts at angle x and ends at angle y, then the end points are (a + r cos x, b + r sin x) and (a + r cos y, b + r sin y) and we also need a point on the circumference in between the two angles, which can be (a + r cos z, b + r sin z) where z = (x + y) / 2. I don't know how feasible this is as an approach if you need to draw very many circular arcs in a computationally efficient manner.
|
# ? Oct 22, 2014 13:39 |
|
Hammerite posted:Given any three distinct points in the plane, either those three points are on the same straight line, or there's a unique circle that passes through them all. In the case where you want an arc of a circle, there's still a unique arc, provided you distinguish one of the points as being "the one in the middle". So at least mathematically you can specify an arc of a circle in that way. Why the library creators chose to have you specify it in that way I don't know. Sorry. Yes - degrees is from the center of the circle, with an arbitrary direction (in this case 'west' or pointing directly left) as 0 degrees. You don't need to know in the context of the library, since you can rotate an arc after the fact to place it where you want. I guess you could pass in a 4th argument as a "starting direction", it's just in this case "0 degrees" is pointing due west. I was not aware of that 3 points on a plane rule, hence my complete and utter confusion as to why someone would represent an Arc that way. My programming career for nearly 20 years has been all application development stuff, so I have never needed so much math before. Guess I probably need to pick up a book and bone the gently caress up. Arguably - it's a strange convention on the part of the library creators. They also express circle measurements in degrees, which is unusual - since nearly every other graphics library I have encountered uses radians.
|
# ? Oct 22, 2014 14:03 |