A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: rotational, translational momentum and torque

  1. #1
    Senior Member
    Join Date
    May 2006
    Posts
    145

    rotational, translational momentum and torque



    I know this is a very easy situation. if the triangle is a pivot which cant move.

    1. only the vector perpendicular to the the beam ( the black line) matters...

    however, I have no idea how if the triangle is NOT a pivot and just simply an object that could freely move just like the black ball. AND to treat them not as one object, but two linked object.

    in particular, how much of the force given by the red arrow will be converted into rotational and how much into transational.

    thankyou in advance

  2. #2
    Knows where you live
    Join Date
    Oct 2004
    Posts
    944
    Run it as a verlet engine and stick a spring between the two objects and the behavior is emergent.

    The button here isn't even running a verlet engine, it just has a simple spring attached to the mouse (and it is clickable).
    http://www.sharemation.com/691175002...tm?uniq=2py6v2

    Here is a more complex demo that is running verlet:
    http://www.sharemation.com/691175002...tm?uniq=2py6x4

    All that is happening is that the lines always try to stay the same length. All the rest of the behavior is just a side effect of that.

    Both examples are rather old and in AS2.0
    The greatest pleasure in life is doing what people say you cannot do.
    - Walter Bagehot
    The height of cleverness is to be able to conceal it.
    - Francois de La Rochefoucauld

  3. #3
    Senior Member ozmic66's Avatar
    Join Date
    Oct 2005
    Posts
    472
    Code:
    Run it as a verlet engine and stick a spring between the two objects and the behavior is emergent.
    Verlet is good (heck, I built an entire physics engine based on it) but sometimes explicitly defining angles and rotations can work better

    Quote Originally Posted by ArielGenesis
    in particular, how much of the force given by the red arrow will be converted into rotational and how much into transational.
    For a thorough explanation I'd refer you to Chris Hecker's Rigid Body Dynamics articles. But here's the short answer...

    Let's say a force is applied on an object at point cp of the object with a force F (a vector of x and y components), it's acceleration will be altered. To start, let's look at how the linear acceleration will be altered:

    Given the good old formula F = M*A (F = force, M = mass of the object, and A = accel)
    we can see that the linear acceleration on the body can be computed by solving for A:
    Code:
    A = F/M
    so, you add an x acceleration to the object of F.x/M and same with y.

    Code:
    accel.x += force.x/mass
    accel.y += force.y/mass
    That was easy, but how about rotational acceleration you may ask.. Well, it's not that much harder:

    First you need to find the x-dist and y-dist between the object's center of mass and the point of collision. This can be easily done:

    Code:
    var dist:Point = new Point()
    //cp is the point of collision (in global coordinates, so you don't have to switch back and fourth)
    //cm is the center of the object in global coords
    dist.x = cp.x-cm.x
    dist.y = cp.y-cm.y
    With linear force, we could just add it to the linear acceleration as above. To do the same with rotation, first we need to find the rotational force (aka torque) to apply. The equations then are very similar to the force ones.

    So, to find the torque, we need to take the dot product of the force vector and the dist vector's normal (hecker calls this the perp-product). If you don't know what that means, don't worry (though it's a good thing to understand).. here's how you get the perp-product

    Code:
    perpProduct = dist.x*force.y - dist.y*force.x
    Pretty easy isn't it?

    Believe it or not, that product is the torque to be applied on the object.

    So we can also say

    Code:
    var torque:Number = dist.x*force.y - dist.y*force.x
    Now how do we get the rotational acceleration to apply? simple.
    Remember F = M*A?

    In rotations you can use the formula:
    Code:
    Torque = I * AngularAccel (In books, you may see a weird greek symbol alpha here)
    Where I is the moment of inertia of the object. I won't get into that too much, but it'd equivalent to what mass is in linear terms. As you know, the higher the mass of an object is, the less a force would move it... Then the higher the moment of inertia is, the less a force would spin it. You should google around to see how you'd find the moment of inertia of a particular shape

    So finding the angular accel (simply solving that equation for angular accel):

    Code:
    AngularAccel = Torque/I
    Remember that this angular acceleration is in radians. If you are working with degrees, multiply it by 180/Math.PI

    So to bring it all together, applying a force on an object would do this:

    Code:
    function applyForce(object,collisionPoint:Point,force:Point){
    
    //linear
    object.accel.x += force.x/object.mass
    object.accel.y += force.y/object.mass
    
    //angular
    //get that distance vector
    var r:Point = new Point(collisionPoint.x-object.cm.x , collisionPoint.y-object.cm.y)
    
    var torque:Number = r.x*force.x + r.y*force.y
    
    object.angularAccel += torque/object.I
    }
    Last edited by ozmic66; 09-07-2007 at 02:57 PM.
    Pixelwave Flash-based iPhone framework
    iPhone Games: Flyloop | Freedom Run

    Twitter: Oztune

  4. #4
    Senior Member
    Join Date
    May 2006
    Posts
    145
    11161, the unclickable button hahahah that was fun.

    wow thanks ozmic66
    but what is vervlet?

    So the translational and rotational momentum is a two seperate thing. I was thinking that F=dp/dt change in momentum over change in time. and so the total momentum is angular momentum+translational momentum. how much of the force goes where! thx now its clear!

  5. #5
    Senior Member ozmic66's Avatar
    Join Date
    Oct 2005
    Posts
    472
    NP, I'm glad that helped. I hope it wasn't too confusing.

    Verlet is really just a way of integrating your simulation (moving it forwards in time) but when people say it they usually refer to how it is implemented in this article:

    http://www.teknikus.dk/tj/gdc2001.htm

    I seriously suggest you read it, as it can get you into making pretty cool things in a short amount of time, and you don't need to know any of the physics/math things I talked about before.
    Pixelwave Flash-based iPhone framework
    iPhone Games: Flyloop | Freedom Run

    Twitter: Oztune

  6. #6
    Senior Member
    Join Date
    May 2006
    Posts
    145
    It's an essay? or a thesis?

  7. #7
    Senior Member ozmic66's Avatar
    Join Date
    Oct 2005
    Posts
    472
    I would say that it's an paper/technical article. It's actually relatively simple to read through. If you have any questions I'd be glad to help clear some things up.
    Pixelwave Flash-based iPhone framework
    iPhone Games: Flyloop | Freedom Run

    Twitter: Oztune

  8. #8
    Senior Member
    Join Date
    May 2006
    Posts
    145
    well, what I am working now is a particle model, so it would be using a diffrent sort of physics. well, I am interested. but may be later.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center