Author Topic: More Physics  (Read 3149 times)

0 Members and 1 Guest are viewing this topic.

Offline Tetra

  • DBF Aficionado
  • ******
  • Posts: 2532
  • Karma: 83
  • Pirate Monkey!
    • View Profile
More Physics
« on: March 12, 2007 »
I just cant get my head round the maths behind the rigid body, i'm just too thick when it somes to math and math symbols. Wonder if someone could perhaps explain or show me what it means cos I dont have a clue.

I'll start by explaining what I done so far and post some links to the definations, and then if someone wouldnt mind telling me how badly I done :D

These are the links i've been looking at:-

Acceleration
Velocity
Torque
Rigid body dynamics


I have absolutely no idea what I am doing, I dont understand the equations for Rigid body dynamics at all.

Here is some code, i've cut it down to simplify it, if I ever get it working i'll post the full code to it.

Square\dx# and Square\dy# is the velocity vector ( from the center of the square )
Square\odx# and Square\ody# is the previous velocity vector ( from the center of the square )

Code: [Select]

; Assuming a collision is detected do the following
; fyi all the vectors origin is at the center of the square
;
; Square\timePassed# = Milliseconds passed so divide with 1000 to convert to seconds

;
; Force = Mass * Acceleration
; Acceleration is the rate of change in velocity over time  a = v/t
;
Square\velocity# = VectorLength#( Square\dx# - Square\odx#, Square\dy# - Square\ody# )
Square\acceleration# = Square\velocity# / ( Square\timePassed# / 1000.0 )
Square\force# = Square\mass# * Square\acceleration#

;
; Angle between the velocity vector and point of impact vector
;
angle# = -getAngle( impactX#,impactY#, Square\dx#, Square\dy#, 0,0 )

;
; torque = distance to center * Force * sin( angle )
;
distance# = VectorLength#( impactX#, impactY# )
Square\torque# = Square\force# * distance# * Sin( angle# )

;
; Convert torque to angular velocity
;
Dunno how to do this







;
; Returns the length of a 2d vector
;
Function VectorLength#( x#,y# )

Return Sqr#( x# * x# + y# * y# )

End Function

;
; gets the angle between two vectors
; x1,y1 vector 1, x2,y2 vector 2, ox,oy origin
;
Function getAngle#( x1#,y1#, x2#,y2#, ox# = 0,oy# = 0 )

Local tvAx# = x1# - ox#
Local tvAY# = y1# - oy#

Local tvBx# = x2# - ox#
Local tvBY# = y2# - oy#

Local d# = ATan2#( tvAy#, tvAx# )

Local tvCx# =  Cos#( d# ) * tvBx# + Sin#( d# ) * tvBy#
Local tvCy# = -Sin#( d# ) * tvBx# + Cos#( d# ) * tvBy#

Local newAngle# = ATan2#( tvCy#, tvCx# )

If ( newAngle# > 0.0 )
newAngle# = -(180.0 - newAngle#)
Else
newAngle# = -(-180.0 - newAngle#)
EndIf

Return newAngle#

End Function


Some insight would be much appreciated :)
Challenge Trophies Won:

Offline Tetra

  • DBF Aficionado
  • ******
  • Posts: 2532
  • Karma: 83
  • Pirate Monkey!
    • View Profile
Re: More Physics
« Reply #1 on: March 13, 2007 »
It's a hard one isnt it  :updance:
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: More Physics
« Reply #2 on: March 13, 2007 »
Looks like it!
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: More Physics
« Reply #3 on: April 20, 2007 »
Only just noticed this bit of the forum!

Looks reasonable to me so far Tetra!

Jim
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: More Physics
« Reply #4 on: August 07, 2007 »
Too convert Torque (angular momentum) to motion you need to know the radius its the same as speed formula ...
      Torque = (Pi*Radians) / time   (this is angular momentum)

torque is usually measured in RPM so use 60(seconds) / 1000 (mileseconds) to gain your basic unit of time
now if you have the Torque and you are rotating a ball the radius*Torque is equal to distance travelled if the ball does not skid but rolls along a frictionless surface ...
       Distance = Radius*Torque = Radius * (PI*Radians) / time   (this is motion)

Edit -

i will clean up the last one for ya. get rid of the if statements and do the atan like this instead ...
      atan(cos(x1), -sin(y2))
something like that will keep it in the right polarity
« Last Edit: August 07, 2007 by rain_storm »

Challenge Trophies Won: