Actually drawing some ovals – that are not ellipses (2017)
medium.com
medium.com
[0] https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandard..., sec. 8.5.2, "Path Construction Operators"
Down at the lowest level the engine can only really do straight lines. You may ask for a circle or a bezier, but the engine only approximates this with enough fidelity that you wouldn't notice the flaws. Beziers end up being approximated as a bunch of tiny line segments. Circles and ellipses can be approximated pretty easily as a handful of beziers.
Beziers are particularly useful because they have some handy properties. You don't need to do any trig to calculate them (like you do for arcs). They're extremely simple to compute, and any bezier curve can be split into two smaller bezier curves. That last fact makes it easier to have varying fidelity along the curve.
Source: was on the original SVG Working Group team @ Adobe.
def bezier(t, *handles):
"""Computes a single point of a bezier of any order where 0 <= t <= 1."""
if len(handles) == 1:
return handles[0]
else:
pairs = zip(handles[:-1], handles[1:])
return bezier(t, *[_bezier_interpolate(t, a, b) for a, b in pairs])
def _bezier_interpolate(t, a, b):
return [a * (1-t) + b * t for a, b in zip(a, b)]
assert bezier(0.25, [1, 1, 1], [2, 2, 2], [3, 4, 5]) == [1.5, 1.5625, 1.625]
You can pass it any order of bezier (cubic, quadratic, etc.) for any number of dimensions, and how for along the interpolation you are. It will give you a single point. Connect a bunch together to get your curve. You can actually stop when `len(handles) == 2` and you get line segments instead of points, but it's slightly less accurate.You can see the math for computing a point (or segment) is trivial (addition and multiplication) and it can be easily parallelized. It can even be a one-liner, but that isn't very readable.
Here's a good website for visualizing the math: https://www.summbit.com/blog/bezier-curve-guide/
[1] - e.g. https://en.wikipedia.org/wiki/B%C3%A9zier_curve#Rational_B%C...
It's one of the reasons a lot of residential development, especially suburban development of the last 40 years, looks as bad as it does. Little to no architectural thought goes into many new homes beyond what's easiest to build.
I grew up in an area with a lot of corn field subdivisions and McMansions. They tend to have a lot of volume/floor space and incredibly poor detailing. On the one hand, I find it hard to believe that anyone building such a big, cheap (at least in the details sense) home on spec would include an elliptical arch. On the other hand, the kinds of contractors that put them up would likely be the kind that struggled to execute such a design element.
I say this having just been very humbled putting up crown in a bathroom. People tell me it looks great, and I reply that it had sure better considering the two weeks of evenings that went into putting it up!
I've shopped for houses a lot, and after "training" mostly on typical '80s+ suburban houses, noticed that when looking at older houses with saner, calmer designs, I'd have to add 500-1,000(!)sqft to my first-impression guesses at their size to get close, while I'd gotten pretty good at guessing the "McMansion" and mini-McMansion style. The older designs don't look as big, at the same size.
[0] https://medium.com/@brunopostle/hey-ovals-are-better-than-el...