Monthly Archives: November 2011

sin prisa

hoy voy sin prisa. quiero decir, menos que de costumbre.

el tiempo es increíble, y la temperatura perfecta. es ese tipo de día en el que todo es perfecto. por lo general, cuando salgo de casa tuerzo para la izquierda. hoy, giro para la derecha. por qué no. sé que por aquí tardaré más en llegar al curro. perfecto.

creo que nunca caminé por estas callles. las pasé en coche, eso seguro. ¿pero las caminé? nunca. se sienten diferente al caminarlas. se hacen más íntimas, casi parece que el caminar te permitiera desarrollar algún tipo de vínculo con cada una de las cosas que ves.

como este tramo particular del tanvía. y este vagón en concreto que lleva a todos estos turistas. o esta increíble y muy lujosa tienda de antiguedades por la que paso. es muy bonita. como lo es la mujer que la atiende, por cierto. le sonrío.

llego al punto de derivada nula de la calle Clay. la segunda derivada es negativa, o en otras palabras, empiezo a tirar cuesta abajo. veo tres chicas, de las cuales deduzco que una es niñera, tirando cuesta arriba de un carrito de bebé como si fueran sherpas monísimas.

ahora atravieso chinatown. banderitas, holores, ruido y tiendas muy raras y chungas. a esta hora de la mañana está muy vivo todo por aquí.

al fin llego a northbeach, donde la iñicleta ha estado durmiendo toda la noche. mola, sigue aquí, intacta, esperándome. la desencadeno, y empiezo a pedalear bajo los rayos calentitos del sol.

de camino a downtown paso por estudio de danza de una de mis amigas. de hecho, está dentro dando clases. asomo la cabeza por la puerta, y le dio hola, ¡buenos días! rápidamente. después, retomo el pedaleo hasta la estación de tren de mongtomery.

qué paseo matinal tan rico.

no rush today

no rush today. i mean, even less than usual.

weather is amazing, temperature is perfect. it is that one day when everything feels perfect. i usually turn left when i leave home in the morning. today, i turn right. why not. the commute will be longer this way. perfect!

i think i never walked by these streets before. drove? sure. walked? never. it feels so different when you walk them. like, more intimate, as if you were growing some sort of bind to these specific things you see.

like this one segment of the cable car. and this one car and all the tourists it carries. or this fantastic and huge luxurious antique shop i’m passing by. it looks beautiful. so does the girl in charge, btw. i smile to her.

i reach the zero derivative of Clay street. second derivative is negative, meaning, i start walking down the slope. i see three girls, one of them a nanny, i deduce, pushing a trolley up the hill. they look like chick sherpas to me.

i cross chinatown now. flags, smells, noise and weird shops. it’s pretty alive at this time in the morning.

finally i reach northbeach, where my bike, iñicleta, has been sleeping this last night. good news, she‘s still there, waiting for me. i unlock her, and start riding under the warm sun light.

in my way to downtown i pass by my friends dance studio. she´s there, in fact, teaching. i lean to the door, quickly say hello to her, and resume my walk towards Mongomery´s Bart station.

this was a pleasant walk.

estrellitas y duendes

to be honest, i don´t do it very often any more. partially as a very conscious (and probably artificial) attempt of mine to not fall into the romantic mood i naturally tend to stay in. the thing is that, from time to time, i still listen to Juan Luis Guerra´s classic songs. i know! just like when i was a teenager. hell, why not.

so, here go my tonight’s favorite lyrics, hopefully well translate from spanish to english by myself:

i’ll live in your memory
as a simple rainshower
of little stars and goblins
i’ll roam along your belly
bitting every single dream

you’ll live in my dreams
as indelible ink
as a stain of steel
language is not forgotten
when love is made by two

a mathapple / una matemanzana

this post demonstrates how you can draw an apple on a table, using only mathematics.

this evening i decided not to code for me, but for the people out there again. so, i recorded this live coding session. as i already explained, it’s not easy to show what one can visually/cinematically/musicaly achieve with maths with a just 8 minutes coding session. indeed, in a 4 minutes of coding you can go only that far. in 20 minutes you can get some more sophisticated graphcis, but still there is no room for playing with content or look. so, this time, i decided to give myself 40 minutes to create something a little bit better. so, i took my compiler and live coding framework, and started to code an “apple on a table” image from scratch, only with mathematics. no txtures, no 3d models, no photoshop, no nothing. just 40 minutes of formulas.

of course, 40 minutes of code jam become less efficient (efficiency measured as visual awesomeness divided by development time) than when you do a 4 minutes production. when i improvise i waste lot of time thinking, wandering and even looking for stupid bugs, and the more complex the target image is, and therefore the code, the more i have of those. so this video is full of dead time where not much happens in terms of content evolution. i hope you enjoy it anyways.

in terms of nerdy content, this video shows how to quickly write a small raytracer/raymarcher, from scratch, how to then model a procedural apple and a ground plane afterwards, and lastly how to procedurally shaded it (textured and lighted) the models. as a bonus, the process involves implementing some sort of primitive perlin noise function, a few local lighting equations, some fake soft shadow technique, some fake ambient occlusion tricks, and a camera system, among other things. again, 40 minutes only allows you to go that far, so both the procedural modeling and the texturing are pretty simple.

finally, before i leave you with the video, some technical comments about the video recording itself: you’ll notice some cuts/discontinuities in the footage. that’s cause the graphics driver halted rendering more than once during the recording (not sure why), so i lost a few frames.

ok, here goes the live coding session. i hope you enjoy it!

un deseo muy tierno

vale. ya había tenido varias personas hablándome desde la ventana abierta de un coche mientras esperaba a que un semáforo se pusiera verde, y también gente diciéndome lo bonita que es mi bici durante mi trallecto en el b.a.r.t. ahora bien, aún no había tenido a nadie abriendo la ventana del coche durante un semáforo en rojo, expresamente para preguntarme qué tipo de bici es la que conducía y para desearme un feliz y seguro trayecto hasta casa. ¡hasta ahora!

a cute wish

ok. i already got people talking to me from the street while i waited to a traffic light, and people telling me how cute my bike is in the bart. but i never got somebody opening the window of her car while in a traffic light to ask my what kind of bike i am riding, and to wish me a great evening and a safe trip home. until now!

¿de serie?

¿es que acaso fabrican los tacatacas de los ancianos con las pelotas de tenis ya incluidas?

pero la pregunta más desconcertante es…

y de no ser así, ¿por qué no?

the blue pal dot

as kid who read and watched Cosmos (many times), the understanding of the insignificance of our existence grew in me in a very natural and romantic way. the idea is pretty beautiful i think. and it was mastery summarized by Carl Sagan himself in this little piece of “The Blue Pal Dot”, which probably is still the most graphical, simple and primitive way to have a first feeling of how much more humble we should be. too simplistic, i agree, but very direct too.

sort, or compute?

i wonder why in french and spanish we don’t call computers “computers“, but “sorting machines” instead (“ordenateur”, “ordenador”)

me pregunto por qué en francia y en españa no tenemos máquinas que computan (computadoras), sino máquinas que ordenan (ordenadores).

¡prueba superada!

la intervención del dios de los semáforos, junto a mis extraordinarias habilidades de equilibrista ninja, ha permitido que hoy consiguiera ir desde casa hasta la estación del b.a.r.t. sin bajar pie alguno del pedal.

necesito un nuevo reto para el paseo de las mañanas

working without topology (II)

imagine you had an arbitrarily oriented rectangle, and you wanted compute its surface area. doing base times height is not that easy when your four vertices are nor sorted or labeled (when you don’t have topological information), cause you have no idea which pair of vertices form the sides. so, preparing for the case when you want to compute the volume of an arbitrarily oriented box in space where detecting edges and faces can be even more tricky, lets try to find a way to compute our rectangle’s surface area without resorting to topology.

one way would be to iterate the four vertices in any order, and take two of the other three vertices in the list in turns and compute triangle areas. when done this way, due to overlapping triangles, the area accumulated is six times the area of the rectangle. therefore,

float calcArea( in vec3 *verts )
    float area = 0.0f;
    for( int i=0; i<4; i++ )
    for( int j=0; j<3; j++ )
        const int ia = (i+((j+0)%3)+1)%4;
        const int ib = (i+((j+1)%3)+1)%4;
        const vec3 e1 = verts[ia] - verts[i];
        const vec3 e2 = verts[ib] - verts[i];
        area += length(cross(e1,e2));
    return area/12.0f;

what a 7 days week!

two earthquakes, wining at the horse racing, a halloween party, an evening of fantasy shopping, a rave, a biking morning, brunch and sun, skype sessions with friends in europe, a recording for the extra dvd of a movie, a box with a surprise, a concert, a dance class, a birthday dinner, gogo dancers.

now lets see what this coming week turns out to be like

working without topology (I)

imagine the situation where you have eight points defining a box in space, oriented in any arbitrary direction. imagine they were actually an unsorted list of points, without any topological information telling you how vertices to each other to form edges and faces. and lastly, imagine you wanted to generate random points inside that box.

the easy way would be to first construct the topology with some sort of more or less expensive and convoluted method, then perform as usual: take the three orthogonal non-normalized edge vectors { e1, e2, e3 }, the vertex v where they meet, generate triplets of uniform random variables { h1, h2, h3 } in the 0..1 range and construct my random points as p = v + h1·e1 + h2·e2 + h3·e3

but what if you cannot afford guessing a topology for your eight corner points, of what if you simply don’t want to. then, you can proceed like this: take the 8 vertices v1..v8, plus 8 random uniform random numbers {h1, .. h8}, normalize these 8 random numbers such that h1+h2+….+h8 = 1, and finally contruct your random points as p = h1·v1 + h2·v2 + … h8·v8. you can of course interpret {hi} as as some sort of barycentric coordinates. the points you get this way are indeed inside the box.

the first problem would be that we would have over-dimensionalized the parameter space from 3 coordinates to 8. secondly, and more importantly, the distribution of points generated this way doesn’t happen to be uniform, but rather biased to the center of the box. see the left image below.

to fix this, intuitively one wants to “bend” the coordinates hi towards zero (by using using a pow function on them for example), such that the biggest of the {hi} coordinates win more easily over the other 7 coords (lower valued hi would loose their relative importance). that should move more points towards the faces, edges and corners of the box, and uniformize the points within the volume. indeed, as we square or even cube our coordinates, we get a much better distribution, although we see it’s still not perfectly uniform as more points aggregate around the diagonals of the cube.

if described in code, the technique would look something like this:

vec generatePointInBox( in vec *v)
    vec res = vec( 0.0f );
    float wto = 0.0f;
    for( int i=0; i < 8; i++ ) 
        float w = powf( frand(), 3.0f );
        res += w * v[i];
        wto += w;
    return res/wto;

an ancient game, actually

i was coming back from work. i was leaning on the door, distracted, probably thinking about something deep like whether do fishes yawn or not, or something on those lines that i cannot recall anymore. in any case, i suddenly noticed a girl looking at me. she was sitting next to the window. she was really cute, both under direct sight and through the reflection on the window. i decided to look at her directly, though. in fact, we kept staring at each other for at least 10 seconds. in the end, the awkwardness of the situation finished with two smiles at each other.

soon i was back to my deep thoughts, but the arrival to the city and the massive unloading of people brought me back to reality. i looked toward the girl to check if she was still there. yes, she was, gazing at me again. i looked at her without moving my eyes from hers. it took us 10 seconds again to start laughing together. then we broke the eye contact once more.

soon before we arrived at the next stop she started moving and packing her bag and getting ready to get off. on her way to the train door she passed by my side. when right next to me she looked at me, smiled, and said “bye”. this wasn’t my stop, but anyway i decided to wait for everybody to leave and get off there too.

once in the platform, a glance to the escalator revealed that she was looking downstairs my way. she smiled. i climbed the stairs slowly, letting everybody else disappear, until i finally reached the main hall of the station. there she was indeed, alone, walking very slowly. waiting.

i approached her. hello, how are you? hm… i wanted to let you know i think you are really pretty. a very sweet oh, thanks! followed, and so did few other words and smiles that are not really worth any further narration.

the naivest story in a long time

las fiestas empiezan en octubre

el día de las calabazas, el de los muertos, el del pavo y el del niño mágico de belén están todos juntos en lo que aquí llaman la “temporada de festividades”, que comprende desde finales de octubre hasta final de año.

es un follón de celebraciones y movida multicultural muy divertido. después de una semana loca de octubre, los disfraces de vampiros y enfermera sexy dan paso a las decoraciones navideñas derrepente un 2 de noviembre. tan de sopetón como es salir del metro y descubrir que toda la ciudad está de pronto iluminada con pinos, estrellitas, copos de nieve y otros motivos invernales. y con la misma facilidad con que las calabazas se reemplazan por campanas, el ambiente de campanas se desvanece momentaneamente por una semana para dejar hueco al día de acción de gracias, que nadie sabe a ciencia cierta en qué consiste salvo en cocinar un pavo de dimensiones dinosáuricas. mientras, las pistas patinaje sobre hielo y abetos siguen en la ciudad otro mes adicional hasta el día de los fuegos artificiales, haciendo el oscuro invierno más ameno. de por medio, el día de papá noel y los concursos de jerseys feos.

está claro que en verdad da igual si hablamos de un desfile de muertos de ancestros mejicanos o de minifaldas de enfermeras y calabazas, o de críos israelitas mágicos o de tradiciones paganas o de papanoeles o de conquistadores y pavos – la cuestión es que estamos en temporada de festividades, y tiempo para celebraciones.