Archive for the ‘code’ Category

Java Web Start for Cranktrain Simulation

June 26, 2006

I have put out a Java web start version of cranktrain simulation for a while. The tricky thing about Java web start is loading a data file. After reading all the available document on the web (which is very little), I learned that ClassLoader is necessary to invoke files in the JAR file.

ClassLoader cl;  crankShape = Trimesh.loadObj(cl.getResource("images/crank.obj"));

I used Java3D ObjLoader class to load the OBJ files. However, I am still confounded about how to directly read a text file in a web start app. The combustion force file was stripped from the current web start version of the crank model until I figured out a way to do it.

Advertisements

LDLTDecomposition.java

April 22, 2005

I have been struggling with remove() for a few weeks. The original C code from ODE is very difficult to understand. I finally gave up writing efficient code yesterday by only supplementing with some naive code. So now this class LDLTDecomposition is temporarily finished until somehow I learned a more efficient implementation. Function remove() is called by transfer_i_from_C_to_N() in class FastLCP. I compared FastLCP and SlowLCP, and found the test results match precisely. Nice. I finally got it working. I was even happier to find out that FastLCP did run faster than SlowLCP. Now I can move on to finish step() in class World with some confidence.

Update: the complete source code can be viewed from SourceForge directly.

LCPSolver.java

March 8, 2005

Two classes are implemented and tested in this code. This is my first attempt of using Colt extensively. SlowLCP is a simple but slow implementation for LCP bookkeeping. In class SlowLCP, the index set C and N are implemented by BooleanArrayList. I don’t know a good way to solve LDL’ yet, so I just use a more generic but less efficient LUDecompositionQuick. It is very obvious that solveLCPBasic directly translates the pseudo-code from Baraff.

Update: the complete source code can be viewed from SourceForge directly.

BoxStack.java

February 25, 2005

The main class for building a World where boxes are dropping on a flat surface. A SimpleSpace is attached for collision detection. The things to be implemented are HashSpace, box-box and box-plane collisions, and a Dantzig LCP constraint solver.

Update: the complete source code can be viewed from SourceForge directly.