March 5, 2011

Koch SnowFlake in Java

Here is some code for the koch snowflake written in java for a class I was taking.  It uses the StdDraw and Turtle graphics to draw the picture, and a little recursion.

Anyways, here's the code for the snowflake:

/**************************************************
 *  Compilation:  javac KochSnowFlake.java
 *  Execution:    java KochSnowFlake N
 *  Dependencies: StdDraw.java Turtle.java
 *
 *  Plot an order N Koch snowflake
 *
 *  % java KochSnowFlake 3
 *
 ***************************************************/


public class KochSnowFlake {
    private Turtle turtle;      // for turtle graphics
    private double size;        // size of each line segment

    public KochSnowFlake(int N) {
        int width = 512;
        int height = (int) (2 * width / Math.sqrt(3));
        size = width / Math.pow(3.0, N);
        turtle = new Turtle(0, width * Math.sqrt(3) / 2, 0.0);
        turtle.setCanvasSize(width, height);
        turtle.setXscale(0, width);
        turtle.setYscale(0, height);

        // three Koch curves in the shape of an equilateral triangle
        koch(N);
        turtle.turnLeft(-120);
        koch(N);
        turtle.turnLeft(-120);
        koch(N);
    }

    public void koch(int n) {
        if (n == 0) {
            turtle.goForward(size);
        }
        else {
            koch(n-1);
            turtle.turnLeft(60);
            koch(n-1);
            turtle.turnLeft(-120);
            koch(n-1);
            turtle.turnLeft(60);
            koch(n-1);
        }
    }

    public static void main(String[] args) {
        int N = Integer.parseInt(args[0]);
        new KochSnowFlake(N);
    }
}

Using  java KochSnowFlake 3 and java KochSnowFlake 4, I was able to generate the images required for the assignment:



You'll probably want these also...  Turtle.java and StdDraw.java.

February 21, 2011

Thanks Oracle...

Thanks for turning my home computer into a worthless pile of processing power.

Since taking a database course at the local college, we were required to load a relational database management system, (RDBMS), and was persuaded to use our professor's personal choice, Oracle.  He'd worked as a database analyst for Oracle for 5 years, so obviously he choose Oracle over MySQL.

Anyways, loading the nearly 3GB software library, (not including the SQL developer software), and a near 2 hour install, Oracle had successfully installed numerous background processes, a webpage to administer the databases, and took over about 8GB of space on my drive.

Thanks.

Now my computer spends more time optimizing and running background processes for a database system with no database.

Oh...  "just uninstall it" you say?  Tried.  Apparently Oracle uses it's own scripts to install itself, so there is no uninstall process.  "Just delete the files and disable the services" you say?  Tried.  All files are locked even when services are disabled.  Perl.exe just continues to run as well as 200MB of RAM being used to run the non-database system.

I'm tired of typing now.

January 30, 2011

Trouble At Bird Manor

Awesome drawing by Grimside displaying the eccentricities of relational dynamics.


Never mind the notes across the top...  this was obviously done on a small notepad at work, but nevertheless it's terrific and disturbing in it's own right.

Everyone loves worms.

January 17, 2011

The Love Of A Howie Bear

I used to work at a place...  And there were others working there too.  Well, once day, I received the letter of a lifetime...


The drawing is impeccably accurate to how this gentleman looks...  almost a little too realistic.

My heart will never be the same.

Little Caesar's New Mascot

A friend of mine seems to have created the new version of the popular pizza chain "Little Caesar's" mascot.

I think it's got the new, hip edge that the kids these days are looking for.

Now....  we wait.

Translation Travesty

So I got some piece of crap remote control car from a conference I went to, and was reading the manual....

Apparently they used a crude program to translate instead of an actual person.


Actually read some of that...  it's hilarious.