Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

3D Physics Equations to 2D

  1. Aug 12, 2007 #1
    Hello, I'm trying to write a 2D physics engine to learn the basic principles of how this all comes together. As a note, I'm not very adept in the field of physics. I took physics in college but it was very difficult for me.

    This is a rather general question, and I'm not sure it has a simple answer, but here it goes:

    What's the general method of converting a 3D equation to 2D? The problem I'm having is most formulas are written for 3D applications, but I want a 2D implementation only. I chose this specifically to force myself to learn the equations and the inner workings of the math behind the equations. But I'm having a bit of trouble visualizing this process.

    Here's an example (Computing Velocity Impulse of Two Colliding Bodies):

    From equation for velocity of a rigid body Vi = V + w X r
    Code (Text):
    Vector3 V = Body.LinVelocity + Cross( A.AngVelocity, Contact.Point - Body.Position );
    3D:Since the cross between two triples will generate a another triple it can be added to the linear velocity triple.
    2D: A cross between two 2D vectors will yield a single number and cannot be added to a vector, so how do you perform an operation such as this? Worse yet, I don't even need a vector for AngVelocity in 2D since I can limit rotations to a single axis, which means I can't even perform a cross product on AngVelocity and another vector as the example shows above.

    There are far more complex examples:
    Take computing the magnitude of acceleration at Contact.Point in the Normal direction of Contact. Here is one of the terms in this process:
    Code (Text):
    Vector3 At2 = Cross( Body.InvInertialTensor * ( Body.NetTorque + Cross( Body.AngMomentum, Body.AngVelocity)), Contact.Point - Body.Position );
    Inertial Tensor in 3D is a 3x3 Matrix, which is multiplied by term Body.NetTorque + Cross( Body.AngMomentum, Body.AngVelocity) to yield a triple, which is then crossed with Contact.Point - Body.Position.

    In 2D, I can limit inertial tensor to a single variable. AngMomentum, like its counterpart AngVelocity is also a single variable. That does away with the Cross( Body.L, Body.W ), but what operation should be performed instead? And for the second outer Cross, I am left with Cross( 1-Tuple, 2-Tuple )... another conundrum.

    Any help would be greatly appreciated. I know it would probably just be best to read some literature actually involving 2D applications of the above-mentioned topics, but I'm just throwing this concept out there for fun to anyone who is patient enough to respond. Thanks.
    Last edited: Aug 12, 2007
  2. jcsd
  3. Aug 12, 2007 #2


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    "Projection" is the important idea here.
    Vectorially, this is done with a dot product.

    Given a vector V in 3D, you can form its projection onto the xy-plane by removing the z component of V: V_proj= V - dot(V,z-hat) z-hat, where z-hat is the unit vector in the positive z-direction. (In terms of (x,y,z) coordinates, this essentially zeroes-out the z component.)

    (Note, in 2D, the moment of inertia tensor has 3 independent components.)
  4. Aug 12, 2007 #3
    I was vague. I'm sorry for not explaining better. The trouble I'm having is not taking an existing 3D space and converting it. The problem I'm having is taking the equations for 3D physics interactions and converting them entirely to 2D so that I can create a 2D space in which all interactions are entirely 2D.

    I don't believe projection would be required because the z-axis is never even considered.

    Insofar as Inertia Tensor, I am defining it as the second moment of mass. Or: J = ∫(r²)dm.
    In such a definition, only a scalar is required because: Each element of mass is multipied by the square of its distance from the center of rotation. If this is not legitiment please explain what I am doing wrong.

    My primary problems stem from this fact: J, w, and L are not sized down by 1 dimension, but 2 dimensions. In 3D they are 3 dimensions, in 2d they are only 1 dimension. Rotations can only occur along 1 axis ( the perpendicular axis to x and y ). This is how I intuitively structured my math. Again, I'm not an expert. This, however, creates problems when converting from a 3D system of equations to 2D.

    With respect to the questionability about Cross( Body.L, Body.w ), with L = Angular Momentum, w = Angular Velocity:

    Cross Product of 2 Triples = |a||b|sin[tex]\alpha[/tex] * n[tex]\widehat{}[/tex]

    L = w * J

    In 2D, Cross( Body.L, Body.w ) = Cross( w*J, w ) = (|w|*J)*|w|*sin(0) = 0. Would this be correct?
    Last edited: Aug 12, 2007
  5. Aug 12, 2007 #4
    I've been thinking about the conversion of
    Cross( a, b )
    Cross( az, bxby )

    This is in regards to how to properly convert Cross( Body.w, Contact.Point - Body.Position ) in 3D to 2D. In 3D I have 2 Vector3's, in 2D I have Cross( Scalar, Vector2 ). The conversion, if the Scalar represents the original first Vector3's third component and the Vector2 represents the original second Vector3's first and second components. I.E. Cross( xyz, xyz ) = Cross( z, xy )
    Then the formula is:

    Cross( Vector3(0,0,az), Vector3( bx, by, 0 ) ) = Vector3( 0-az*by, az*bx-0, 0 ) = az*Vector3( -by, bx, 0 )


    Perp( b ) * a

    or in context...

    if Cross( Vector3, Vector3 ) in 3D yields Cross( Scalar, Vector ) in 2D
    then the 2D representation of that computation is Perp( Vector ) * Scalar
    Last edited: Aug 13, 2007
  6. Aug 13, 2007 #5
    I'm not sure it makes much sense to "convert" Physics in 3-D to Physics in 2-D. If you really want a system of equations describing 2-D Physics, you should derive them from Newton's laws, working in 2-D right from the start. The problem is that there are dynamics that can occur in 3-D, but which have no meaning in 2-D.

    For example, you mention the cross-product of L and w. In 3-D this makes sense since the two vectors might not be parallel. In 2-D, where all rotations must take place in the x-y plane, L and w will always be parallel, so their cross-product will always be zero.

    In general, vector equations with cross-products are written in 3-D because the resulting vector is perpendicular to the plane of the two vectors being crossed. In 2-D, where the perpendicular direction is not defined, you have to modify the rules for manipulating cross-products. I think you might be on the right track by redefining cross-products in such a way as to suppress explicit reference to third vector components. Any 3-D equations the seem to require a vector out of the x-y plane as a result are likely incorrect, since nothing that occurs in a plane should require movement out of the plane. Any equation that might produce such a result in 3-D should reduce to 2-D when all the input vectors are coplanar.

    Certain 3-D dynamics will remain undefined, such as the motion of an electric charge in a magnetic field. In that case, the motion is 3-dimensional, and you would have to derive Maxwell's Equations in 2-D from scratch. (I'm not sure how an electric charge would behave in a magnetic field in 2-d.)

    Hope that helps.
    Last edited: Aug 13, 2007
  7. Aug 13, 2007 #6
    Yes, that was a big help thank you. I'm beginning to see that there are equations that simply don't make sense. I have been able to logically decompose 90% of the 3D equations, but some just don't make sense, even in a simple Rigid Body model.

    The trouble I'm having with 2D is finding good literature that is strictly 2D. I admit, I haven't searched incredibly hard, but it certainly wasn't hard to find elaborate 3D references.

    If you or anyone have good 2D rigid body reference, please share!

    Also, in 3D many texts talk about using a Runge-Kutta 4th Order Differential Solver. Would it make sense to use a RK4 solver for 2D as well?
  8. Aug 13, 2007 #7
    You can use the RK4 integrator for solving equations of motion in any number of dimensions - or at least, I'm not aware of any restriction base on the number of dimensions.

    I'm not sure you'll find a lot of literature on purely 2D Physics. Usually problems are solved in 2D only as a simplification for 3D problems that can be reduced to 2D for convenience, like the two-body problem.

    What I would do would be to start with general equations (i.e. general vector equations, where appropriate), and then see how they behave when all initial conditions are expressed in two dimensions. You might occasionally get an expression for vectors in the third direction, e.g. for expressing a torque, but in that case you'll have to treat write the equations in terms of the magnitudes of these vectors. A torque will produce an angular acceleration, for example, but you'll just have to treat that as a scalar, since all rotational vectors (and all cross-products, for that matter) will be perpendicular to your 2D space.

    That's not very detailed, I know, but all I'm saying is that I believe that what you're trying to do is possible; you're just going to have to work through the math.
  9. Aug 13, 2007 #8
    Cool, thanks for the tips. While being forced to solve the equations on my own is a inconvenience in one sense, it is a lot of fun to actually produce a solution that is, in some ways, my own. ( At least in the sense that it requires understanding all the concepts and applying them to a known problem ).
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook