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++?
 
Thread 'Collision of a bullet on a rod-string system: query'
In this question, I have a question. I am NOT trying to solve it, but it is just a conceptual question. Consider the point on the rod, which connects the string and the rod. My question: just before and after the collision, is ANGULAR momentum CONSERVED about this point? Lets call the point which connects the string and rod as P. Why am I asking this? : it is clear from the scenario that the point of concern, which connects the string and the rod, moves in a circular path due to the string...
Thread 'A cylinder connected to a hanged 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