michDS wrote:I'm curious, why doesn't the body go to sleep in the frictionless case, and why does it slide to the left?
a rational number is the ratio of two whole numbers.
There is something that is call round off errors when you have to express a rational number as a single floating point value.
bascially it is the fact that to represent a number exactly you need a finite number of digits, at some point you will have to truncate the value.
here is an example say you have the value x = 1 / 3
and you need to represent that value with 2 digits, your resutl is 0.33
now let us say you want to collect the original value by mutiplying by 3, the result is 0.99 not 1.0
if this was a dollar, every time you do that operation you lose one penny, if you do it tousands of millions of time, these error accumulate,
and soon your error are mush bigger than a penny,
in a numerical integration this manifesct as residual net forces acting on the body, it just happens that when the body hit the floor the forces are very close to zero, but not exactly zero because of the imposibility to calculate exact values.
these residual forces are passed to the integrator, and they add some momentum to the body,
after doing this in every step, the resul is that these residual moment get applied in a randome direction, but because there is not a not way to reduce any momentumn, the body migh gain in a lareg monetum that is not no neglegible.
when friction forces are present the error are still there, but each time that the becom large in any direction the calculated friction forces
do not let the momentum grow large enought, so there residual forces do no get amplyfied.
michDS wrote:My other question is about setting the inertia. If I pass an offset matrix when creating the cylinder collision (like you have done, and I also do this in my game), would the following inertia calculation be correct, or is this still wrong? I understand that newton 300 calculates this for you, but am wondering how I would do it correctly using newton 200:
dVector I;
float Mass = WEIGHT_MASS;
float Radius = WEIGHT_RADIUS;
float Height = WEIGHT_HEIGHT;
I.m_x = I.m_z = Mass*(3.0f*Radius*Radius+Height*Height)/12.0f;
I.m_y = Mass*Radius*Radius/2.0f;
NewtonBodySetMassMatrix(gPuckBody,Mass, I.m_x, I.m_y, I.m_z);
Thanks!
if you sit the offset matrix as a shape offset then the cylinder axis will be along the y axis, your calculation will be correct.
if you want to avoid have to determine the matrix alignment, you can use the function that compute the inertia matrix off the shape.
it should produce the exact same values you calculated, but with the corrrect order.
that is why I change the interface in core 300 to take a collision shape, many people were making that king of mistake.
with the new interface you can do things like setting a balling ball, and have it with the inertia of a cylinder inside.
in fact that is how balling ball are exactly made. they have a cylidrical shape made of a material of diffrent density than the ball outer layet
it is this feature that makes balling ball to have what the call Hook, basically after the ball rools for a while
the heavy cylidrincal act as a giro tha makes the ball change diretion because the inertia want to roll as a cylinder but the shape want to roll as a sphere.
In newton 300 you can do the same, make a spherical balling ball, then make a cylinder and set the ball inertia passing the cylidrical shape and the mass.
the by setting the friction, you should be able to make very realistic balling shot.