Wednesday, June 28, 2017

A conclusion shopping around for a theory.

You sir are a donkey fucker. Okay, maybe you're not a donkey fucker, since there's no evidence of that. You sir, are a chicken fucker. Wait, no evidence there either. You sir are a squirrel fucker. -- Look, I have my conclusion, you fuck some kind of animal and when that type of animal is shot-down, I'm going to shop around for another type of animal. Because that's how this shit works apparently. --- Make some shit up, when that gets demolished, make different similar shit up, with generally the same conclusion.
You catch the analogy there goat-fucker?

Tuesday, June 27, 2017

Approximating an arc with cubic bezier curves, yet another metric.

C = 0.552

C = 0.55201372171

The idea is that rather than minimize the extrema of the error we can instead minimize the total error. Graph out formula for the error and calculate what would be under the curve as a whole. So rather than positive and negative error equal it would seek to minimize the error overall. It's not too different from the other metrics. But, rather than trying to keep the first pixel from being wrong, it tries to keep the pixels as a whole from being wrong for as long as possible. It's different than the number for the extrema because oddly the graph is symmetric at 0.5. It's not symmetric with regard to the y axis, and has different amounts areas of positive and negative and the error shifts as the value of c shifts.

Mortensen's value. Even extrema point.
0.55191502449 at 0.0000001 increments
Total error:1180.57375326880434046054832219597498652621901536765190
Samples: 10000001

My calculated value, brute force.
0.55201372171 at 0.0000001 increments
Total error:1159.83397426356807198675826572857280613256846239728729
Samples: 10000001

Naive geometric value, with purely positive error ((4/3)*(sqrt(2) - 1).
0.552284749 at 0.0000001 increments
Total error:1401.62730758375303300973494715872257045283590056376636
Samples: 10000001

As we can see the total error over a million samples gives us an improvement of 20. Compared to the naive value for all error being positive we gain 242 which is better than Mortensen's gain of 222.

We're talking literally fractions of percents here, but this number has another advantage. You can call it .552 which is a much shorter fraction. Besides the more slices I do the more I narrow in on the value, but it's still a bit off. I'm pretty sure on most of those digits but without actually doing the calculus I can't get much better than that.

0.552 at 0.0000001 increments
Total error:1160.26180861006145200701189677079769078925976995284068
Samples 10000001

You'll notice my value is only 0.4279 different than that in total error over a million samples. And since that truncation lowers it, it will only make it a bit closer to the even extrema point, which is a fine metric.

P_0 = (0,1), P_1 = (c,1), P_2 = (1,c), P_3 = (1,0)
P_0 = (1,0), P_1 = (1,-c), P_2 = (c,-1), P_3 = (0,-1)
P_0 = (0,-1), P_1 = (-c,-1), P_2 = (-1,-c), P_3 = (-1,0)
P_0 = (-1,0), P_1 = (-1,c), P_2 = (-c,1), P_3 = (0,1)
with c = 0.552

Under this metric the cubic value something like: 0.92103099 which might be more important because really flattening out the error might matter in that case a lot more than in the cubic case. I'll call it 0.921

Friday, June 16, 2017

Using a quad to emulate an arc, solving for C.

Basic geometry allows one to solve for the best solution to use a value of C to make a bezier curve close to an arc. The naive solution using Geometry is

This is the solution to the question of we have anchor points on the curve and the curve touches the circle at the center, what value of C for a control point on the quadrant curve (0,1),(C,C),(1,0). Gives us the best fit to the curve.

However Mortenson points out that we are better if we minimize the error rather than allow all the error to be on one side of the circle.

This issue allows a few more percent with the Cubic Bezier form. But, it's more important if we're using one fewer control points. The same is also true at one fewer yet. If we have a square, what square looks most similar to a circle.

The if the naive geometry solution is the same we get:

. Where the corners touch the circle but do not exceed it. The other way you could do it is to have them only touch at the corners and just make the curve larger than the circle.

And finally we have Mortensen's solution to it, by making the metric for closest be the average error across the entire graph.

Well, solving this for 1 control point means doing the same thing he did. Which isn't super-trivial because it means calculating min and max error and adjusting various things. So I wrote a program to do it.

Your C points in Quad Bezier curves are:

C= 0.92519820883625651516056680057654772234129017577799879993432335355559372311727101122467939843041708056568481020881580812152533756252840773920708961655740969447362217856208142868847332990974178763987890

Having the program I refigured it for Cubic:

Having a deviation in both directions of: ±0.00019607646987687817401874512914923 ....

Mortensen gave this as,

Since we might well be using doubles I'd give it as:

C0.5519150244935106,1 1,0.5519150244935106 1,0
C1,-0.5519150244935106 0.5519150244935106,-1 0,-1
C-0.5519150244935106,-1 -1,-0.5519150244935106 -1,0
C-1,0.5519150244935106 -0.5519150244935106,1 0,1

And the c value for the quad bezier curve as:

Q0.9251982088362565 0.9251982088362565 1,0
Q0.9251982088362565 -0.9251982088362565 0,-1
Q-0.9251982088362565 -0.9251982088362565 -1,0
Q-0.9251982088362565 0.9251982088362565 0,1

This is much better than the more naive value: 0.91421356237 which is effectively unusable. While Mortensen's use for the cubic is great, it changes the quad naive to almost usable, generally not, but *almost* usable. The Mortensen-optimized value for quads is off by max 0.007767318 whereas the naive value is off by 0.010781424258 which is 28% better. Hm. That's the same value Mortensen got for the cubic.
Naive Quad: For comparison.

Saturday, June 3, 2017

1 dimensional fractals.

1 dimensional fractals all look the same. That's why they are fractals. Get it? Because they are all lines. And fractals look the same. And all 1d anything is a line which looks like all the other lines. HAHAHAHAHAHA!