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:
0.55191502449351057074356272279256664233618039472430889733698053746758709885277817592685338345358001614300815257463095148547403466508799941938848910944812198495136713728128014911200347760723733292314480

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

Mortensen gave this as,
0.551915024494

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

M0,1
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:
0.9251982088362565


M0,1
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!

Thursday, May 25, 2017

Entirely Hex Words

aa, ab, aba, abaca, abba, abbe, abed, accede, acceded, ace, aced, ad, add, added, ae, aff, ba, baa, baaed, baba, babe, bacca, baccae, bad, bade, baff, baffed, be, bead, beaded, bed, bedad, bedded, bee, beebee, beef, beefed, cab, cabbed, caca, cad, cade, caeca, caf, cafe, caff, ceca, cede, ceded, cee, da, dab, dabbed, dace, dad, dada, daff, daffed, de, dead, deaf, deb, decade, decaf, dee, deed, deeded, def, deface, defaced, ebb, ebbed, ed, ef, eff, efface, effaced, fa, fab, facade, face, faced, fad, fade, faded, faff, faffed, fe, fed, fee, feeb, feed

My favorite: effedface. Though 0xeffdface would fit in an int. 0xFADEDBEE 0xBEDAFFED 0xDECAFBAE 0xFEEDFACE 0xDEFACADE

32 bit hexwords.

abasedly aba5ed17
abatable aba7ab1e
abatises aba715e5
abbacies abbac1e5
abbatial abba71a1
abbesses abbe55e5
abettals abe77a15
abigails ab16a115
ableists ab1e1575
abscised ab5c15ed
abscises ab5c15e5
abscissa ab5c155a
abseiled ab5e11ed
accessed acce55ed
accesses acce55e5
accidias acc1d1a5
accidies acc1d1e5
accolade acc01ade
accosted acc057ed
acetylated ace7718d
acetylates ace77185
acetylic ace7711c
acidoses ac1d05e5
acidosis ac1d0515
acidotic ac1d071c
acolytes ac0177e5
addicted add1c7ed
adelgids ade161d5
aecidial aec1d1a1
affected affec7ed
affiliated aff1118d
affiliates aff11185
afflicts aff11c75
affordable af4dab1e
affordably af4dab17
afforested af4e57ed
agiotage a6107a6e
agitable a617ab1e
agitatedly a6178d17
albedoes a1bed0e5
alcaides a1ca1de5
alcaldes a1ca1de5
alcaydes a1ca7de5
aldolase a1d01a5e
alfalfas a1fa1fa5
algicide a161c1de
algidity a161d177
algology a1601067
alidades a11dade5
alliable a111ab1e
allodial a110d1a1
allotted a11077ed
allottee a11077ee
allseeds a115eed5
alogical a1061ca1
asbestic a5be571c
ascetics a5ce71c5
asocials a50c1a15
assagais a55a6a15
assailed a55a11ed
assegais a55e6a15
assessed a55e55ed
assesses a55e55e5
assisted a55157ed
associated a550c18d
associates a550c185
assoiled a55011ed
astasias a57a51a5
astilbes a5711be5
atalayas a7a1a7a5
attaboys a77ab075
attendees a710dee5
attested a77e57ed
atticist a771c157
babbitts babb1775
babesias babe51a5
babydoll bab7d011
babysits bab75175
bacalaos baca1a05
baccalas bacca1a5
badassed bada55ed
badasses bada55e5
bagasses ba6a55e5
bagatelles ba6811e5
baggages ba66a6e5
baggiest ba661e57
bailable ba11ab1e
bailiffs ba111ff5
ballades ba11ade5
balladic ba11ad1c
ballasts ba11a575
ballboys ba11b075
balletic ba11e71c
balliest ba111e57
ballista ba11157a
balloted ba1107ed
basaltes ba5a17e5
basaltic ba5a171c
baseball ba5eba11
baseless ba5e1e55
baseload ba5e10ad
basicity ba51c177
basidial ba51d1a1
basified ba51f1ed
basifies ba51f1e5
basilect ba511ec7
basilica ba5111ca
basseted ba55e7ed
bassetts ba55e775
bassists ba551575
bastiles ba5711e5
bastille ba57111e
batistes ba7157e5
battalia ba77a11a
battiest ba771e57
baysides ba751de5
beadiest bead1e57
beasties bea571e5
beatable bea7ab1e
beatific bea71f1c
beatless bea71e55
bebloods beb100d5
bedabble bedabb1e
beddable beddab1e
bedotted bed077ed
bedsides bed51de5
bedstead bed57ead
beefalos beefa105
beefiest beef1e57
beefless beef1e55
befitted bef177ed
befleaed bef1eaed
befogged bef066ed
befooled bef001ed
begalled be6a11ed
beladied be1ad1ed
beladies be1ad1e5
belittle be11771e
bellboys be11b075
bellcast be11ca57
beltless be171e55
besieged be51e6ed
besieges be51e6e5
besotted be5077ed
besteads be57ead5
biacetyl b1ace771
biasedly b1a5ed17
bibelots b1be1075
biblical b1b11ca1
biblists b1b11575
bicycled b1c7c1ed
bicycles b1c7c1e5
bicyclic b1c7c11c
biddable b1ddab1e
biddably b1ddab17
bifacial b1fac1a1
bifidity b1f1d177
bifocals b1f0ca15
bigfoots b16f0075
bilabial b11ab1a1
bilgiest b1161e57
billable b111ab1e
billeted b111e7ed
billetee b111e7ee
billfold b111f01d
bilsteds b1157ed5
bioassay b10a55a7
biocidal b10c1da1
biocides b10c1de5
biocycle b10c7c1e
biogases b106a5e5
biologic b101061c
biolyses b10175e5
biolysis b1017515
biolytic b101771c
biosolid b105011d
biotical b1071ca1
biotites b10717e5
biotitic b107171c
biscotti b15c0771
bisected b15ec7ed
bistable b157ab1e
biteable b17eab1e
bitsiest b1751e57
bittiest b1771e57
blasties b1a571e5
blastoffs b1a52ff5
bloodied b100d1ed
bloodies b100d1e5
bloodily b100d117

Hex words, as in words that can be spelled purely in hex.`

aa aa
aal aa1
aalii aa111
aaliis aa1115
aals aa15
aas aa5
ab ab
aba aba
abaca abaca
abacas abaca5
abaci abac1
abaft abaf7
abas aba5
abase aba5e
abased aba5ed
abasedly aba5ed17
abases aba5e5
abasia aba51a
abasias aba51a5
abatable aba7ab1e
abate ab8
abated ab8d
abates ab85
abatis aba715
abatises aba715e5
abattis aba7715
abattises aba7715e5
abaya aba7a
abayas aba7a5
abba abba
abbacies abbac1e5
abbacy abbac7
abbas abba5
abbatial abba71a1
abbe abbe
abbes abbe5
abbess abbe55
abbesses abbe55e5
abbey abbe7
abbeys abbe75
abbot abb07
abbotcies abb07c1e5
abbotcy abb07c7
abbots abb075
abdicable abd1cab1e
abdicate abd1c8
abdicated abd1c8d
abdicates abd1c85
abed abed
abele abe1e
abeles abe1e5
abelia abe11a
abelias abe11a5
abet abe7
abets abe75
abettal abe77a1
abettals abe77a15
abetted abe77ed
abide ab1de
abided ab1ded
abides ab1de5
abigail ab16a11
abigails ab16a115
abilities ab11171e5
ability ab11177
abiological ab101061ca1
abioses ab105e5
abiosis ab10515
abiotic ab1071c
abiotically ab1071ca117
ablate ab18
ablated ab18d
ablates ab185
able ab1e
abled ab1ed
ablegate ab1e68
ablegates ab1e685
ableist ab1e157
ableists ab1e1575
ables ab1e5
ablest ab1e57
ably ab17
abo ab0
abode ab0de
aboded ab0ded
abodes ab0de5

Wednesday, January 4, 2017

Reinventing the world without reinventing the wheel

I just made this up. Dibs.

"Reinventing the world without reinventing the wheel" - Tatarize.

Thursday, December 22, 2016

Flaw in VelocityTracker changes to a diagonal.

Velocity is the direction and speed of an object. Changing the direction because of the maximum velocity was reached must be considered a defect. This also clearly causes a flaw in that a diagonal velocity is faster than the orthogonal one.

The problematic bit of code akin to:
mXVelocity = accumX < 0.0f ? Math.max(accumX, -maxVelocity) : Math.min(accumX, maxVelocity);
mYVelocity = accumY < 0.0f ? Math.max(accumY, -maxVelocity) : Math.min(accumY, maxVelocity);

The flaw here is that if your velocity in the X direction exceeds the maxVelocity it is changed equal maxVelocity and the same for the Y. But, that means that if we are going at 20° angle and at a speed of 200, and our maxVelocity is 20. Our velocity is changed to be 20*sqrt(2) at a 45° angle. The correct answer is to scale the mXVelocity and mYVeloicity by the ratio of the actual velocity and maxVelocity.

mXVelocity = accumX;
mYVelocity = accumY;
double actualVelocitySq = mXVelocity * mXVelocity + mYVelocity * mYVelocity;
double maxSpeedSq = maxVelocity * maxVelocity;
if (actualVelocitySq > maxSpeedSq) {
    double excessFactor = Math.sqrt(maxSpeedSq)/Math.sqrt(actualVelocitySq);
    mXVelocity *= excessFactor;
    mYVelocity *= excessFactor;
}

Sunday, September 18, 2016

Scaryish fact of the day

Each and every moment half of this solar system's life-ending cataclysmic asteroids get closer to Earth.

Saturday, August 27, 2016

Wow the Table Talks are total bullshit.

I checked a few of the Table Talk quotes and found the same thing Richard Carrier found. That they were generally bullshit. But, I didn't know how far the rabbit hole went or how crap they were to start with.
http://www.richardcarrier.info/archives/10978

Tuesday, July 12, 2016

Fastest Pure Code Java Box Blur

----- Behold. Admittedly it'll fill the side two garbage pixels on the right with looped garbage but it doesn't bother to slow down to check when those happen. Stride is typically equal to width.


private static void applyBlur(int[] pixels, int stride) {
    int v0, v1, v2, r, g, b;
    int pos;
    pos = 0;
    try {
        while (true) {
            v0 = pixels[pos];
            v1 = pixels[pos+1];
            v2 = pixels[pos+2];

            r = ((v0 >> 16) & 0xFF) + ((v1 >> 16) & 0xFF) + ((v2 >> 16) & 0xFF);
            g = ((v0 >> 8 ) & 0xFF) + ((v1 >>  8) & 0xFF) + ((v2 >>  8) & 0xFF);
            b = ((v0      ) & 0xFF) + ((v1      ) & 0xFF) + ((v2      ) & 0xFF);
            r/=3;
            g/=3;
            b/=3;
            pixels[pos++] = r << 16 | g << 8 | b;
        }
    }
    catch (ArrayIndexOutOfBoundsException e) { }
    pos = 0;
    try {
    while (true) {
            v0 = pixels[pos];
            v1 = pixels[pos+stride];
            v2 = pixels[pos+stride+stride];

            r = ((v0 >> 16) & 0xFF) + ((v1 >> 16) & 0xFF) + ((v2 >> 16) & 0xFF);
            g = ((v0 >> 8 ) & 0xFF) + ((v1 >>  8) & 0xFF) + ((v2 >>  8) & 0xFF);
            b = ((v0      ) & 0xFF) + ((v1      ) & 0xFF) + ((v2      ) & 0xFF);
            r/=3;
            g/=3;
            b/=3;
            pixels[pos++] = r << 16 | g << 8 | b;
        }
    }
    catch (ArrayIndexOutOfBoundsException e) { }
}

Monday, March 14, 2016

The SVG 2.0 Specification adds a 'b' command to path for bearing.

This is going to make some pretty interesting L-System fractals pretty trivial to generate. F, F:=F-F-F+ then at the end replace all F with h10 all + with b90 and all - with b-90, and you're totally done.

Sunday, February 21, 2016

As a GMO myself...

I've started calling myself a GMO in some conversations where it's useful the reason being is that the placental mammal syncytin gene is not ancestral to the line but evolved as a part of a virus and was inserted by a virus. Just like in some GMOs. http://blogs.discovermagazine.com/loom/2012/02/14/mammals-made-by-viruses/#.Vso5mvkrJhE

Tuesday, December 1, 2015

Hiding your God doesn't make atheism unreasonable.

Making God pointless doesn't render God real. Trying to hide your deity from the light of science and reason and sneak it under new rocks and in deeper holes, doesn't make atheism the wrong answer. Or people who who aren't intimately aware of the various places you've tried to hide your feeble and now pointless god, ill-informed. Even a child who drew a correct analogy to Santa Claus, and lost her faith accordingly, got the right answer without reading excessive amounts of prattle. And failing to do that reading, doesn't make the conclusion in error.

Saturday, November 14, 2015

Olsen Noise Implicit Boxiness, or Causing Artifacting With Interpixel Levels

If for whatever reason you need something that does a full range of levels rather than discrete levels, you'll find Olsen Noise to cause artifacting, if you try to achieve that by doing a non-floored division on the blur. The problem is within the scopes it does a few operations:

upsample & adjusts position for scoping.
applies blur,
applies noise.

Well, the upsample are squares and the blur is a box blur, applied for each given level. The blur could well just be a high sigma gaussian of upsampled and speckled landscape (infinite scoped field).


Without blurring the pixels at various level become apparently. It's a bunch of noisy pixels and different levels (and thus sizes) which then gets blurred successively, rather than something like midpoint displacement in diamond squared. This works, but only if the edges are not allowed to propagate. Typically this is because the number of blurs will clip out the error so that the topmost iteration, none of it could persist. Well, if you're doing things where the difference between 0 and 1 matters to you, something other than voxel height maps or images where very tiny but ultimately discrete distances from one pixel to the next matter, then the obvious seeming desire is to have the blur (total / 9) rather than floor(total/9). As this will result in a non-boxy set of levels and give you artifacting as you cannot fully clip the edge of the giant deep-level pixels.




For clipped floored blur between the areas.


Without clipping during the blur process.

The latter method causes artifacting from those boxes being blended but not clipped. So the impact of the difference between one pixel and the next at the iteration=0, will *still* exist in the final image. Rather than be guaranteed to be eaten by the rounding in the blur. Since every pixel transition will always have a non-zero effect on the final image, and pixels are square. It produces square artifacts if you don't clip. If you do, then you get boxes. You could apply a final blur that doesn't clip to the end result.

So get the boxy version, then blur that, and get it looking smooth and artifact free.





Thursday, October 15, 2015

Renderscript Olsen Noise

Converted Olsen Noise to Renderscript for speed purposes. Then cheated and added caching. Made it into a live wallpaper somewhere.

http://pastebin.com/kA6C1Vkg

Thursday, September 10, 2015

Android Memory Compact Draw Segments drawLines();

if (count >= 4) {
    if ((count & 2) != 0) {
        canvas.drawLines(pointlist, 0, count-2, linePaint);
        canvas.drawLines(pointlist, 2, count-2, linePaint);
    }
    else {
        canvas.drawLines(pointlist, 0, count, linePaint);
        canvas.drawLines(pointlist, 2, count - 4, linePaint);
    }
}

If anybody needs to draw a bunch of lines from a float[] of points (not segments). Somebody is going to go OMG that's way better than how I was doing it!

Wednesday, September 2, 2015

Clever, even for me.

If you do deny me life, liberty or property, I do not care if you believe that a space-turtle on a mountain gave you religious permission to do that, you don't have that right. And if you do that to all black people, all gay people, all woman on equally nebulous grounds; you have no right, and you're a bigot.

Wednesday, August 19, 2015

Matthew 20:29, Mark 10:46-47 Why add a blind man?

I think Matthew just changed it to fit better with the two brothers of Zebedees. The parallel in Mark is largely that of the blind seer. The idea is that the apostles are dumb as a sack of hammers and don't see that Jesus is the Messiah. But, the blind man without eyes proclaims him "son of David" and asks to be healed and then follows him. Whereas the Apostles see with their eyes him feeding thousands and do not see at all. In the Odyssey the blind seer warns Odysseus of the suffering to come as he returns home. Here we have Jesus just before the passion.

It was a pretty common theme in many Greek myths that the blind seer would see what the seeing people could not. In Oedipus it's followed by the extra irony of him blinding himself after the seer's prophecy came true. Here Jesus keeps doing miracles extremely giant miracles and the apostles don't understand no matter how many times they are told. But, the blind man instantly knows and completely understands.

The change that Matthew made goes less towards the allusion to the Greek myth and more directly parallels the brothers of the Zebedees who just before are asked to sit at the right and left of Jesus. And Jesus says that that isn't up to him. Then Jesus heals the two blind men who follow him without ambition and see what the apostles cannot. One presumes they follow him on the right and left to Jerusalem, and towards the coming passion.

Rather than just an unassociated blind seer that basically is cribbed from Homer. We get phantom parallel and reversed James and John (Zebedee). The apostles are see but are blind to the truth. They ask for honors that are not earned. The blind men cannot see but already know the truth. And they follow, where the apostles shall scatter.

It really is brilliant mythology.

Saturday, August 15, 2015

Anti-suffragette's argument.

"A stranger from another planet, ... would certainly be led to believe that Christians are, and always have been, unable to tolerate so cruel and inhuman an institution. It is even suggested that it was the Church of Christ which finally abolished this unholy practice. Christianity abolish slavery! Why, slavery was maintained under Christianity for over eighteen hundred years; while in America after all those centuries a Christian people fought a bitter and bloody war, lasting four long years, and suffered the loss of a millions of men and money before they would give it up!" - Mrs. John Martin (1910)

Sunday, July 26, 2015

Anti-suffragettes and progress.

So I decided to study up on the arguments against women's suffrage and the people who argued and rallied for that point of view. I've run into a number of time when my arguments for slavery as given by the people who argued it during antebellum has come in handy.

It turns out, not at all to my surprise, that a lot of them were women. Like basically all the big hitters were woman.

They were often depicted as hating immigrants and thus not wanting them to get the vote and being puppets of their husbands, but they were generally socially conscious. The founder of largest group there was also important with the implementation of the earliest kinds of day care (day nursery). And generally were maligned as backwards and overly clinging to Victorian ideas of gender roles. Women do the housework, child care, and social work. Men do the dirty works of politics. They weren't oddly enough, just prissy rich bitches hating on people. They, like basically everybody, thought they had a genuine point.

I quickly ran into National Association Opposed to Woman Suffrage (NAOWS) and some of their meetings as such: "Feminism and the woman's movement last night received such a drubbing as only a sister woman could give, when some 200 active members and friends of the New York State Association Opposed to Woman Suffrage gathered in the home of Mrs. Henry Seligman at 30 West Fifty-sixth Street to hear Mrs. John Martin, the Charlotte Perkins Gilman of the No-votes-for-women movement, tear to tatters the great new Cause."

30 West 56th is still there and is a five story mansion, though today it's between D&S Market and a Sushi place.

So who was this Mrs. John Martin?
"The most important question in the world." Is mankind advancing? - "Mrs. John Martin"

Apparently she was quite intelligent and quite wrong. She wrote the above book, which basically argued that we are not advancing because despite all our high technology and discovery it paled in comparison to the art and science of the ancient Greeks as measured by the number of notable figures in the past. Clearly she knew far more well-known geniuses in the past than she knew of in the future. And nobody can carve a picture on a gem worth a damn anymore. Clearly we aren't progressing!


Pablo Picasso - Girl-with-Mandolin (1910)

This was written in 1910. So Picasso had just entered his cubism period and Einstein was just made a professor and had five year earlier set forth the basis for relativity, quantum mechanics, explained brownian motion while proving atomic theory, and explained the photoelectric effect which is how solar panels work.

Update: So I don't forget the posters.