May 4th, 2008

Releasing Java Vector Class

This semester, I took a class called “Computational Physics,” where we simulated various physical properties. For my final project, I wrote a simulation of the Solar System, and in the process, I wrote a “Vector” class for Java. It allows you to do 3 dimensional vector math operations pretty easily, like in the examples below:

// Create vector <1,2,3>
Vector v1 = new Vector(1,2,3);

// Unit Vector <0.27, 0.53, 0.80>
Vector unit = v1.getUnitVector();

// Magnitude (3.74)
double mag = v1.getMagnitude();

// Get each value
double x = v1.getX(); // 1
double y = v1.getY(); // 2
double z = v1.getZ(); // 3

// Multiply v1 by scalar (<5,10,15>)
Vector scalarM = v1.scalarMult(5);

// Create vector <-4,-5,-6>
Vector v2 = new Vector(-4,-5,6);

// Add v1 and v2 (<-3,-3,-3>)
Vector add = v1.add(v2);

// Subtract v2 from v1 (<5, 7, 9>)
Vector sub = v1.minus(v2);

// Dot v1 and v2 (-32)
Double dot = v1.dot(v2);

// Cross v1 and v2 (<3,-6,3>)
Vector cross = v1.cross(v2);

I’ve never really used Java before, so my code might not be the best, but it gets the job done. If you want to download the Vector class, here’s the link. If this comes in handy to anyone, I’d really appreciate it if you left a comment!

May 1st, 2008

Tacos in Vegas

An ad for What Happens In Vegas came on TV this evening, and I noticed something bizarre. Take a look at the font they’re using:

Now, take a look at the font Taco Bell’s been using for years:

Someone in advertising definitely dropped the ball on this one.

April 22nd, 2008

Getting Started with phpViddler

Over on the Viddler Lab blog, Colin Devroe and I are putting together a series on how to use phpViddler, the PHP wrapper for Viddler API. Parts one and two are already up, and more are on the way, so definitely check it out if you’re interested in developing a site powered by Viddler.