Jump to content
  • Advertisement
Sign in to follow this  
AGlass0fMilk

Rotated position and other physics questions

This topic is 3072 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am currently writing a physics engine for my game engine and would like to be able to calculate the position of a vertex on a rotated shape as this picture illustrates:



I have an idea of how to go about calculating this, but I've had no luck in calculating the position correctly, and I don't know what to search for on the internets to find this information.

Also, this thread will most likely change as I will probably need to ask more questions about physics later on in my quest to create a working, realistic, and a worthy competitor other popular (stand-alone) physics engines.

I plan to post some of my code here later for you physics buffs to go over, to see if it calculates correctly. The simulations I am getting from my code seems to be realistic, but I feel as if the math is incorrect in some way

Also, I'm starting to get into the subject of collision detection (not response) and would like some references as well as explanations of common techniques. I hope for my physics engine to be able to support complex (and convex/concave) shapes as most other physics engines do. So any references concerning those topics would be nice as well.

Thanks


Edit:

I would also like to know how to draw a force being applied to a vertex, as illustrated by another picture:



Again, Thanks

[Edited by - AGlass0fMilk on July 15, 2010 2:45:44 PM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
I am currently writing a physics engine..

Some tough love: If you don't know how to transform a coordinate, you are in for a long haul.

FYI, I got 11,600,000 hits on google for "rotate coordinate." [wink]

In any case, construct a matrix to translate the object (translate the center of the shape, not the vertex) to the origin, rotate it by the requested angle and translate back to the object position. Apply that matrix to the vertex position. That general method may work better for you in the long run than coding a specific trig method for that one calculation. If you want to be specific, you can use trig.

With regard to references, you can download the source code for ODE (Open Dynamics Engine) and see how that sort of thing is implemented.

Share this post


Link to post
Share on other sites
Quote:
I have an idea of how to go about calculating this, but I've had no luck in calculating the position correctly, and I don't know what to search for on the internets to find this information.
Presumably, you know the local-space coordinates of the vertices. To find the world-space coordinates, simply transform the local-space coordinates by the object's current transform. (If that's not clear, perhaps you could specify what part you're having trouble with.)
Quote:
Also, this thread will most likely change as I will probably need to ask more questions about physics later on in my quest to create a working, realistic, and a worthy competitor other popular (stand-alone) physics engines.
If writing a physics engine interests you, I would definitely go for it - it'll be quite a challenge, and I imagine it will be a great learning experience.

Be aware though that there are already numerous high-quality physics engines available, both 2-d and 3-d, and both free and commercial. I think that even if you were able to create an engine comparable to, say, Box2D or Bullet (a tall order, IMO), you'd find that the market is already fairly saturated.

That's just my view though, which you can take or leave.
Quote:
Also, I'm starting to get into the subject of collision detection (not response) and would like some references as well as explanations of common techniques. I hope for my physics engine to be able to support complex (and convex/concave) shapes as most other physics engines do. So any references concerning those topics would be nice as well.
Common techniques/algorithms include the SAT (separating axis test), and 'closest points on medial structures' tests for 'rounded' shapes such as spheres and capsules. I believe that some engines also make use of GJK, a more general (and more complex) algorithm that operates on arbitrary convex shapes.

Another issue is whether tests will be discrete or continuous. The former is easier to code, while the latter can better prevent 'tunneling' effects. Some engines use discrete only, while some (like Box2D) use a mix of discrete and continuous.

Some engines also consider angular motion when performing collision tests.
Quote:
I would also like to know how to draw a force being applied to a vertex
How to render the effect depends on what graphics API you're using. If you're asking how to create the render geometry, you'll need the transformed vertex (as discussed earlier), and can compute the 'force arrow' vertices using a little vector math.

Share this post


Link to post
Share on other sites
Thank you for your replies. The use of matrices seems like a good place to start for my first problem.

I am using OpenGL and if I didn't make it clear, I already have working linear and rotational physics working in my engine.

If my Physics engine ends up being an atrocity, I'll probably utilize a 3rd party Physics engine (most likely Box2D) so users and myself can get the most out of my game engine.

But most of this is just a learning experience any way, so if I don't end up using my physics engine (and for that matter, game engine) at least I'll have learned more C++ and OpenGL techniques and some basic physics and rigid body dynamics and simulation techniques.

Share this post


Link to post
Share on other sites
Quote:

Another issue is whether tests will be discrete or continuous. The former is easier to code, while the latter can better prevent 'tunneling' effects. Some engines use discrete only, while some (like Box2D) use a mix of discrete and continuous.


By Discrete and Continuous, what do you mean? Could you give examples.

Share this post


Link to post
Share on other sites
Quote:
By Discrete and Continuous, what do you mean? Could you give examples.
I think if you Google/search for 'continuous collision detection' and check out a few of the references that come up, you'll get your answer. (If after that though you still have questions, post back.)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!