Inertia tensors (moment of inertia) code

AI Thread Summary
The discussion focuses on developing an algorithm in C or C++ to calculate the inertia tensor for 2D shapes in a physics-based game. The user is working with closed concave line loops, which can be decomposed into non-overlapping triangles, and seeks a general solution for calculating the moment of inertia, beyond special cases for circles and rectangles. There is a mention of the parallel axis theorem, but the user struggles with applying this concept due to a lack of calculus understanding. The request emphasizes the need for clear guidance on implementing the inertia tensor calculations in code. Overall, the thread highlights the challenge of integrating physics into game development and the necessity for effective algorithm design.
Aggrav8d
Messages
2
Reaction score
0
inertia tensors (moment of inertia) for a game

Hello, physics gurus!

I'm trying to write a little 2D game that uses physics for more dynamism. Part of this game involves shapes bouncing around and reacting to forces, each other, etc. Each shape that can interact is a set of one or more closed concave line loops. (Complex line loops are not allowed.) Each set has an assigned mass and center. What I would like to do is develop an algorithm in C or C++ to calculate the inertia tensor for any of these shapes. I can decompose the shapes into a set of non-overlapping triangles, if that helps. I already have special cases for circles and rectangles who's centers are in the middle of the mass... but I would feel much better if I had a general solution. Sadly I failed my introductory level calculus class and I'm under a bit of a deadline.

If anyone of you miracle workers o:) can help me I would be eternally grateful. Thank you in advance!
 
Last edited:
Physics news on Phys.org
Parallel axis theorem
http://www.ac.wwu.edu/~vawter/PhysicsNet/Topics/RotationalKinematics/MomentInertia.html

http://www.ae.msstate.edu/~masoud/Teaching/SA2/chA3.10_text.html
 
Last edited by a moderator:
I've seen this before and a few other googles (that's how i found the special case info for rectangles and circles) but I don't understand how to apply this to my situation. Can you please elaborate?
 
You know what is the inertia tensor?? and how to work with a matrix in C/C++?
 
I multiplied the values first without the error limit. Got 19.38. rounded it off to 2 significant figures since the given data has 2 significant figures. So = 19. For error I used the above formula. It comes out about 1.48. Now my question is. Should I write the answer as 19±1.5 (rounding 1.48 to 2 significant figures) OR should I write it as 19±1. So in short, should the error have same number of significant figures as the mean value or should it have the same number of decimal places as...
Thread 'A cylinder connected to a hanging mass'
Let's declare that for the cylinder, mass = M = 10 kg Radius = R = 4 m For the wall and the floor, Friction coeff = ##\mu## = 0.5 For the hanging mass, mass = m = 11 kg First, we divide the force according to their respective plane (x and y thing, correct me if I'm wrong) and according to which, cylinder or the hanging mass, they're working on. Force on the hanging mass $$mg - T = ma$$ Force(Cylinder) on y $$N_f + f_w - Mg = 0$$ Force(Cylinder) on x $$T + f_f - N_w = Ma$$ There's also...
Back
Top