centre of gravity

(kos) #1

i’m going to animate a TREX that blows a car and the car rotatets and falls like the one in jurassic park.i want to do it using physics with the help of python.can anybody tell me is the center of gravity of a model is truly in the same point as the centre after hitting"centre new"button…or shpuld i have to work it out gain using python?? :-?

(theeth) #2

No, they are usually not the same. But unless you want to make multiple integrations and calculate the real one, you’re better of working with the geographic center than the gravity center.


(Koryo) #3

And, of course, you can not properly do the integrations unless you know the complete composition of the car and the density of each of its component parts :slight_smile: So, what theeth said is best. If it looks wrong, just manually set the centre to something that looks good.

(S68) #4

Or forget physics and hack IPO curves, after all you’ll get so many problems in handling collisions that simulating a nice parabola-like trajectory with IPOs will be a breeze.


(kos) #5

ipos may be good but you know i’m a perfectionist type of people :wink: .i like physics simulations in 3d very much.i certainly may go to multiple integrals…coz i like maths too.but how do i implement integrations in python? :frowning: ofcourse i haven’t read the python manuals that came with the py2.1 :o .but still how?

(S68) #6

Oh, that’s easy, just grab a copy of the Abramovitz big blue ‘Handbook of mathematical functions’ or something like that. Go to gaussian quadrature and implement :slight_smile:


(theeth) #7

Well, as perfectionnist as you can be, I doubt you have all the data required to do the integrals. It’s not three of four integrals, it’s 3 or more per part of the car. Basicly, you’ll have to calculate the gravity center for each part (say, the left head light for example) and then combine all of them. It doesn’t have to be in real time, since the gravity center is fixed (onless you blow the car apart :-? ). Now, having found the gravity center, you’d also have to find the rotational inertia, if you plan on doing rigid body stuff. That’s another pack of fun integrals.

Those equations should be covered in any good books that covers rotational physics.


(kos) #8

i know that…but i wanted to ask that how to do integrals in python.i do not even know the function of square-root in python :frowning: .if it were C or C++ i would have proceeded a step… :slight_smile: .but you know this python thing is quite different from those languages.is there any function in python to do calculus?

(Koryo) #9

Since the car is modelled, you can find the exact volume of each piece, and use symbolic calculus to find the exact integral. If you want to do this in Python, basically rewrite Maple or Mathematica for Python :slight_smile: (Oh, and good luck!) More realistically, you can do numeric integration in python the same way you’d do it in C or C++. Write a function to implement the method of your choice: rectangles, trapezoid, Simpson’s, etc. and “integrate” over some finite dx, dy and dz.

(theeth) #10

many of the math related functions in Python are stored in the math module. So, just browse it and read the docstrings. For example:

import math
print math.__doc__
print dir(math)
print math.sqrt.__doc__
print math.sin.__doc__


(kos) #11

oh…thanx…thanx…thanx…i wouldn’t forget you in my entire life!! :smiley: …may be not your faces…or show me your pics…RIGHT NOW.