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 'Struggling to make relation between elastic force and height'
Hello guys this is what I tried so far. I used the UTS to calculate the force it needs when the rope tears. My idea was to make a relationship/ function that would give me the force depending on height. Yeah i couldnt find a way to solve it. I also thought about how I could use hooks law (how it was given to me in my script) with the thought of instead of having two part of a rope id have one singular rope from the middle to the top where I could find the difference in height. But the...
Thread 'Voltmeter readings for this circuit with switches'
TL;DR Summary: I would like to know the voltmeter readings on the two resistors separately in the picture in the following cases , When one of the keys is closed When both of them are opened (Knowing that the battery has negligible internal resistance) My thoughts for the first case , one of them must be 12 volt while the other is 0 The second case we'll I think both voltmeter readings should be 12 volt since they are both parallel to the battery and they involve the key within what the...
Back
Top