Live data from Hacker News

Code golfing a tiny demo using maths and a pinch of insanity

blog.pkh.me

21–23 of 23 posts

Re: Code golfing a tiny demo using maths and a pinch of insanity

#22

Another two bytes found (I think) (d==0.?K*.01*h:c-c) could become (d>0.?.0:.01)*K*h

Ah nice for noticing d!=0 is d>0. Not sure how I missed the multiplication to get rid of the vector form; I guess I was too obsessed with the x-x trick...

I added your changes to the Shadertoy version with your HN nickname. I'll integrate it to the original later.

Thanks!

Re: Code golfing a tiny demo using maths and a pinch of insanity

#23
post #22

Another two bytes found (I think) (d==0.?K*.01*h:c-c) could become (d>0.?.0:.01)*K*h

Ah nice for noticing d!=0 is d>0. Not sure how I missed the multiplication to get rid of the vector form; I guess I was too obsessed with the x-x trick... I added your changes to the Shadertoy version with your HN nickname. I'll integrate it to the original later. Thanks!

I saw that you used `float z;` to later use `z` instead of the constant `0.`. You can also apply that to get a zero vector: `vec3 y;` and use `y` in place of `p-p`.

It seems that leaving the obsession behind some more can save another byte.

Post reply on HN