Better billboarding in Papervision3D
by Alex on Nov.07, 2007, under Flash
The Papervision3D wiki has an example for making billboarded sprites with just three extra lines of code. Trouble is, it doesn’t really work. Anyone who’s tried it may have noticed that when the planes get too close to the camera, or if the camera rotates around it’s z-axis at all, the planes start rolling instead of staying vertical.
The problem is that the lookAt method defaults to using the world y-axis as “up” for the billboards, which isn’t usually correct. Of course we don’t really care about the world y-axis with billboards. We just want them to be vertical in the camera. Here’s some code that does it.
// calculate the camera vertical in world coordinates
var up : Number3D = new Number3D(0, 1, 0);
Matrix3D.rotateAxis(camera.transform, up);
// billboard is the plane you want to billboard.
billboard.lookAt(viewpoint, up);
billboard.roll(180);
billboard.pitch(180);
Easy Scientific Notation In LaTeX
by Alex on Mar.02, 2007, under LaTeX, Math, Physics
I use LaTeX for all my physics homework and lab reports, and I’ll be using it for a master’s thesis in the next few years, so I’m constantly adding to my library of LaTeX commands to save some typing. Here’s a good one when you need to use scientific or engineering notation. Put the following in the document preamble (before \begin{document}):
\providecommand{\e}[1]{\ensuremath{\times 10^{#1}}}
Then, typing
The [111] crystal planes are 3.2\e{-10} m apart.
gives you:
The [111] crystal planes are 3.2×10-10 m apart.
whether or not you’re already in a math environment. If the exponent is just one number, you can omit the braces, like this: 3\e8 m/s. Cool, huh?
(Of course, for 10-10 m you can just use Angstroms, \AA. If you’re in a math environment, use \text{\AA}, or else the circle won’t line up with the A. That is, if you’re okay with non-SI units.)
Bold vectors in LaTeX
by Alex on Feb.12, 2007, under LaTeX, Math, Physics
Vectors can be typeset in LaTeX with the command \vec, which decorates the argument with a little arrow. This was cute at first, but it doesn’t look very good, especially in fractions. Textbooks use bold face for vectors, so here’s how to do that in LaTeX.
\let\oldhat\hat
\renewcommand{\vec}[1]{\mathbf{#1}}
\renewcommand{\hat}[1]{\oldhat{\mathbf{#1}}}
This also makes unit vectors (typeset with \hat) bold.
Silly Jessica Simpson Game, Pizza Hut Codes
by Alex on Feb.04, 2007, under Flash, Games
I don’t get it, but my wife loves the celebrity gossip, so when all this stuff about Jessica Simpson started coming out I whipped up this little game to make her laugh. It’s an homage to an old Mac game I haven’t seen in years called “Slick Willie.” I’m also keeping track of Pizza Hut’s sweepstakes codes here. Have fun.
Click on “more” to play the game.
wxCL, SBCL, and Windows
by Alex on Jan.25, 2007, under Lisp, Windows
wxCL is a GUI package for Common Lisp that uses wxWidgets, and it seems to look pretty good on Windows and Linux, and the code is sufficiently lispy. Exactly what I’m looking for, except it’s in alpha. Serious, seeping wound alpha.
I haven’t gotten it working on Linux yet, but it works on Windows. The asdf-install included in SBCL 1.0 for Windows doesn’t work, and asdf doesn’t work with Windows links, so here is what I ended up doing. First, I unpacked the wxcl archive to ~/.scbl/site. This is where asdf-install would put it. Then I copied the function sysdef-source-dir-search from the current asdf-install release to installer.lisp in SBCL’s version. Finally, I add that function to asdf:*system-definition-search-functions* so ASDF can find stuff in .sbcl/site.
Mathcad 13 with Wine, first attempt
by Alex on Jan.20, 2007, under Linux, Wine
The professor for my electricity and magnetism class wants me to use Mathcad instead of Maple, so I bought the student version. I’ve been using it on my Windows laptop for a week or so, but it would be nice to be able to run it on my desktop. The Wine compatibility lists show good results with earlier versions of Mathcad, so I thought it might work out. Unfortunately, it requires the .NET framework, which requires IE 5, which I’m not going to install just yet. Damn.
Flash 9 in Linux
by Alex on Jan.20, 2007, under Flash, Linux
Those of you in the know already know that Adobe recently released Flash 9 for Linux. An official, honest to god, up to date version. The best part? It actually works.
I’ve had problems with Flash since I switched to Linux, because I foolishly chose the AMD64 version of Kubuntu. After messing around with a 32-bit chroot for awhile, I finally discovered Swiftfox, a version of Firefox compiled to use 32-bit libraries but optimized for, and compatible with, 64-bit systems. I could watch Flash movies again. Sound didn’t work, but who needs to hear them anyway? Oh, and since Macromedia never released Flash 8 for Linux, there were more and more SWF’s that I couldn’t watch. And it crashed the browser a lot.
Okay, so it totally sucked.
Even so, I was pretty disappointed after I upgraded to Swiftfox 2 and found that Flash stopped working. Imagine my surprise when I clicked on the missing plugin button and saw that Flash 9 was available. I knew Flash 9 for Linux was out, but I’ve never had the plugin search feature actually work correctly. Then, right before my eyes, Flash 9 installed, the page reloaded, and the SWF started playing. With sound. “Thus Spoke Zarathustra” came on the radio, the sun broke through the clouds of winter storms, and a chorus of angels heralded, or trumpeted, or whatever it is that choruses of angels do.
It’s almost as if big companies are starting to take Linux seriously.
Snow Crash
by Alex on Dec.01, 2006, under Books
I just finished the book Snow Crash by Neal Stephenson. Yes, for the first time. It had some interesting ideas; not “they might be true” interesting, but “what if they were true” interesting. The idea that all our major religions are based on stories about exceptionally remarkable people which have evolved into more grandiose tales over millenia of oral tradition is probably not far from the truth. Just looking at something like Iliad it’s obvious how quickly an oral tradition can embelish extraordinary deeds until they’re superhuman. Add to that the modifications stories undergo as they’re filtered through the ever shifting styles and zeitgeist of the people telling them, and the tendency for people to rely on supernatural explanations when natural explanations fail them, and we can almost see the skeleton on which our religious myths have been built.
I also liked the idea of an ancient language which arose from our brain structures. Interesting to think of the consequences that would have on linguistic research, but it doesn’t seem too likely.
The ending of the book was disappointing, since almost nothing was resolved with any of the characters. We don’t even know who lived and who died. It desperately needed an epilogue. I was also rather disappointed with the three or four chapters which consist entirely of Hiro explaining everything that was going on. That part felt like the end of a Scooby Doo episode, right before they say, “Well, that about wraps it up. There’s just one more thing. Let’s see who the monster really is. Why, it’s old man Wilfred!!” Neal Stephenson seems to be a good writer sometimes, but at times he simply fails.
Why I switched to Linux
by Alex on Sep.24, 2006, under Linux, OSS
My first experience with Linux was in 1996. Somebody I met in IRC offered to send me a set of Slackware CDs he had lying around for free. What a deal! It blew my mind a little to think that a whole operating system could be (legally) free. I can’t remember now if it was four CDs or eight, but I remember being a little disappointed after I got it installed. Later I understood that Slackware was probably the worst distribution to start with, but then, coming from Windows and DOS, I couldn’t understand why nothing worked right. Where were the drives? Where’s the GUI? Why can’t it autodetect my sound card? With no guidance and no goal, it felt like I had taken a huge step backwards into the days of DOS. I quickly gave up on it, but the vision of a free, open source OS had impressed me deeply.
I tried to switch to Linux on my desktop around 1998 or ‘99; I think it was Redhat 6.something (this was before Redhat was selling an enterprise edition, I believe). I spent days and days trying to configure things like an internet connection over PPP, email, and sound. Sound never worked, but I finally figured out the rest. The breaking point, though, was X11.
What a mess. Back then, you had to actually define every display mode in terms of the horizontal and vertical refresh timings of your monitor. Not only that, but the only guidance the documentation gave was to find these timings in your monitor’s manual (what manual?), along with the ominous warning that using an incorrect set of timings could permanently damage your monitor. I finally got X11 working, but the default windows manager was ugly as hell, and there weren’t even any decent GUI applications available.
Well, by this time I’d had enough. I was spending all my time just trying to get the damn system to work the way I wanted instead of actually using it, and I haven’t even mentioned the dependency hell caused by RPM (this was before yum). For a number of years, Linux’s only place in my eyes was on servers.
I finally switched for good last October, this time to Ubuntu 5.10, then Kubuntu 6.06. Here are the reasons I switched:
- Ease of use. Most things just work now; installation was a breeze, all of my hardware was detected, and most of the configuration dialogs make sense.
- I had started using a lot of GNU software on Windows with Cygwin. The Cygwin folks have done a great job, as have the contributors to GNU software that release Win32 versions, but despite all this running the stuff on Windows is still a pain in the ass. This was a very important point. I had gotten used to using a lot of software that I knew would work better and be easier to use in Linux. This is probably the biggest reason that I was able to stick with Linux through the rough parts, because even if I was having trouble with WMVs or Flash, I could still do my work.
- Windows Vista will be an expensive, unnecessary upgrade. I never upgraded from Windows 2000, but when it went into the no-updates phase I realized I’d be forced to upgrade soon. Vista has absolutely nothing that I need, and a lot of features I don’t want. On top of that, I realized in the previous year that pirating software is unethical, and I had a moral obligation to stop. Facing the choice of paying $200 for an OS with a lot of features that I didn’t want, or paying nothing for an OS with a lot of features that I did want but felt a little awkward, I decided to hunker down and make the switch.
Why am I writing this? There is a big group of people that advocate open source software with a conviction approaching religious. Like anyone advocating anything with such conviction, I think they are causing some harm to their cause. Here’s the thing that most of them try not to admit: Linux is not right for most people. Sure, it could be right for most people, but it isn’t. A lot of it isn’t Linux’s fault, but even if you got hardware manufacturers to make real Linux drivers, and you got the X11 group behind XGL, and you hired Orson Scott Card to write documentation for every package that was so good you’d read it in the bathtub, it still wouldn’t be right for most people.
Most people are afraid of change. These days, Linux itself isn’t really such a big change from Windows (patent and printer issues aside), but expecting someone to change not only their operating system, but every piece of software they use, it’s too much. Most people have a tenuous grasp on their computer as it is, they simply can’t drastically alter every aspect of how they interact with it.
If you’re serious about advocating open source software you have to embrace Windows. You don’t have to use it, but you have to acknowledge that most people do use it, and it’s good enough for them. Don’t push Linux on people, push open source alternatives to software they already use. Once they get comfortable with those things, they’ll find Linux when they’re ready.
If you want to advocate open source software, you have to be rabidly anti-piracy. Unfortunately, the very idea that software can be owned by someone, the crux of piracy, is considered invalid by a lot of OSS advocates, but for the average Windows user price is the only advantage that OSS has over more traditional software. Piracy takes that advantage away, so you absolutely must make it very clear to people that piracy is wrong. Really guilt them about it, and they’ll make the right choice when they know they have an option.
Remember that computers are already very scary for most people. So talk softly and carry a big LiveCD.
KPAX, SLIME, and SBCL
by Alex on Sep.23, 2006, under Emacs, Lisp, Web development
I’ve been struggling on and off to get KPAX to work for the past few days. It turns out that the default method SLIME uses to communicate with the Lisp interpreter causes problems with the way s-sysdeps sets up the socket listening function in SBCL. The workaround is to set swank:*communication-style* to :fd-handler, but it has to be set before SLIME starts, so put the following form in ~/.swank.lisp
(defparameter swank:*communication-style* :fd-handler)
Now to get KPAX to work with mod_lisp…