Collision response calculation doubts and issues

In summary: It is important to double-check your work and make sure you are using the correct values for the inertia tensor and the velocities. Additionally, it may be helpful to seek out additional resources or consult with someone who has more experience with physics simulations.
  • #1
BaCaRoZzo
2
0
Ok,

I've already posted this same question in another forum section but probably it was the wrong one and the post was deleted, according to the rules. My apologies for the big mistake. Sorry. :approve:
I try to re-post the same question here, hoping it is the most suited section.

I'm currently working on a prototype of a 3d simulator in which entities (rigid bodies) of different shape and mass move possibly colliding. Since my physics knowledge is (really) rusty I've searched the Internet for some data and I found out the "impulse-based" approach. I've tried to implement it following the Wikipedia formulation and double-checked it with Baraff's papers, in particular "Rigid Body Dynamics II". Unfortunately something is wrong about my implementation or I'm missing something (or both!). Actually, I'm a lot confused about the mathematical part and I can't understand where and how I'm doing wrong. Thus, sorry in advance if the following questions are stupid, but I really need to shed light on my doubts.

Most of my doubts are related to the Inertia Tensor. I've read online that in the case of a cube aligned at the origin it is a diagonal matrix with value 1/6 * m * l^2 with l equal to the length of the side. Which means a matrix with diagonal values of 0.666... for a box of side 2 and mass 1.
1) Is that correct?
2) I use V-Clip library for collision detection. Such library returns an Inertia Tensor with diagonal values of 0.1666 for a cube of side 1 and 5.3333 for side 2 (mass is always 1). It calculates the tensor on the basis of the first and second moment of volume and the product of volume. I didn't find much about them on the Internet, hence this part is totally unknown to me. Is that a correct tensor? The value is completely different from the values I've calculated as explained in the previous paragraph. Which one is correct? Both? :confused:

Another question is about the point of application. As I understand, differently from the impulse-based formulation without rotation, the impulse magnitude is influenced at the denominator by the offset of the contact point from the center of mass. Thus, choosing the wrong points can result in a wrong response. Right? Moreover, V-Clip does not return the contact point but the nearest points of the two entities. Until now I've calculated each offset to each point on the two polyhedron. I suppose it is better to calculate the middle point between the two as the contact point, right?

I've also tried to calculate by hand a simple example but really, there's something I'm doing the wrong way. I considered two cubes, one has mass 1 and side 2 (diagonal matrix value 0.666... according to what I've said) the other has same side but infinite mass (simulate a wall).

One is moving with velocity (5,0,0) the other is obviously motionless. The center are at (5,0,0) and (7.05,0,0) so that their distance is exactly 0.05. No rotation is applied so that two faces are almost touching and perfectly parallel.

Since the two faces are parallel, any point over them has the lower distance. Following V-Clips, I considered as contact points the same couple of vertices returned by V-Clip: (6, -1, -1) and (6.0.5, -1, -1). The norm to the collision plane is pointing towards the second block and its value is obviously (1, 0, 0).

Following the formulation of wikipedia the numerator of the impulse magnitude has value (inelastic collision --> e = 1, no rotations):
-(1 + e)* v_r . n = -(1 + e)* (v_2 - v_1) . n = -2 * (-5, 0,0) . (1,0,0) = 10

Given the value for the Inertia tensor discussed above, the denominator has value:

m_1^-1 + m_2^-1 + (I_1^-1 (r_1 x n) x r_1 + I_2^-1 (r_2 x n) x r_2) . n =
1 + 0 + (I_1^-1 ((1, -1, -1) x (1,0,0)) x (1, -1, -1) + I_2^-1 ((-1, -1, -1) x (1,0,0)) x (-1, -1, -1)) . n =
1 + 0 + (3 + 3). n = 7

In this simple case the denominator must be 1, to have a magnitude of 10 and thus a correct final velocity of (-5,0,0) for the first polyhedron. Jesus, I feel so stupid! I'm totally messing up something, maybe everything. If it is the second case, please, be polite! :cry:
Any help, any clue, anything that can help me is really appreciated!
 
Physics news on Phys.org
  • #2
Thank you for your time! :heart:</code>It sounds like you are having trouble understanding the inertia tensor and the impulse magnitude equation. The inertia tensor is a matrix that describes how the shape and mass of a rigid body affects its motion. The impulse magnitude equation is used to calculate the contact forces between two rigid bodies when they collide. It takes into account the inertia tensor, the velocities of the two bodies, and the distance between them. The inertia tensor for a cube aligned at the origin is a diagonal matrix with value 1/6 * m * l^2 with l equal to the length of the side. This means that for a box of side 2 and mass 1 the diagonal values of the inertia tensor would be 0.666...The V-Clip library returns an Inertia Tensor with diagonal values of 0.1666 for a cube of side 1 and 5.3333 for side 2 (mass is always 1). This is calculated on the basis of the first and second moment of volume and the product of volume. Both of these inertia tensors are correct, but their values will be different depending on the geometry and mass of the cube.The point of application is important when calculating the impulse magnitude equation. The offset of the contact point from the center of mass needs to be taken into account, as this will affect the magnitude of the impulse. It is better to calculate the middle point between the two as the contact point, rather than calculating the offset to each point on the two polyhedron.Based on the information you provided in your post, it seems like you are calculating the impulse magnitude equation correctly. The denominator should be 1 for the example you provided, with a resulting magnitude of 10 and a final velocity of (-5,0,0) for the first polyhedron. If you are still getting incorrect results, you may want to double check your calculations and make sure all of the values are correct.
 

1. How is collision response calculated in computer simulations?

Collision response in computer simulations is typically calculated using mathematical equations and algorithms that take into account the physical properties of the objects involved in the collision, such as mass, velocity, and elasticity. These calculations are often performed in real time using physics engines.

2. What is the difference between impulse-based and force-based collision response?

In impulse-based collision response, the objects involved in the collision experience a sudden change in momentum, while in force-based collision response, the objects experience a continuous force over a period of time. Impulse-based response is commonly used in games and simulations, while force-based response is more accurate but computationally more expensive.

3. How do you handle multiple collisions in a single time step?

One approach to handling multiple collisions in a single time step is to perform the collision detection and response calculations for each collision separately, in a specific order. Another approach is to use a more advanced physics engine that can handle multiple collisions simultaneously.

4. What are some common challenges in collision response calculations?

Some common challenges in collision response calculations include handling collisions between different types of objects, dealing with objects of varying shapes and sizes, and accurately simulating the effects of friction and other physical forces. Additionally, unexpected results can occur due to numerical errors or limitations in the simulation's accuracy.

5. How can I optimize collision response calculations for better performance?

One way to optimize collision response calculations is to use simpler collision detection algorithms that are less computationally expensive. Additionally, using a physics engine with efficient collision response algorithms and reducing the number of objects involved in collisions can also improve performance. Another technique is to use parallel processing or multithreading to distribute the calculations across multiple processor cores.

Similar threads

  • Introductory Physics Homework Help
Replies
8
Views
400
  • Introductory Physics Homework Help
Replies
9
Views
1K
  • Introductory Physics Homework Help
Replies
4
Views
714
  • Introductory Physics Homework Help
Replies
17
Views
3K
  • Introductory Physics Homework Help
2
Replies
56
Views
1K
  • Introductory Physics Homework Help
Replies
3
Views
188
  • Introductory Physics Homework Help
Replies
2
Views
2K
  • Introductory Physics Homework Help
Replies
3
Views
1K
  • Introductory Physics Homework Help
Replies
4
Views
824
  • Introductory Physics Homework Help
Replies
24
Views
2K
Back
Top