August 9th, 2007

The Dark is coming to a theater near you

Today I happened to walk past a movie poster with the title The Dark is Rising. Something clicked inside my head, and I had to go up to it to read the poster’s small print. “Story by Susan Cooper”.

No. Way.

There are two books that defined my childhood: The Dark is Rising by Susan Cooper, and Programming the Z80 by Rodnay Zaks.

The Dark is Rising is a fantasy novel (actually a sequence of five shorter books) about a boy, Will Stanton, who is made aware that he is no ordinary boy. The evil forces of the world, The Dark, is rising, and only with the help of the special powers Will will inherit on his eleventh birthday, the forest spirit Herne the Hunter, the power of the six Signs, the six awakened Riders, the Grail coaxed from the Greenwitch in the sea, and the birthright of the strange little boy with the raven eyes can the Old Ones from The Light win the final battle by the Silver tree.

When light from the lost land shall return,
Six Sleepers shall ride, six Signs shall burn,
And where the midsummer tree grows tall
By Pendragon’s sword the Dark shall fall.

The similarities to Lord of the Rings is apparent (each book begins with a prophetic verse, much like in Lord of the Rings) and not so strange; Susan Cooper was a student of JRR Tolkien.

The books have won multiple awards and many, like me, cherish them and re-read them over and over.
I’ve always hoped that someone would make a movie out of Susan Cooper’s books. The movie adaptation of Lord of the Rings shows that it could be done.

And now Cooper’s epic has been turned into a movie. There’s a trailer available.

Watching the trailer, it’s painfully obvious that the production company has completely raped it.

They’ve changed the story to present, changed most of the characters (Will is now American!), and in an effort to appeal “to a new audience” turned it into an action movie (explosions!) that resembles those Hollywood crap magician kid movies. Likely extremely intended.

Why do they keep picking these masterpieces and turning them into manure?

I think I’ll go cry myself to sleep now.

Posted by Roine at August 9th, 2007 21:08 | Permalink

July 22nd, 2007

Elusive Ellipses

Today I received this letter.

Dear Roine,
I’m trying to do ellipses in OpenGL. The ellipses turn out fine, but I can’t seem to position them correctly. All my tries have turned into giant hairballs. Please advice.
Confused

Dear Confused. I know just what you are going through. Just the other day (well, today actually) I needed to do the same thing. I started out with a bunch of glRotatef(..) to position the ellipses with angles computed from the vectors with arcsine, but the cyclic issues and rounding issues with e.g. sin(asin(x)) made the ellipses go bonkers. Google didn’t turn up more than hints, so I had to write this beautiful piece of code myself:

// Draw an ellipse with focus points r1 and r2, with radius r
// 'quad' is a previously allocated GLUquadric object
// The code avoids using inverse trigonometric functions and the cyclic issues with them.
void
ellipse(float r1x, float r1y, float r1z, float r2x, float r2y, float r2z, float r, GLUquadric* quad )
{
  glPushMatrix();

  // As with all OpenGL code, this is done 'backwards', the first transformation being applied last:

  // Finally, create a coordinate system transformation for the ellipse,
  // where the X axis transforms to the desired vector (i.e. r2-r1).
  // 'by' and 'bz' are created by cross products, which is perfectly
  // valid since an ellipse is rotationally symmetric about (in this case)
  // the X-axis and so any orthonormal vectors to 'r2-r1' are valid choices.

  const float d = sqrt((r2x-r1x)*(r2x-r1x)+(r2y-r1y)*(r2y-r1y)+(r2z-r1z)*(r2z-r1z));  // d = |r2-r1|

  const float bx[] = { (r2x-r1x)/d, (r2y-r1y)/d, (r2z-r1z)/d };  // normalized r2-r1

  float by[3];
  const float dx2 = bx[2]*bx[2]+bx[1]*bx[1];          // |[ex x bx]|^2
  // Unfotunately, there is no vector guaranteed to be orthogonal to r2-r1;
  // we have to test for it.
  // If bx happens to be (nearly) parallel to ex then use ey instead to avoid degenerate case.
  if (dx2 > 0.01) {
    // normalized [ex x bx]
    const float dx = sqrt(dx2);                       // |[ex x bx]|
    by[0] = 0;
    by[1] = -bx[2]/dx;
    by[2] = bx[1]/dx;
  } else {
    // normalized [ey x bx]
    const float dy = sqrt(bx[0]*bx[0]+bx[2]*bx[2]);   // |[ey x bx]|
    by[0] = bx[2]/dy;
    by[1] = 0;
    by[2] = -bx[0]/dy;
  }

  // Now make one last orthonormal vector to both bx and by crossing them
  const float bz[] = { bx[1]*by[2]-bx[2]*by[1],
                       bx[2]*by[0]-bx[0]*by[2],
                       bx[0]*by[1]-bx[1]*by[0] };  // [bx x by]

  // This matrix both rotates the ellipse to the desired vector r2-r1
  // and translates it to r1 (last column)
  // 'm' is column major as required by OpenGL.
  const float m[16] = { bx[0], bx[1], bx[2], 0.0,
                        by[0], by[1], by[2], 0.0,
                        bz[0], bz[1], bz[2], 0.0,
                        r1x, r1y, r1z, 1.0};
  glMultMatrixf(m);

  // Reposition ellipse with left focus in origo, and right focus at 'd' on X axis
  glTranslatef(d/2.0,0.0,0.0);

  // Stretch sphere to an ellipse with semimajor radius 'r' and distance 'd' between foci
  glScalef((d+r)/2.0,r,r);    

  // Rotate sphere so the rotationally symmetric axis is in X direction (looks better)
  glRotatef(90,0.0f,1.0f,0.0f);  

  // Create unit sphere
  gluSphere(quad,1.0,12,8);    

  glPopMatrix();
}
Posted by Roine at July 22nd, 2007 10:07 | Permalink

April 21st, 2007

Gecko galore

I have a gecko invasion in my apartment. I counted three the other night. Geckos are tiny lizards that can crawl on walls and ceilings and eat bugz.

One of them are missing it’s tail. They can shed tails if they’re for example coming under heavy avian attack. Or being stepped on late at night in a dark bathroom. I’m so sorry mr Gecko! I expect to wake up one of these days and find one of my legs has been gnawed off during the night.

I love geckos. Not only are they cute, their primary reason of existance is to eat things I hate, like ants and mosquitos.

I hate mosquitos. I’ve spent months of my life hunting and swatting mosquitos that have managed to sneak into my bedroom. I’ve actually become quite apt. I have a fierce backhand, and I can take them out in mid-air. I’m thinking of publishing a how-to book on the topic.

When I get filthy rich I will set aside a specially tagged fund for eradicating mosquitos from this planet (and any other planet should they manage interstellar space travel first. At the rate I’m making money, it’s not a given which will come first. The best-selling how-to book should help here).

As I side bonus I will have cured Malaria. You’re welcome.

Posted by Roine at April 21st, 2007 18:04 | Permalink

April 14th, 2007

Songkran pictures

As promised, new folder (and new year! Ugh, need to take the camera out more) in the photo section.

This Songkran it rained and I managed not to get sunburned, but my entire body aches today.

My camera is now quite possibly toast. I used a wrapping bag at first, but it caused the camera to fog up. I ditched the bag and the camera got completely soaked, but worked! - for thirty minutes. When it dries out, next week or so, I’ll try it out, but if it’s gone I’ll let it rest in peace. It’s an eight year old digicam which has more stuck pixels than a 50 cent webcam.

Then again, that’s exactly what happened on the first Songkran (yes, it’s the same camera) and after it dried out it’s been working fine for five years.

Just for kicks, I’ve also added four more images to the 2006 Songkran pictures.

Songkran picture Songkran picture Songkran picture
Posted by Roine at April 14th, 2007 23:04 | Permalink

April 13th, 2007

Songkran 2007

Songkran is already over (technically the festival is three days, but there is only splashing on day 1). After a slow start it turned out to be the best one so far. It is getting dark now and only the most devoted are still splashing away.

I took almost 300 pictures, but most of them came out hazy because of lens fog (I really need to kill someone to get a 1Ds with enviromental sealings. Killing is required, no?) However I do think I got a few good. Will update with pix tomorrow.

Need. Sleep. Now.

Posted by Roine at April 13th, 2007 17:04 | Permalink

April 12th, 2007

Anticipation

The situation is getting critical now. The anticipation is so tense it’s smothering. Any street market vendor will sell you a gun - they even hang them in the windows. I’ve already seen cars cruising around, people standing in the back, showing off their guns, harassing innocent people. They’re just young punks that can’t wait. People are already avoiding the streets.

I’ve heard fighting will start at midnight tonight, not too far from here. Of course hell won’t be unleashed until sometime later tomorrow. Ordinary people will stay indoors with cars full of hooligans with war paint on their faces cruising around.

I’ve checked my gear. I think I’m good. Technically, I’m a non-combattant, but experience tells me most don’t care, especially girls. These people don’t even care about sides, they’ll just take out anyone who crosses their path. And with a smile on their face.

I’ve actually gotten a small piece for myself. For protection, you know. This time they won’t take me dry.

Posted by Roine at April 12th, 2007 20:04 | Permalink

April 10th, 2007

Tap’d

I donated blood yesterday. A local hospital apparently had a drive, and were present in a mall. Since I used to go regularly I decided to donate. Forgive me doctor, it has been several years since my last donation.

They had a medical form, which was of course in Thai. Since I don’t read Thai they had to read it out to me. A cute nurse had to ask me all the personal questions and check them down. I swear she blushed when she had to ask me if I see prostitutes.

One kind of bizarre question was if I had visited England. “England?”. “Yes”. “Um, yes?”. “How long?”. “Um, about two weeks?”. “Oh, fine”, check. Imperial blood is bad? Must be all the vinegar crisps they eat. I knew that can’t be good for you.

The setup was very conventional and everything was as sterile as anywhere. The only difference in the setup was they used what looked like regular kitchen scales to measure the blood bags, instead of fancy schmanzy specialized automatic scales you see elsewhere.

I felt fine afterwards, but slept like a log last night.

Posted by Roine at April 10th, 2007 10:04 | Permalink

February 4th, 2007

cobain onebritney nose reindeer

OK, so an update. Not dead. The bunnymess sending was recently fixed, and he’s been online pretty much constantly lately so sending a bunnymess should work now.
People always ask me what I’m doing. I guess if I updated this a bit more people wouldn’t need to ask. It’s just that my days are mostly ordinary and boring anyway; I’m doing much the same thing as everyone else, just 9000km away. And it’s a little better weather here I guess.
While other of my friends do cool and spontaneous things like delivering babies on their kitchen floor, I mostly go through my daily routine. Lately I’ve been working my ass off to get a release done, so I think I’ll be in for a little vacation afterwards. After all, I am living in paradise.

The title? Oh, it’s from a spam mail. I don’t know what a onebritney is either.

Posted by Roine at February 4th, 2007 13:02 | Permalink