Inigo Quilez   ::     ::  
1402 blog posts, written between 2008 and 2016. These are mostly short observations, funny thoughts and word playing. Some are embarrasingly corny, some more deep. I keep it here mostly a little time capsule for myself, organized by month:

April 2013
they are all wrong
- some people thing i'm supposed to be a fierce defender of my homeland above everything just because i'm basque
- some people think i'm supposed to be a great "latino stuff" dancer just because i come from spain (er... there's some serious intercontinental cultural confusion regarding this)
- some people think i'm supposed to be an entrepreneur just because i live in The Valley and i happen to work on my own projects
- some people think i'm supposed to be a politically blind socialist with liberal ideals just because i am european

it's interesting (or alarming) realizing how i get to be labelled so differently depending who i'm being analyzed by. needles to say that, despite i'm in love with the place i was born, despite i like dancing, despite i like developing and sharing my ideas, and despite i was educated in a society that naturally cares about one another, those people presuming those identities of mine are all wrong!

i wonder how much of that same thing i do regarding other people when i meet them for the first time. i believe not much, but i'm obviously not the best person to tell.
not sure what it is... but i like it!
they are about to open a new store in the neighborhood. i walk by it almost every night. it's still unfinished, you can see they are still working on it because there's nothing in it yet, but a couple of items in the windows. one of them is a fantastic chocolate cake with some platform high heel shoes on it. so sweeeeeeet! and the cake is probably delicious too.

now, i've no idea what the store will be about once it's complete. but i can already tell i'm gonna like it!

look at them
sometimes (i mean, very often), somebody weird-looking comes in the train car. i love it when that happens.

my first reaction is thinking "good for him/her". then, i like looking and inspecting the much weirder faces people put while staring at the newcomer. it's really entertaining to analyze their reactions: surprise, unease, curiosity, disapproval, envy.

so next time somebody weird looking joins in a public place, don't stare at him/her, but look at the people around. it is priceless.
... delusion of self-relevance
i wonder why people keep asking themselves "how is it to be dead" when we all have already been dead; before we were born.

i ask to them, "how was it to not be born yet?"

no, but seriously. why would it be any different? well... (read title)
a glass of milk
they say there's nothing like drinking a glass of milk before going to bed.

i don't drink milk anymore (although i do consume massive amounts of yogurt and condensed milk), it's being 6 years since last time, but making a fractal before going to bed feels almost as pleasant and sweet.

somtimes, you don't need a reason to make a fractal
a man gets in the Bart car in an electric chair. he asks the old man who was standing in the area reserved for wheelchairs to make some room for him. the old man politely quickly offers him all the space indeed, and moves out of the area despite there's no seats or room left anywhere else. hence a young man sitting right in front of the wheelchair area stands up and offers his seat to the old man. so the old man proceeds to sit but the train resumes its trip and both of them almost fall. thankfully a woman next to them catches the old man, but she has to give two steps back herself in order to avoid falling down while holding his weight. in doing so she steps over my left foot.

then there is a succession of thankyous and sorrys, don't worrys and launghts between the five persons involved in this long chain of domino events.
one new thing that i know
I met my neighbor, who is an man in his 60s or 70s (I can never tell), when I was leaving my apartment this morning. He told me "That was beautiful".

I had just played the piano a few seconds before, as I do every morning right before leaving for the office. I always count with most neighbors being off at work by then, but seems some unfortunate soul like this mans must have been suffering those three daily minutes.

Still, I'm glad that we talked about other stuff than the music on our way out together. Once outside, when about to jump in my bike, I asked him his name. "Bill", he said. Before I could tell him my name and introduce myself he told me: "You know, there's only one more Inigo that I know of".

At this point I realized that I must have been annoying the shit out of this poor man a lot lately with my piano thing, if he already knew my name by now. Then I expected to be told about "The Princess Bride", but instead the man proceeded with "There was an Inigo living in Great Britain in the times of Shakespeare, who was a designer and architect working for the royalty, and founder of the classical British architecture".

We talked a little bit more, and then I finally started pedaling uphill California St thinking about what could have possibly been the adventurous story of a Basque name ending up serving a British man.
mathimage #10: insect
this time's mathematical image for my weekly commitment was an experiment on simple locomotion - i wanted to see how it would be to make a mathematical creature move, mathematically as well.

as usual in these weekly experiments time was a limiting factor in development. sure enough with more time i'd have made a better formulanimation (and i'd have iterated in improving the shape of the creature and its colors/textures). but then again, the essence of these weekly images is to prevent me from getting stuck in a single idea for a long time, and go to something new the coming week. that way i can explore lots of stuff without getting lost in the endless refining of the final product. the more i try, the clearer it is in my mind what i'm doing next. it's an exciting process, and i'm very glad i decided to undertake. in the meanwhile i do have other projects where i can put or my attention to detail anyway.

so yeah, this was a couple of three hours sessions. quite an investment, i must say, i don't think i'll spend this much time in a single image anytime soon. i must say however that during these six hours i spent most of the time fighting the technical difficulties set by the web browsing technology on which the maths run, not on making the actual images. sad, somehow wasted time. i guess that's the prize you pay for accessibility and ease of distribution (as opposed to an installable demo application). as result of this lack of actual production time, the sky is flat, the shape of the insect way too simple, the textures are broken, the terrain has random black dots, and the movement of the creature is too simple and lineal.

BUT, despite all of these, the result is goo enough as to stop here, call it a new successful image for my exercise, and move on. i think i'll do another creature/character this time, i have enjoyed doing something that is alive.

for the curious, the body of the insect is an ellipsoid plus some cosinuses, the legs some thick conical line segments plus a cosinus, and their smooth attachment to the body some exponential.log based function. if you want to see it moving in your own computer, or to explore more the mathematical details of the making, just follow this link:

i also rendered this video below over night, which higher quality than what the web browser can give you out of the box. hopefully you'll find yourself saying "creeeeeepie!". that means the math is doing its thing :)

i'm sorry, but "cocktail" still feels like two words to me. i cannot avoid it. to my hears, "lets drink a cocktail" doesn't sound exactly glamorous.
random interactions
A woman stopped me and my friend last night in Bush and Hyde, while we were walking to downtown and talking about how many thousands of times we've walked these streets already. The woman followed us for half a block, running trying to talk to us, until we finally noticed her and stopped. She was tired, and she looked a bit weird (well, everybody does look weird in this city anyway, which defeats the meaning of weirdness anyway, and which I celebrate). Then, she talked to us in a clearly nervous voice: "Hi guys, sorry, I don't want anything from you, don't worry. Just wanna say that you bring energy and happiness to the neighborhood. I was drinking a cocktail and saw you pass by, and.. my life is weird, my brother and I are from different mums, and... Well, I'm happy you passed by me, you have a fantastic energy and... Hm, I think that we don't say these sort of things often enough, so I though I'd do it. So.. thanks for being here".

This is the second such bizarre (but gratifying) interaction in less than a week, and I'm not used to it (but I like it). It is the spring that makes people happier and keen to talk to strangers?
this is not programming
I found this fossil in my code, which indisputably proves that, if anything, this is painting rather than actual programming - you can clearly see the evolution of the local brush-strokes, piling one after the other, exploring/iterating til the final result was reached. From actual code:

w[i] = s*(1.0f-s) * slen * 0.04f * 0.66f * 2.0f * 1.5f * 1.5f * 0.5f;

Code-wise this is horrifying. But then again, this is not programming
i love that glass. but unfortunately it's gonna fall and break. it's unavoidable.

unless i move it in a bit, as soon as i finish cleaning these dishes, i just have to finish with this few plates, then i'll do it. yet, i know that that glass will somehow manage to fall and break eventually.

still, it would be great if i moved it right now cause then i'd had more room to let this dishes i'm cleaning dry. i'll do it now, in a moment. in fact, you know what, it's decided already - two more plates, and i'll move it. cause, oh boy, i can totally see it falling and breaking, it's gonna happen for sure.

in the other hand, now that i think about it, it's being there for a while... so wouldn't it be really bad luck if it fell and broke now that i have only one plate left? the pile seems to be pretty stable after all. yet... i know the glass is gonna fall and break. which is a pity cause i really like this particular glass.

well, never mind, i have just finished washing the last plate and it's all fine, nothing broke. but i'll move the glass anyway just in case. i just have to put this last plate here... and now take the glass and...

too late. the glass starts sliding as soon as leave the plate and, finally, falls. and breaks.

just as expected
I grew up in a time when computers couldn't compute trigonometric functions. The available alternatives where either not use trigonometry in your programs (that's when algebra and its cross and dot products shine), or to store tables of trigonometric functions and interpolate an approximate values when an evaluation was needed. That created a scar in many of us, and quite like a trauma, these days we still tend to underestimate (of not deny) the brutal evolution that the silicon has undergone.

Today I was doing some real-time mathematical image. In my oldschoolness, I thought I might attempt to speed up the rendering by replacing some trigonometric functions with something approximate but cheaper that would "look" the same in screen. This time I went for my well known and multi-purpose parabola f(x) = 4·x·(1-x). Here I'm scaling the domain from 0..Tau (2PI) to 0..1. It's easier to work with normalized frequencies (Tau's) than weird radians. Now, because the parabola (sort of) gives you half the sinus, you gotta duplicate it and put the copy upside down to get the full cycle. You can do that by multiplying the domain by two and renormalizing it to the unit segment by taking its fractional part. Then of course you want to make your function periodic so you end up having something like where I'm using the hat symbol to express the fractional part of a number. This results in something like this:

where the red curve is the real sinus and the blue one is the periodic parabola. Not bad. The problem is probably that there are two fractional part computations (one for 2x, one for x), which are expensive. I thought I might be able to do better that this.

My second attempt was therefore to use (again) a polynomial to generate a full cycle at once, then make that one periodic with a single fractional part computation. Since the curve has to pass by zero, one half and one, such polynomial could simply be g(x) = k·x·(x-0.5)·(x-1). In order to get k such that the function goes from -1 to 1, one has to make sure that g(x)=1 for the value of x that makes the derivative g'(x) = k·(3x² - 3x + 0.5) equal zero, resulting in k = 36/√3, making the complete function . The nice thing about this curve is that g'(0) = g'(1) = k/2, which means that the function is not only periodic, but it's also smooth at the tiling points. It's the blue curve in the following graph:

The function is a bit off the sinus, but it's perfectly fine to be used in pattern generation for mathematical images/textures/animation. So, when I found it I copied it to the code and got my pretty image indeed. I was expecting to see my performance boost, call the whole thing a good move, and continue with my image design. However I got the very disappointing surprise of realizing that g(x) wasn't faster, but actually much slower than using the original sin(2PIx) that I had been trying to avoid.

And that's when I realized that I had to unlearn what I once knew to be true. Indeed, these days trigonometric functions are not 110 times slower than arithmetic instructions as they used to be back when they finally implemented them in computers, but they are in fact, basically as fast. And I knew this, yet... So, I wasted about 15 minutes of my evening. The good thing is that I have un-learned a good lesson. I hope this time is for real.
mathimage #9: angels
More improvisation today made me end up having a group of alien creatures flying in the sky instead of the garden of flowers I thought of doing. I got inspired by a friend who used recursivity to make a tree, something I didn't do since the old good days in the 90s when I experimented with IFS fractals. Doing IFS again in the context of implicit distance fields was fun, although modeling is somehow limited. But it's powerful, for you can render millions of primitives for the price of a bunch. In this case the flying creatures are made of hundreds of thousands of small ellipsoids which are so packed it gives the illusion of having a solid surface. Anyway, at some point I had this weird shapes so I decided to stop, add some color and lighting, and call it "the experiment of the week" for my weekly "one realtime mathematical image a week for a whole year". This one was 4 hours, but most was spent messing around with the IFS modelling, not the image making really. Anyway, here it goes, with the corresponding link to the actual editable code and realtime version:

a debate is something you cannot unilaterally decide to end. it doesn't work like that. if it does end unilaterally, then it has clearly not being a debate.

(more often than not both sides end up agreeing in little more than just acknowledging that they'll never agree anyway, but even then it's a bilateral resolution)

(other things that i can think of which cannot be unilaterally terminated either: sex and war)
at the station
this evening i was late. i always am. everywhere. everywhen.

i was late and there was a huge line for getting the bart ticket. but i didn't mind, cause the temperature was warm and the weather beautiful, and there was a band of 4 bohemian musicians playing live, with a piano that they (somehow) brought and planted it in the middle of the station.

so there i was in the line, smiling distracted and dancing a bit, when i heard a voice telling me "you seem to be a good person". i turned in the direction of the voice and i saw a man smiling and handing a bart ticket to me. i looked to the ticket and asked "oh... you don't need it?" he said, "no, it's all yours". i thanked him, got the ticket, and run to the train, which i jumped into just on time for its departure. i sat, and smiled again thinking how lucky i had been, for i'd be a little bit less late than expected, and then i got distracted again in random thoughts. what i didn't know yet is that the ticket i was holding in my pocket wasn't a regular one way ticket, but a $60 one. that, i would discover only a few hours later.