Points of Graphic Oval
mark at livecode.com
Wed Aug 2 15:13:55 EDT 2017
Bézier curves are a polynomial - usually quadratic (2nd degree) or cubic (3rd degree) but the model extends to arbitrary order.
With four cubic Bézier curves (so 8 quadratic) you can make an exceptionally good approximation to an oval - but it is not exact.
Indeed (anyone who might have a better memory of this than I, please correct me) from memory, to accurately represent an oval (or arc - any general planar quardratic shape written naturally as a quadratic polynomial in TWO not ONE variable - eg x^2 + y^2 = 0) you would require an infinite single variate polynomial (and I think this would only work for a quadrant too). This can be seen from the fact that to compute cos/sin/tan (which are the mathematical primitives in some sense acting here) require a 'taylor' expansion which is an infinite polynomial sequence (with order tending to infinity) which converges to the required value.
Enough abstract math over - here the only 'issue' with the effectivePoints for the purpose described is that it does not take into account radius to adjust the number of generated points - hence the 'too many points at certain sizes' problem.
Now this is not an error or bug - I remember Mark (not me!) submitting that PR and reviewing it - what he did was entirely reasonable given that there were no apparent use-cases at the time, and without use-case then you can only make things generally useful, and not specifically useful. (After all 360 is a key number as it is the number of DEGREES in a full circle - so is something which is understandable to most).
Indeed, what is actually needed here is to approximate the required arc based on a notion of 'flatness' and 'pixel positioning'. Meaning that you want the line segments to have minimal maximal (that is not a typo a for once!) perpendicular distance from the true curve, and still be large enough to sit at pixel positions so as not to cause jitter (a slightly subjective idea).
I strongly suspect Malte's animationEngine does this 'correctly' for this case as it was designed with this kind of use case in mind.
Anyway I know this thread has gone on a bit and perhaps the above is not really useful anymore but I thought it (1) might be interesting and (2) might perhaps encourage the more mathematically minded among us (and yes, I have one or two specific people in mind!) to maybe find a spare moment to 'do the math' and write up how it should work.
And yes, there are those on the team who probably could - but I think all of us have long sinced 'hung up' our mathematician's cowels and are now focused on more concrete day to day endeavours... However, that focus does perhaps mean we could happily implement whatever correct (relative to this use case - which is probably the singularly most important one!) solutions appear.
Sent from my iPhone
> On 31 Jul 2017, at 22:23, Bob Sneidar via use-livecode <use-livecode at lists.runrev.com> wrote:
> Both are part of the joke. I shouldn't explain it because that is like disecting a frog. The frog dies and nobody cares. :-)
> But geometrically in any line there are an infinite number of points, because a point is an infinitely small coordinate. That's if by point you mean literally points in the geometrical sense. But if you mean how many pixels on a given display to create a visually smooth curve, well that is another matter. And if by points you meant anchors in a vector based drawing program, why typically 4 points, although 3 will do, I just don't know how perfect the circle can be and I thing an oval would require 4.
> See? The frog died and nobody cares!
> Bob S
>>> On Jul 31, 2017, at 08:34 , hh via use-livecode <use-livecode at lists.runrev.com> wrote:
>>> Bob S. wrote:
>>> By strict geometry, an infinite amount. Using Bezier, 4. :-)
>> Just because I am curious which part of your statement is the joke:
>> How do you define "strict geometry"?
>> And what is an "infinite amount"?
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the Use-livecode