Thursday, February 28, 2008

Original Triangle

I've been working with the original Triangle program from K. D. I compiled it and saved it as a .jar file. I also played with the coordinates for the endpoints and successfully flipped it over.


The new .jar file. The coordinates are specified in the code as follows:

// Remember to
// draw the points in counter-clockwise order. That is the default
// way of determining which is the front of a polygon.
// o (1)
// / \
// / \
// (2) o-----o (0)
Shape3D shape = new Shape3D();
TriangleArray tri = new TriangleArray(3, TriangleArray.COORDINATES);
tri.setCoordinate(0, new Point3f(0.0f, 0.0f, 0.0f));
tri.setCoordinate(1, new Point3f(0.5f, 0.5f, 0.0f));
tri.setCoordinate(2, new Point3f(-0.5f, 0.5f, 0.0f));

The coordinate array takes inputs for x,y,z for each of 0,1,2. To invert, I moved 0 to the origin, 1 to .5,.5 and 2 to -.5,.5.

No comments: