- #1
cycloverid
- 5
- 0
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
3D:
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:
3D:
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.
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
3D:
Code:
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:
3D:
Code:
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: