# Posts tagged ‘Simulation’

The method ive found  to resolve spherical and circular collisions at high speed is borrowed from the spherical bounding box method. I first store the current distance between the two spheres/circles and then the  future distance between the two  . $cd = |p0_{1} - p1_{1}|$ $fd = |(p0_{1} + (p0_{1} - p0_{1-1})) - (p1_{1} + (p1_{1} - p1_{1-1})) |$

if this future distance is smaller than the combined radius’s I re imagine the current distance $cd = (cd \frac{cd}{fd})$

and continue to do the standard method.

The basic verlet algorithm im using is, $x_{1+1} = x_{1} +(x_{1} - x_{1-1}) + a dt^2$

where x is the current and previous position a the accumulated forces, and dt, the timestep or period over frequency. This is great if the simulation is un-fluctuating i.e baked; if it was realtime i’d introduce the TCV (time corrected verlet) version, $x_{1+1} = x_{1} + (x_{1} - x_{1-1}) (frac{dt_{1}}{dt_{1-1}}) + a dt_{1}^2$

The nice thing about verlet is that velocity is calculated from the current and old positions, and because of this you can keep throwing collsion and constraint methods at it. It handles the rest. My current approach is to fire the integrator ( verlet) then collisions and constraints – the latter two iterated several times.

I started to think about building a very simple framework for dynamics based on this article: http://www.gamasutra.com/resource_guide/20030121/jacobson_01.shtml

It uses the verlet method and then successive systems to check for constraints, collisions etc. – I like this approach as it seems pretty modular. I think the basic method ill go for is defining objects/verts/lines/etc with attributes, whether there masses or constraints connecting masses together. Then the main system calls the general functions on them.

Im not sure if this is correct but i think the aproach with the main system is to:

1. Calculate all the forces of all the masses
2. Apply verlet algorithm with a timeStep
3. Do a scene check i.e if the masses are in a box if its simple or/and
do some collision/friction checking
4. satisfy the constraints

Im not sure if 4 & 3 are the right order so, ill have to think on that – but this is my basic approach to building a simple system. I thought of attributes because they could be place on anything then, and i could add some function for display methods, like cylinders and spheres.

So I’ve been looking into using quats to simulate joint rotation and deformation. What I’ve found out is that most joints of a human can fall into two systems: single and double quaternion systems. If a bone system doesn’t twist using its bone like the forearm then it can fall into a single quat system, which dictates just a direction , resolution of the twist happens naturally when two perpendicular axis’ come together at 90 degrees.

If a system has a twist dictated by bones in conjunction with muscle deformation, then one quaternion is needed to dictate the twist space the second ‘deformation’ quat rides on. With this we can say that twist is not only dictated by the resolution of the system it exists in, but by the spin this system dictates. The order of which system drives each space is important.