## mathimage #29: intersecting planar coordinate systems

Say you want to intersect a ray with a planar coordinate system (a regular plane with a center point and two perpendicular vectors defining a 2D coordinate system). You are interesting in getting the distance to the intersection point along the ray (t), and the 2D coordinates of the intersection point in the coordinates system of the plane (s,t). So, given you ray with origin o and direction d, and your plane with center c and generating vectors u and v, you can proceed in two ways:

[1] The traditional way: computing the intersection with the plane (t), then project its relative position with respect to the center of the plane into the two coordinates axes (s,t).

[2] The elegant way: solving the 3×3 linear system of equations for (r,s,t) all at once, at a single step. You can do this by using Cramer’s law.

The second solution, despite more expensive, turns out a lot more elegant (more symmetric and regular, that is)

 ```vec3 intersect( vec3 o, vec3 d, vec3 c, vec3 u, vec3 v ) { vec3 q = o - c; vec3 n = cross(u,v); float t = -dot(n,q)/dot(n,d); float r = dot(u,q+d*t); float s = dot(v,q+d*t); return vec3( t, s, r ); }``` ```vec3 intersect( vec3 o, vec3 d, vec3 c, vec3 u, vec3 v ) { vec3 q = o - c; return vec3( dot( cross(u,v), q ), dot( cross(q,u), d ), dot( cross(v,q), d ) ) / dot( cross(v,u), d ); }```

This is one example of how you can use the function in order to draw oriented planar patterns:

## fun

visiting a work colleague in her office for coffee break, and spending more than one hour playing piano and singing classic disney movie songs.

## the 7 dimensional train

you know, all those guys trying to unify quantum mechanics and general relativity by means of a universe of a higher dimensionality than 3+1, face the frustrating but very necessary need for a scientific a prove of their model in the form of a repeatable experiment. of course, finding traces of the existence of such 5th or 6th dimensions for example is way too indirect and elusive, and chances are they are not real but only existent in this mathematical model that desperately tries to unify the four forces, and the big and the small.

now, here in my nightly train commute from the office to the city, i often have the impression i actually must be making use of the dimensions 5, 6 and 7 every time i have to leave the train car…

usually the car is really packed with people, to the point that passenger have little to no space and margin of movement at all. the situation gets really complicated for me, because i have my bike surrounded by people who have been pushing and finding gaps between it and other passengers, quite like in a tetris game. so almost every night, when we leave Montgomery station and i realize i have to get off at the next stop, i freak out. i never see how i and my bike are going to make it out of the car. then i say “excuse me”, and magic happens – as if this a magic password for the opening of a stargate to higher dimension where i somehow was able to maneuver my bike freely just in time to return to our regular 3 dimensional world right before the door opens at Powell station. i’m normally unaware of the process, i only know i say “excuse me” and then i’m automagically and instantly at the door quitting the car, not aware of what have possibly happened between those two moments of space-time.

this happens to me in the train almost every night, it seems to be a very repeatable experiment indeed. maybe i should contact the guys at Cern.

## perhaps a disturbing idea

i am in my bike heading home. it’s not that late really, still in the one digit PM-s, but the city has already turned its face into its night face, the more decadent one.

i’m waiting here for the red traffic light to turn green, at that weird corner in SF where a fancy trendy restaurant shares the cross street and address with the market of cheap sex. to my left, a group of people in elegant dresses and suits just left the restaurant. to my right, a prostitute starts walking the zebra crossing. when she passes by me and my bike she fires her hook in form of a smile and a “hi baby…”. i look at her, smile, shake my head, and break the eye contact rapidly and look to the infinity. that seems to be the protocol, or at least, one way to do it safely through the situation. finally the traffic light turns green and i resume my pedaling for one more block of sketchiness before i reach more transparent waters.

this little encounter starts a new thread of thought that keeps my head busy until i finish my ride home. this time i don’t think of these women themselves, of how conflicting for their lives it must be to do that, or what needs and dramas pushes them to do it in the first place. this time my thoughts go to the counterpart of the business – those who pay for sex and the very idea of paying for sex in itself. bear with me for a bit, i hope not to offend anybody (and if i do, you probably don’t enjoy reading this blog in general anyway). because i’ve seen many, may people paying for sex in form of expensive ticket to music festivals or expensive clubs, perfume, alcohol and invitations to drink, fantastic sexy dresses, cab rides, love hotels, breakfasts, and “good bye, see you soon”s. for the most part there’s a lot more going on than just the desire of a sexual encounter, granted. however, can anybody categorically assert there’s only one way of paying for sex?

of course these are not all the same. ideas like “courtship” or “socialization” come to my mind while i keep biking home. but still, to me, if i put all social context, accepted morals and established behaviors aside, the question phrased the way still sort of holds in some ways.

## mathimage #28: inversions

This week’s doodling happened during coffee break, in about 30 minutes. I used 16 inversions of the z plane (1/z) moving origins, followed by a twists. Every point/pixel gets transformed with these 16 maps and the distance to the origin is mapped to a color through a cosine with three different phases. Will see what I end up doing next week. For now, homework is done.

## a celebration

this is a funny group of people that the gods have decided to crowd together tonight, here by this door of this car of this late metro train. it’s the wednesday night of an anonymous week of the year. we are all participating, some more shyly, others more vibrantly, in this spontaneous concert that we have here.

next by where my and a girls bikes are resting there’s a young man with a hat who has started playing guitar as soon as he has entered the train in West Oakland. i immediately do the eye contact, smile, and decide to support him into building his audience. others join rapidly, happily, with huge grins in their faces, almost as if they had been desperately waiting for an excuse for leaving their smartphones.

one of the first ones to join in is a punk blond girl who has a puppy, which moves at the feet of the musician and looks up to her owner, me, and the musician alternatively. behind the punk girl, by the other door, there’s a gothic young redhair teenager. sitting in front of me a blond curly haired boy with a skateboard, to his left an asian office employee young lady. then there’s me and the other biker girl. there’s plenty exchange of eye contacts and smiles between all of us. and that makes me thing of how different all this would have been, what of an sterile space this would have been, if it wasn’t for the musician and his music.

in fact, now it’s the third song the plays already. this one is quite fast paced and happy. now, a super young cute black about-5-years-old girl stands up from her seat a couple of rows back and comes our way while her mum follows her while smiling. the little girl joins in the middle of the concert space, in front of the musician, and with the help of her mum who’s holing the by the arms, starts dancing. everybody looks at her, including the puppy. the scene is pretty cute and somehow magical. some of us laugh, some grin, some. there’s clearly a lot of happiness here right now. it’s clearly a celebration. a celebration of the small things probably.

yeah, a wednesday night in the metro is just as good as any other place, or what am i saying – it’s perhaps the best place, to to celebrate such things.

## grrraaaaawwwwwwww

2:30pm

(grrraaaaawwwwwwww!) okey, time to wake up! i did nothing but relax last night, and same this morning. (diving in thoughts) to make things even better, i’ve got three days ahead fully packed of no-plans-whatsoever. (huge grin). ok, end of transmission (happy, and one foot on the floor)

## clearly not me

due to entering the credit card number in a multitude of online websites over and over again for many years, people end up knowing their credit card number by heart eventually.

i am clearly not one of those people.

## mathimage #25: openly geometrical

i’ve been doing mathimages for almost 20 years now. back in the beginning most of my drawings were purely geometrical. because doing geometry in the computer is just easy: lines, cubes, spheres… these are all geometrical objects with simple mathematical descriptions and therefore easy to compute. since computers are made exactly for that, compute, creating images (or sounds) in the computer with such shapes is by far the easiest.

of course, the challenge of moving away from such simple geometrical shapes and producing organic imagery instead (ie, rich in shapes, textures and movement, yet not random but with rhythm) is indeed a fight against the machine, and also the ultimate goal (from a technical point of view) of creating mathimges. that’s way i enjoy it better trying to create such natural/organic images than doing easier geometrical work.

however, for this week’s mathematical image i decided to do all my regular improvised jam coding session strictly in geometry-land. no attempts to break regularity or silhouettes, no diving in memories in search of the shapes of nature. instead, i played only with one of the most regular and euclidean of all structures: an infinite grid of cubes.

as usual, a jam session is a jam session, improvisation drives it all. so sure, the image could be better, but the exercise turned out fun once again:

## i know, but still…

when i pay a check with credit card and i stamp my signature, i often draw a smiley face as well next to the signature.

because in my innocent and inaccurate version of the world, there’s a poor banking intern assigned the task of manually double checking all the signatures for approving all the transactions that happen every day. and i want to make that intern smile.

i know none of this is true, that there’s no intern checking anything. but i still have the funny though, and laugh at myself for thinking about it while putting my signature.

and then, before finishing,… just in case… i draw the smiley face.

## on race

it’s interesting to realize that i never had to think of race issues until i moved to this place. furthermore, i never before knew there were still “issues” with race, to begin with. not so extended as i have come to understand recently.

just to put things in context and give you an idea of what i’m talking about – i was grown up in a quarter of a million inhabitant city and studied in a city populated by one million people. hence, both were reasonably sophisticated urban areas. yet, i had never seen a latinamerican, arabic, african or asian person other than in the movies and TV until the age of 23 when i moved to the capital of europe. even there things didn’t get much better. for example, i can say that the amount of asians i saw during those 7 years can be counted with the fingers of a single hand.

this means that my only contact with race conflicts had been little to none, and i was only aware of them through the conflicts portrayed in documentaries, movies and news (which i never trust for you are never sure how much of what you see in those media is real and how much is just there as hyperbole serving the narrative). of course i had been exposed to some degree of racism in one form or another, for in such lack of prominent race or cultural diversity back there back there in the old continent, language and cultural localisms have often been used as excuses to create conflict. also, the recent massive immigration from latin america, euroasia and africa to europe are starting to rise conflicts and hence awareness. but in any case, it is undeniable that the magnitude and intricacy of the issue of racism that americans have to live with every day are unheard to me (and probably to the average european immigrant in americam).

in fact, being grown so unexposed to a multicultural and multiethnic reality, the average european feels too optimistic, probably too confident and surely too naive regarding race issues in america, the first country on the planet to celebrate diversity for more than a century. “way, wasn’t this already solved?”. however one learns with disappointment that we these hairy monkeys called humans have not solved the issue yet, and that the topic is fact pretty vivid issue and continuous topic of debate. i am still very tangentially exposed to it. i am however often find myself reading about race or talking about it in casual conversations with friends. which is something new to me. new and sometimes difficult for me and most eurokids, simply because we the lack the life experiences in a multicultural and multiracial reality that allows us to have developed an opinion and taken a position.

however we might enjoy some advantages. for example, we do join such discussions with some sort of tabula rasa mindset, free of preconditioned opinions nor real cultural artifacts. i’m thinking that perhaps we can see things a bit clearer, free of pre-established believes or indoctrinated “truths” blocking our view. we’ve never been educated in any particular point of view regarding the topic.

one such thing that i clearly see is the mistake of assuming that the average (liberal) white person feels (or should feel) guilty for all the atrocities done by white people during the centuries. i’ve seen this idea expressed multiple times. i’d like to inform them that i feel no connected or related whatsoever to the fucking bastard spaniards who killed the native americans, nor i feel responsible for the slavery white americans practiced. if anybody thinks i should feel guilty for what other people from which i only share skin color or blood did, then they are being racist. because race is not something transcendental that carries identity with it. culture is the mechanism to transfer identity. race isn’t. or not even – perhaps my very strong sense of individuality and the fact that i always have problems feeling blame or pride for what a group of people i am told i belonged to do or achieve, doesn’t help me here.

another cultural artifact i personally am free from (i think!) is famous whole american idea of the “white default” – that the US mostly agrees that americans are “white” by default. and that therefore black, yellow and brown people are out of the norm and must in fact be labeled as such. this is something carved so strongly in the very language that it is unconsciously accepted by all americans regardless of their race. for example, the news in the TV will talk about “a man” if the subject of the news is a so called “regular” white man, but will specifically talk about “a man of color” if he subject was a black man. indeed, analyzing the use language is a good way to measure one society’s idiosyncrasy, morality and standards. and it seems clear that being any color buy white is considered the exception to the rule in the american collective consciousness.

i do think i am still in my naive euroflowepower view of things, and relatively free of these preconditioned opinions and artifacts. i wonder if this will always be so, or if being now exposed to this new culture will, over the years, change and shape the way i subconsciously think and feel about these issues.

## a silly permutation

i had this silly joke idea in my head, and i needed to put it out there. i am sorry.

because it’s a visual joke, and because i cannot draw with my hands (well, obviously nobody can, what i mean is i can’t draw with a pencil or tablet), i asked my friend to execute it for me. thanks!!!!

## anywhere but there!

for me, clearly, the one place you absolutely don’t want to put the “watch your step” warning sign in, is the step itself.

anywhere but in the step, for Aristotle’s sake. what’s wrong with you, people? why am i alone in this one again?

## mathimage #24: abstract flames

This one got improvised pretty quickly (90 minutes or so) after a similar volumetric image I made a few days ago, which was a lot more dramatic. I’ve realize that I spent quite a lot of my time tweaking the colors. Since I don’t have any solid understanding of color theory (from an artistic point of view, I mean), I find myself exploring variations and going by intuition more than I should. Which is fun, but time consuming. My hope is that I keep learning as I do this naive searches, and that by the end of this year of weekly mathematical images I’ll be more agile in this aspect of the image making.

Anyway, the image this time is a volumetric fbm (the same I used a few months ago with my clouds, which were the first mathematical image in this ongoing challenge), and I deformed it inside out, then distorted it with some low frequency noise and then twisted it a bit. That creates moving flames (click in the realtime player below to see how the image moves – it’s pretty cool). The coloring is a gradient of two colors based on the local density, plus some spatial variation shaped by a cosine, and then some periodic dot patterns (product of cosines).

Overall I’m happy with the result, even more considering the limited amount of time invested. I hope you like it too!

## tontería

un grupo de osos panda, es “una panda de osos panda”?

## funny place

Number of verbal interactions with random people on my way to work last morning: FOUR! (a guy from the window of his car, a woman in the escalators in the station, a lady in the train, and a man at a traffic light). I looked all over myself trying to identify any potential indicators of a willingness to interact, but I found none. No special clothing, no goofy smiles whatsoever, no open zips, no nothing on my face. So I don’t know. People just wanted to talk to me last morning I guess. The US can be a funny place.

## three places, one instant

I love, love, love it when it rains like this. Soft, gently, elegantly. Gracefully. Like the sky was looking down the city and presenting us this beautiful morning rain, while smiling like the sweetest mom ever. That’s what happens when it’s warm, and there’s no wind.

It reminds me of my childhood summers back at home. The drops are huge thick balls of glass, but fall very slowly, almost as if they were suspended, floating in the air. And because it reminds me of home, I decide to not take any umbrella, not rush to the office, and instead walk slow and take the cable car. From it I take a picture of the trees in the financial district through the wet glass while my hears and heart are plugged to La Valse D’Amelie.

And so, the rain (home), cable car (San Francisco) and music (Brussels) blend seamlessly in a potpurri of feelings and memories. I can clearly feel my heart beating.

La Valse d’Amelie

## one h

speaking of pronunciation, sometimes an “h” can make a huge difference:

* air conditioning: the process of altering the temperature and humidity of air to more favourable conditions
* hair conditioning: a hair care product that alters the texture and appearance of hair.

i wonder how do english speaking frenchies handle this one… (imagine one in the beauty saloon asking the assistance for help when looking for the best “air” conditioning)

## antiphonetism

a – “ei”
e – “i”
i – “ai”

when and how the heck did this get screwed up this much?

## oh . shit…

i’m clearly and unquestionably not a morning person.

that’s why all these years i’ve been believing i am a night person instead.

now, lately i’ve started realizing that, perhaps, i’m not that much of a night person either!

oh . shit…

## mathimage #22: a thin layer of snow

over a bridge that i mathematically modeled a couple of years ago. This was a fast improvised image again. The interesting bit is probably in the smooth blending of the terrain and the bridge, which serves perfectly as a natural transition between the bridge and the recently fallen thin layer of snow. Everything else is uber simplified. The “trees” are dark cones, the bridge is a few boxes, and the lighting is pretty simple and non realistic as well. I pushed the saturation of the sky a lot in order to make sure this wasn’t perceived as an attempt to photorealism. Not that I wouldn’t have wanted to, I won’t lie, but I failed to nail the lighting in the very short time I gave myself for this image, so I decided to not even try to hide it.

What I like the most is that I wasn’t expecting to make a snowy scene at all. I love these math jam sessions.

If you are curious about the maths or code, or want to see it move in realtime (it’s sort of a time lapse thing), go here: https://www.shadertoy.com/view/Mds3z2

## ouch!

i took the Bart, got stupidly distracted thinking of music and chords and stuff, and passed San Francisco without noticing. by 5 stops! i think i’m somewhere near the airport (or LA or something), damn. correcting route, new mental gps destination: “the city”

## truths, and their context

although using scientific concepts in your discourse tends to impress certain type of people, it doesn’t really make it any more scientific or truthful. in fact, the opposite is quite frequently the case (think of parasciences, books like The Secret, and other such jokes).

what they often do is telling you, for example, that you can count the amount of rings in a tree stump to know the age of the tree, which is pretty accurate, and then claim that obviously you can similarly estimate the age of Saturn by counting its planetary rings.

the key maneuver here is to take a truth out of the context in which it applies as such, and abuse of it within the topic of interest.

as if truths could exist without a context, in the vacuum of knowledge; supporting everything that is. in short, as if they were absolute. hence, no surprise that people who believe in absolute truths tend to be easy victims for parasciences as well.

## the wrong complain

today i saw a 25 years old complain “i’m bored”. i’m sure what she meant was “i’m boring”.

i don’t have memories of when was the last time i felt bored. must have been a couple of decades ago at least. sure, over the years, i have had to do things i didn’t want to do at times, or be in places i didn’t want to be. but even then i kept myself busy actively hating the situation. not really “bored”.

## mathimage #21: wavy shapes

Improvised an animated noise field. I’m adding an image this time for the realtime version (to be found here, along with the maths/code: https://www.shadertoy.com/view/ldX3zS) has some artifacts.

On afterthought, I find some clitoral qualities to this. Anyway, the idea here was to improvise something abstract, and it worked well. But if I had more time I’d probably work harder and try pushing it to the next level. I like it.

## too little information

people say sometimes “too much information”. most of the times, however, it feels it’s “too little information” to me.

## when will… i ovulate?

what are the people’s concerns? what is important to them?

that’s difficult to know, but if you take just the population that speak english and use internet regularly, then you can play the game of asking Google about it. not directly, but by typing an incomplete query and letting Google offer some suggestions for autocompletion based on the most popular searches the world is actually doing… (make sure you log out of google and that you flush your caches)

for example, “when will” is a good start:

this (very scientific and flawless experiment clearly) indicates that people have the tragic and poetic hope of a life that gets better than their current one (“when will my life begin?”), that they want to make sure that better life happens before it’s already too late (“when will the world end?”), and that they don’t want to be by themselves regardless any of the previous two things happen or not (“when will i see you again?”).

and then, once those things are sorted out, the next big thing people want to know is… when they will ovulate.

## err… oops… hehe…

i rarely think about what i do while in my office playing/working. i’m usually too distracted/focused as to notice that i am may be dancing, or having a pen in the hole of my ear, or two, and such stuff. usually, i realize just in time before somebody comes in, but this time my colleague caught me inadvertently in retarded-but-cool-boy-mode wearing my sun glasses while working some formulanimation out.

alternative title for the post – on how to lose the respect they had for you, in 3 seconds, but at least make them laugh in the process.

## we’ve killed “love”

love is a short word. yet, it takes a lot to say it. even to express it.

i think this is especially true in this place. almost as if loving was something to be ashamed of, or something offensive that you shouldn’t talk about in public.

in fact, you don’t see people hold hands or kiss when walking in the streets over here, and if they do, faces or even verbal expression of disapproval from other people are to be expected. this is a sad prove that exercising the very human feeling of love has been effectively banned from public spaces. there, in the middle of the main shopping street, in the core of this self-proclaimed open-minded city, the fragility of human morality is put to exposure when the system feels no shame for allowing homelessness to happen in the very entrance to the stores where people spend lots of money, but however is embarrassed for an adorable portuguese couple that are kissing each other while waiting for the cable car. whoever shouted at them asking for decency, has in my opinion their values upside down.

but, speaking again just of the word “love”, and despite i’m still new here, i have the impression that the mere word itself has been somehow banned from circulation in public conversations as well. in fact, i have seen it replaced with euphemisms already, like it was just one more offensive word and needed a replacement! for example, people have referred to “love” as “the L word” in front of me. what the fucking fuck is that?. perhaps they said it somehow kidding, sort of playing… but still, for me it is a symptom, the peak of an iceberg of much more profound facts.

i have also heard things like “i have romantic feelings for you” instead of the old school “i love you”. because these days saying “i love you” is not just the expression of romantic affection anymore. it’s not even a sentiment. instead, it has become a tool, one of the key steps in an intricate social courtship machinery, a verbal request for permission to proceed to the next phase in a relationship. this way, saying “i love you” has little to do with the actual communication of love, but social intentions.

in fact, “love” not only has been raped and denied its true meaning, but has actually been fully repurposed for a much lower task: expressing that you simply like something. “i love it!”. or, perhaps, that you like something very very much.

we bastards!

## cause…. you never know?

you know when you get in the entrance hall of your building and there’s a pile of packages next to the mailboxes with the amazon label in them, some of them quite big, and despite you haven’t ordered nothing at all from amazon, you still go read their recipient in the label just in case there has happened some sort of glitch in the matrix and there’s one surprise box for you?

that makes me ask myself, what kind of naive delusional optimistic useless hope is that?

yet, instead of answering this question, i find myself actually evading it with an equally insubstantial “oh, but you never know!”

## mathimage #20: volcanic landscape

This one was, again, a completely improvised one.

It all started with a sphere, but after 30 minutes of exploration of a couple of random ideas, I had settled in some sort of a flat landscape full of caves (or, “empty with caves”?). From there I focused for two hours on adding a rocky feel to it, find some nice color/material distributions for the depths (yellow and browns) and the aerial bits in the top (grey and greens), through three lights (sun, sky, and bounce), add volumetric smoke and oranges for the lava, and call it a day. A very successful day! Cause, despite all the fakery involved here (which would make any computer graphics professional scream in pain, for these methodology and tools are exactly the opposite of how you are supposed to do things), the image is compelling and definitely complex for what it is: 300 lines of code/maths!

The realtime version with source code is here:

And a prerendered video (for those with slow computers) and with extra cinematic look, here:

## choices

I got stolen my bike. My super cute bike! Option A: get angry and infuriated, hate SF thieves, ruin my day. Option B: buy a new one and focus on enjoying the sunny day. Choice made: B. (so I just bought a new bike. a smaller, lighter, blacker and sexier one!). Alright, resume life.