most obfuscated code I've ever seen

I'm porting something from java to C#. I'm pretty sure what I'm trying to figure out at the moment is the Bresenham line drawing algorithm, which tells you how to draw a line on a bitmap. But then I get to this line, where it actually sets the pixel value in the buffer:



int rand8 = Shade3D.nextRandom8Bit();

pbuf[offset] = (n > nMid?(rand8 < 85?argb1Dn:(rand8 > 170?argb1Up:argb1)):(rand8 < 85?argb2Dn:(rand8 > 170?argb2Up:argb2)));



So first it gets a random 8 bit integer, if the method name can be trusted, and then

it decides what value to put in the pixel by whether the random is less than 85, less than 170, or greater than 170.



Okay, wait -- I might actually understand this. This might actually be antialiasing. Or it might be utter witchcraft.



This section also includes code that shifts bits left and right, and a lot of code that pays a lot of attention to 8 bit vs 16 bit vs 32 bit integers. As a rule, something is harder to port the closer it is to hardware. Bit-shifts and paying attention to the bit-width of types is rather close to the hardware, for my taste.



So have I just spent two day's on a fool's errand? Perhaps. I'm probably going to have to throw away the last two days of work, and re-start the port with another approach. Damn it. At least I get to keep the lessons learned.



And yes, it is new year's eve and I'm programming. It's not exactly fun, but it's what makes my life better.

weather

This is just an idea; it might be horrible in some ways.

This year we had the worst hurricane season ever. Last year was the coldest winter in ages, and the year before I think was the snowiest winter in ages. Significant portions of the Antarctic Ice Shelf are falling off and melting into the sea. I'm talking about rapid global climate change. I think it's real, and it's here, and it's just going to get worse.

Eleven countries around the rim of the Indian Ocean are suffering the worst natural disaster ever because of one tsunami: the waters rose quickly, then receded. A tectonic shift caused the earthquate which caused the tsunami, but think about this: the flood waters receded this time. What's going to happen when the water rises, and rises, and doesn't recede for hundreds of thousands of years? It won't be sudden; there will be time to plan for it, but it will be permanent. People won't just be homeless; the actual land they live on will disappear.

Let's use this disaster as a preview of the coming floods. Let's encourage the nations to rebuild at higher elevations, and leave the lowlands for the sea's inevitable encroachment. Most of all, let's use these horrible images to keep up the fight against global warming. A tsunami early warning system won't save us from global warming; we've already got a global warming detection system, and the alarms have been ringing off the hook for twenty years. We ignore them at our peril.

"significant enhancements"

I've been working on migrating Jmol to Microsoft Visual J# so that I can use it in a C# program. I ran into a problem with the javax.vecmath library -- it falls into the set of "technologies with no automatic migration." The Moving Java Applications to .NET instructions include this ridiculous bit of "it's not a bug it's a feature" and generally everything that's wrong with Microsoft's worldview when it comes to Java:

To finish the migration, you replace the unmigrated Java technology with comparable .NET technology. Because .NET provides a richer set of classes than what is available in Java, often you can make some significant enhancements when performing the technology replacement.



*splutters* But I don't want to re-work Jmol to use .NET's vector math library. There's already a perfectly good java vector library that I want to use.



What this *actually* means is that if I want to use vecmath, I have to "upgrade" it to J#. I think it will be worth it for Jmol though -- the whole point of using Jmol is to save me from having to write a complete molecule viewer in Direct3D/C#.



...arg. It turns out to be rather difficult to sane-ify the output of the "upgrade" wizard. And in fact, it seems to upgrade to C# rather than J#. I know C#, so I don't mind that.



I'm still in love with open source. Very much in love.

I love cross-platform open source.

I'm so in love with open source. And unix. And cygwin.
./configure
make
make install

Those three commands lead to such goodness. At the moment I'm installing FreeType2, a free, high-quality, portable font engine. I'm installing it on my windows tablet, but I'm entirely certain that I'll be able to compile and install it on the linux system at work with those same three commands... and that code I write on my PC will work under linux.

And, my favorite firefox feature: type anything into the firefox address bar. Hit return. You get the google "I'm-Feeling-Lucky" result. It's just... so... perfect.

I'm a hobbit!

Janet Bruesselbach painted me last night, as Frodo. She's a RISD student who's into sci-fi and fantasy and geeks. She was my partner in cs137 this fall. She asked if she could paint me as a fictional character... I took a look at my hair, which is at its curly, overgrown stage, and decided to be a hobbit. So last night I pulled on some heavy felt pants and a cloak, took off my shoes and socks, and posed on Janet's couch... while watching Return of the King, no less. Janet started with an empty canvas, and then three hours later, there was an actual painting there. Of me! As a hobbit! I look like me and also like a hobbit at the same time. I was worried that I wouldn't like the way I look, but I really do... something about how hobbits are supposed to be chubby.

I did try to watch the whole ROTK extended edition, but that's just too long to sit still for me!

Now I"m off to the cave for some hacking on screen, which I'm re-implementing in IS3D. I want to finish a project. For once.

Maybe that's what's so amazing about Janet's painting last night -- she produced a complete, finished work. Also that she did it on a Saturday night, at the end of the semester... it reminded me that artists make art for fun, not just for coursework. I code for fun, too, sure, but this was still somehow surprising, I suppose after all semester of hearing the RISD kids saying things like "I have to go finish a painting now."

Zebediah and I are planning to build a space ship and fly to the moon, or Mars, or Saturn. We will bring Hugo and Phineas in special kitty space suits, and we will return to earth when we need to go to a cat food store. Darling and Isabel just want to lie on the couch; they don't want to go to space.

Barney Cam 2004

The white house has made a film starring the most visible memebers of the Bush cabinet and Barney, W's scottish terrier. CNN just played the whole film. The plot seems to be that Barney has lost Mrs. Beasley, who is the new puppy. It actually features W down on one knee in the white house explaining to Barney what his job is for the holiday season, and why Barney didn't get any cabinet appointments.
People! There's a war on in Iraq. American children don't have enough to eat and they're certainly not getting enough education. We're accumulating a gigantormous deficit, and the dollar is sliding. Why are they spending the time and money on this silliness?

geek survival kit

Lately I have been having entirely too much fun with duct tape, velcro, and surplus electronics. I've been connecting everything to everything else. The two best examples of the last 24 hours:
-- a wireless keyboard duct-taped to a belt, making a wearable keyboard for use in vr. We took some pretty silly pictures of this; apparently it has a glam-rock aspect that RISD students can't get enough of.
-- a super-cheap dvd player, my ipod, and an walkman radio hooked up to my tv -- a complete home entertainment system that would just about fit in a backpack.

I think I should make it a point to always have the following supplies on hand:
* velcro
* duct tape
* utility knife or leatherman
* cable ties
* blank cd-r's
* earbud headphones
* dark chocolate
* aa batteries
* an unread issue of the ny times magazine, harper's digest, the economist, science news, or the atlantic monthly
* aleve

Anti-Grain Geometry -

Anti-Grain Geometry - is a super-platform-independent rendering engine for C++.

I'm in LOVE.

Have I mentioned that I'm in LOVE? Cross-platform C++ anti-aliased graphics. Really cross-platform! like G3D!



This fits into the saga -- I'm trying to dynamicly generate textures based on a simulation of fluid flow, to make a cutting plane with a painterly representation. I want an imaging library... and I want to be able to develop on windows and linux. Nothing else will do.



Meanwhile, I'm also trying to get GLSL going on my tablet. This is apparently a bit tricky. I'm kind of going in two directions at once: I could work on getting GLSL going on my tablet, and go straight to writing a shader to generate a texture dynamicly, or I could first generate the texture traditionally -- on the CPU, not the GPU. I imagine debugging will be much easier if I develop on the CPU first.



I am having SO MUCH FUN. I am doing this because it DELIGHTS me! I made a rake in VR today -- a streamline generating rake. In 1992 I helped one of the graphics group members by typing for him when his wrists were giving out -- he was working on building a streamline-generating rake for analyzing fluid flow around the space shuttle. Now I'm doing it myself.


What I love about open source

Bug [ 1033686 ] GImage::GImage(filename) dies on certain images
Submitted by: sascha
Date Submitted: 2004-09-23 17:45
Changed to Closed status by: vejita
Closed as of: 2004-09-26 01:14

Three days! How rad is that?

Translation for the non-software-developers out there: I found a bug in the g3d library, and reported it by filing a bug in the project's bug tracker. A developer named Corey -- not at Brown, not someone I've ever met -- identified the source of the bug, fixed it, and committed a fix, within three days of when I filed the bug.

This is an everyday thing in the land of open source, sure, but it's the first time that it's happened to me.

Try that with a fucking Microsoft library.

Thank you, Corey! Thank you, Morgan!

what? incarcerated people can't vote? people convicted of felonies can't vote?

Wait, I must have missed part of social studies -- people who were convicted of felonies can't vote!
Actually, I've done some research, and it turns out that in many states, the right to vote is automatically restored when a person finishes serving a sentence, parole, and probation.
However, in the states that I've checked, people who are incarcerated can't vote. How the hell is this legal?

Part of the Fourteenth amendment:
Representatives shall be apportioned among the several States according to their respective numbers, counting the whole number of persons in each State, excluding Indians not taxed. But when the right to vote at any election for the choice of electors for President and Vice-President of the United States, Representatives in Congress, the Executive and Judicial officers of a State, or the members of the Legislature thereof, is denied to any of the male inhabitants of such State, being twenty-one years of age,* and citizens of the United States, or in any way abridged, except for participation in rebellion, or other crime, the basis of representation therein shall be reduced in the proportion which the number of such male citizens shall bear to the whole number of male citizens twenty-one years of age in such State.

So -- from that we learn that people denied the right to vote because they're incarcerated still count towards the population count for purposes of determining representation. Oof. I looked through the rest of the amendments, and as far as I can tell, it's not legal to discriminate on the basis of sex, race, previous condition of servitude, age above eighteen.... but it seems to be legal to remove the right to vote because people are incarcerated.

This really bothers me. It takes all the inequities of the criminal justice system, magnifies them, and perpetuates them. Incarceration could be a time when people learn about how to participate in democracy. Damn.

deleting files in Win XP SP2

Why the hell does it take >30 seconds to delete a 1 kb file in Windows XP?
...and we don't get WinFS until when?
I'd stop using windows entirely except that...
a) work buys me fast windows laptops
b) work doesn't buy me fast macs
All the other reasons, I'd be willing to work around for the massively improved goodness of a mac... but since my current mac is slow-ish (667 mHz G4) and doesn't have a ton of memory (512 mb)... it's not as fast as my windows tablet... except when it comes to deleting files.

So amazing I had to blog it

I'm leery of all of the... everything around 9/11 today, because it seems like it always works out to making Bush look good somehow. In fact I spent the hour from 4-5 am (insomnia) watching Bill Moyer's take on the 9/11 Comissioner's Report... then for the rest of the day it was super-hard to find any decent tv that wasn't 9/11 related. But this... this is a 9/11 thing that I'm actually glad I clicked on. Hint: look up.

QTVR panorama: Tribute in light, 09/11/2001

From the BoingBoing archives -- this full-screen QTVR panorama of the light tribute to victims of 9/11, shot by Jook Leung. Link