Monthly Archives: July 2011

on areas and normals for n-sided polygons

draw a triangle ABC defined by three point A, B and C. say we want to compute its normal or surface area (which is half the length of the normal). then, as usual, you take two of its edges, and cross them, or in other words, normal(A,B,C) = (B-A)x(C-A). of course, area(A,B,C) = |normal(A,B,C)|/2. not big deal. now, remember the cross product is distributive, so we can expand it to normal(A,B,C) = BxC – BxA – AxC + AxA, and given that it is also anticommutative, and that the cross of a vector with itself is zero (as it defines a zero area triangle), we get that normal(A,B,C) = AxB + BxC + CxA. this is the cross products of the vectors going from the origin to the three vertices, taken in pairs, one per edge, in strict cyclic alphabetical order.

draw a quad ABCD defined by four points A, B, C and D. say we want to compute its normal or surface area. lets split it in two triangles, and sum their normals, therefore sum their areas: normal(A,B,C,D) = normal(A,B,D) + normal(B,C,D) = AxB + BxD + DxA + BxC + CxD + DxB. again, due to the anticommutativity of the cross product (BxD = -DxB) we get that normal(A,B,C,D) = AxB + BxC + CxD + DxA, which is again a cyclic alphabetically sorted summatory of one cross product per side of the polygon.

draw a pentagon ABCDE defined by five points…. ok, you see where this is going. indeed, it’s very easy to prove that the normal (and area) of a polygon is simply (half the length of) the sum of the cyclic cross products of vertex vector of each side.

no need to mention this became super useful to some 4 kilobytes demo-coding back in the days

a nice day

i find somebody i know in my way to downtown. today the bart is 12 minutes late. the announcement label has spelling errors. the girl waiting next to me smiles to me. the man sitting right behind the car door with that huge walking stick looks like a wizard. i do some neat algorithms and painting today. i chat and talk and laugh loud during lunch. they teach me how to play a couple of chords of A Whole New World in a piano. i see a movie about cowboys and aliens. i go to the gym a bit. the cute girl sitting next to me in the bart has a colorful red, green and yellow hair speaks asks me about my bike, and more. i cook some mussels and fish. i skype and chat with a friend and we prepare some pranks for the week. i drop few lines in the blog, and go to sleep – i’m so ti… ti… red

por el camino al centro me encuentro con un conocido. hoy el tren llega con 12 minutos de retraso; tengo más tiempo mí. el panel de anuncios tiene errores ortografía. la chica que está esperando a mi lado me mira y me sonríe. el hombre que se sienta tras la puerta está apoyado en un bastón gigante y tiene pinta de mago. tiro unos algoritmos chulos y pinto un rato. charlo y hablo y río estrepitosamente durante la hora de la comida. me enseñan a tocar en piano los primeros acordes de Un Mundo Ideal. veo una película sobre vaqueros y extraterrestres. voy un ratito al gimnasio. la chica que se sienta al lado mío en el tren es preciosa, y tiene el pelo teñido de rojo, verde y amarillo, y me pregunta sobre mi bicicleta, y más cosas. cocino unos mejillones y dos pescados. chateo por skype con mi amigo para preparar las travesuras de esta semana. dejo caer un parrafito en el blog, y me marcho a mimir – estoy tan can… can….. sado

science for the art

usually science serves technology. i’m glad to be able to work in one of those very rare places where science serves art instead.

por lo general la ciencia está al servicio de la tecnología. me alegra poder dedicarme a uno de esos escasísimos trabajos en los que la ciencia está al servicio del arte.

apricots

translation:

i still don’t know why we call them eggs. it must be because of their color, i guess. cause, based on their shape, size and texture, it seems to me the testicles should actually be called apricots, instead

albaricoques

no sé por qué le llaman huevos, tal vez sea por el color. porque atendiendo a forma, tamaño y textura, los testículos deberían llamarse albaricoques

inventing AND discorvering maths

is mathematics invented or discovered? such a classic question…

i would say that we invent the questions, we freely set the conditions and the context for maths. we have no limits here, human imagination is allowed to go as far as it possibly can, which means infinitely far. so i think that in our relationship with maths, we are true inventors when it comes to create new questions and create objects or structures.

however, once we have made our choices, these creations of us do what they want to do, as if they had a true life and will. the behavior of the structures we invented, the relationships between the objects we created, seems to be out of our control, and so our role is that of seeking discovery, by means of reasoning, guess and intuition.

probably, as those behaviors are an indirect consequence of the way our brain works, we are perhaps discovering nothing but our own internal intelectual structure, but that’s another issue.

so, in short, i think we invent objects and the framework on which maths develop, and once that’s set, we discover their behaviour.

however, during the discovery process we are often in need to reinvent new concepts and structures, and so the process is relatively intricate, and probably, both invention and discovery happen at the same time during the creative process of a mathematician.

hello

i’m biking back from work. i feel good, it’s warm, the sun shines and makes me tickles in my shoulder as i ride to the bart station. the traffic light gets red and i stop, stretch my legs and look to the distant hills of berkeley. a car stops by me, to my left, but i keep examining the hills, distracted, while now stretching my arms, until a sweet soft voice tells me “hello”. i turn my head and i find a little girl looking to me from the car’s front seat, half head out of the window. she’s smiling, and greets me again. i answer, “hi, how are you?”. “good!”, she says with energy. her mum smiles from the driving seat, and makes a shy eye contact with me. traffic light is about to get green. “ok, bye bye!”, i say looking back to the girl. “bye!”, she replies, and i start pedaling again.

—-

estoy volviendo del curro. me siento bien, hace calorcito, y noto el solete que me hace cosquillitas en la espalda mientras iñicleteo hacia la estación del bart. el semáforo se pone rojo y paro, estiro las piernas, y miro las colinas distante de berkeley. un coche para a mi altura, a la izquierda, pero yo sigo distraído mirando las colinas, mientras estiro mis brazos también, hasta que una voz suave y dulce me dice “hola”. me giro, y veo una niña que me mira desde el asiento delantero del coche. tiene la mitad de la cabeza fuera de la ventana. sonríe, y me vuelve a saludar. yo le contesto con un “hola, ¿cómo estás?”, a lo que me responde con un “¡bien!” muy enérgico. su madre sonríe en el asiento del conductor, y me echa una mirada vergonzosa. el semáforo cambia a verde. miro de nuevo a la nena y le digo “vale, ¡hasta luego!”. “¡adiós!”, contesta, y empiezo a pedalear de nuevo.

practicing scales

in fact, that same friend reminded me that pianists indeed practice scales every single day, no matter their level. i guess this is a bit the same, and every cg coder should, no matter her/his level, rewrite a small raytracer once in a while?

writing a raytracer in 24 minutes

a friend of mine told me the other day “i will one day write a raytracer myself”.

then i realized that a simple raytracer can be written in a matter of minutes. indeed, as with everything in live, repetition brings fluency. even for writing a raytracer. i think this is my 50th or so raytracer i write (if not more). of course, not all of them were BIH based out-of-core packet tracers, but simple ones, not far from the one i improvised during this short live coding session yesterday.

note that sometimes i got stuck cause i didn’t have syntax error logs, and i also had to deduce the intersection functions on the fly. but there it is, white sphere on a plane with some interesting shading on it. you can follow the process of creating the tracer, step by step. it’s rudimentary, it renders slow and it designed wrongly… but it’s fast to develop and easy to follow. so, i hope you enjoy it!

on host and guest realities

reality-traveling is the mechanism by which, in movies, different realities seem to be related. like when a virtual character gets transported to another reality (the girl in Tron), or when injuries in one reality have a physical counterpart in the other one (The Matrix), when a text message gets routed from a simulated reality to the world that holds the simulation (Source Code), or even when dying in a dream means dying in real life (Nightmare on Elm Street).

the idea of being living in a dreams or simulation is probably as old as human kind is. and lately, since physicists get discovering what looks a pretty arbitrary set of rules for our basic sub particles behaviors (not less arbitrary than the ones we set for the Game of Life), the fantasy of us living in an architectured reality gets more than ever reinforced. yet, the existence of a hosting reality above us does not explain any leaking of information from it to ours.

indeed in the classic view of simulated realities something like an advanced Conway’s Game of Life where interesting patterns, a complete ecosystem and even intelligence would emerges, is still a closed system that is isolated from external events (unless otherwise designed). meaning “closed” as in its mathematical definition.

however the possibility that some information or causality might be leaked from the hosting reality to the simulated one is easy and fun to fantasize about, movie writers take for granted and the audience love to dream with it. but i’m not any convinced it will ever happen.

men wanted to travel across the air, and so they did. they also wanted traveling to other planets and worlds, and so they did too. men even wanted teleportation, and they will achieve it one day in the future. however, time-traveling and reality-traveling are the two things i have a harder time foreseeing.

tres años de trastero

parece mentira que hayan pasado ya casi tres años desde que abrí el trastero y tiré mi primer pensamiento huérfano en él. casi 500 posts. ya sé que cantidad no equivale a calidad, pero no era tanto calidad como posteridad lo que buscaba para los artículos en cualquier caso.

posteridad sobre todo para mi propio consumo, porque aún (lo siento, no puedo evitar poner la tilde) me lamento de no haber dejado demasiada constancia escrita de todas las cosas que me rondaban la cabeza cuando nací, de adolescenete. no es que fueran especialmente brillantes, pero igual que repasar un álbum de fotos antiguo trae recuerdos entrañables, un álbum de ideas y razonamientos ingénuos (o no tanto) adolescentes habría sido algo apasionante de escrudiñar. y para no cometer el mismo error de nuevo, entre otras cosas, empecé a dejar caer vivencias, pensamientos y paridas varias en el blog.

y lo hice de forma pública, como quien compartiera sus juguetes con todos, como ya anuncié desde el principio. mentiría si digera que el ego no tuvo nada que ver en tal decisión. fui en parte víctima de la web 2.0, que fue diseñada para satisfacer los egos y alimentar a los narcisistas, y yo, como todos, tengo también algo de eso.

aún así, siempre he tenido cuidado de no revelar nada especialmente personal en el blog. espero que uno pueda, porque así me he preocupado de que quedara codificado, interpretar y deducir el grosso de mis puntos de vista en temas como religión o política; pero efecticamente a nivel personal creo que es imposible vislumbrar ni intuir cómo soy o cómo transcurre mi vida. además, estando evidentemente en control absoluto del contenido, me he encargado de exponer la parte de mí mismo que me conviene comunicar. como dijo el excéntrico genio surrealista, las personas son poliédricas, es decir, tienen muchas caras (facetas). y si bien prometo que siempre escribo de manera genuina, sincera y transparente, espero que se entienda que evidentemente hay un iceberg de realidades sobre mi persona que nunca llegarán al trastero.

aún así, ahora que hemos parado a tomar un descanso y respirar profundamente un rato, y estamos en familia y no muchos nos escuchan, hago una excepeción para hacer un par de confesiones. el trastero lo abrí en bruselas, en el momento en que por fín decidí volver a sonreir; una época agridulce al comienzo, y dulce al final, romántica, de paz interior, vida sencilla y risa voluntariamente ingénua. supongo que los posts de esa época asi lo reflejan. apenas un año después se desencadenó una metamorfósis/revolución interna necesaria, aunque más que un cambio, fue una expansión que esparaba (sí, se ve que siempre son y serán mujeres las que marquen el tempo de mi vida). posiblemente, si nací a los 16, y a los fue 23 mi juventud, entonces a los 28 tuve mi adolescencia. el trastero siguió siendo mi lugar para almacenar curiosidades y respojos cuando me mudé a san francisco. tal vez, nunca antes necesité tanto de un trastero, y nunca antes tuve tan poco tiempo para él, ni tanto celo a la hora de confiarle mis pensamientos. posiblemente se note en una mayor ligereza de los posts, o en su cambio de color. y es que de alguna forma, por alguna carambola indirecta, lo que llega al trastero ha de verse forzosamente afectado (negativeamente) por lo que implica la vida en san paco. lo cual no quita para que siga sentándome a relajarme cada dos o tres días a escribir algunas de las cosas que me pasan por la cabeza frente a este portátil, con un sentimiento de romanticismo, aunque sus teclas no hagan ruido ni tenga martillos que se atascquen..

¡larga vida al trastero!

escolingarse

…y palabra de la semana, gracias a Ana, es… escolingar(se): descolgarse desde algún lugar, balancearse mientras se está colgado de algún lugar, columpiarse.

we are probably not worth the effort

men have always been terribly egocentric. just like young kids, who believe they know everything, we keep wanting, perhaps needing, to see ourselves like something unique and special in the world/universe/reality. sometimes by naively assuming earth was the center of the universe, others by desperately assuming some sort of magic dad made us in his own image, then by pretending we were the most sophisticated consequence of evolution, and now by having to conclude that if nobody talks to us it must surely be because there is certainly nobody out there. and, regarding this last assumption… did we think that, perhaps, we are just not worth the effort?

i wonder when we will stop thinking like kids. ohhh, when shall the overmen arrive, dear friend?!

8 minutes vs 1500 minutes

and while we are at it, here goes a jam coding session (ie, random toying with formulas towards an improvised target). in this case i was testing the live coding framework and i ended up doing this simple happy-talking-sun animation.


the very same technique was used for most of my procedural graphics and demos, for example organix (see below), made 3 years ago. the difference is, of course, that i spent 8 minutes in the happy sun, and around 24 hours on organix. otherwise, pretty much the same techniques, tricks and process.


organix, made in 2008

maths sound great!

i noticed that while developing interactive demos, i tend to spend as much time playing with the interactive part as i spend doing actual coding and implementation work. too bad!!! so, i decided to start recording all the toying happening during this involuntary debugging sessions. like, say, a live coding and piano keyboard playing session, for testing my mathemagical instruments editor.

not to mention that more rich sounds can be achieved with slightly more complex formulas and research time. take it as a sneak peak

a town?

you know a city is small when you walk and randomly bump into a friend once or twice a week