Entries Tagged ‘fix’:

Better billboarding in Papervision3D

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);

Tags: , , , , , , ,

Comments (1)

Easy Scientific Notation In LaTeX

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.)

Tags: , , , , , ,

Comments (16)

Bold vectors in LaTeX

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.


This also makes unit vectors (typeset with \hat) bold.

Tags: , , , , , ,

Comments (16)

wxCL, SBCL, and 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.

Tags: , , ,

Leave a Comment


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…

Tags: , , , ,

Comments (1)