Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Triangles (Collision and Rotation)

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2004
    Location
    Hurricane, UT, USA
    Posts
    4

    Triangles (Collision and Rotation)

    I was wondering if someone could help me. I'm writing a program that has circles that bounce on the screen with air friction, collision friction and gravity all incorporated. I was wondering how would I incorporate triangles into the program and have then bounce off the circles and rotate accordingly as if in the real world.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Oct 2002
    Location
    San Diego, CA, USA
    Posts
    209

    Re: Triangles (Collision and Rotation)

    oooh, that's a tricky one. My old thinker is drawing a zero on how to do the collision detection, but I suggest you think of the triangles having "weight" at each vertex, and when there's a collision you apply a force with the appropriate lever arm to the center of the triangle's mass. Taken physics 1? That's prolly the only way to make it all seem real.

    Hmm... collision... I suppose each line of the triangle can split the screen into two halfspaces. If the ball is at all within the halfspace shared by the triangle, keep on testing. Otherwise, it isn't colliding.
    Test all three halfspaces, if the ball is touching or within all three halfspaces, it may very well be hitting the triangle. Draw the whole thing out on paper... You'll see there are some error regions, so you'll have to test for those.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Oct 2002
    Location
    King George, Virginia
    Posts
    132

    Re: Triangles (Collision and Rotation)

    this involves getting into rigid body dynamics. unlike particles, which are just point masses, larger objects have a center of mass. this is the point about which an object will rotate. think if you apply a force to one tip of the triangle. it will start to spin. the point it spins around is the center of mass. also, if the force is applied more towards the center of the triangle, it will spin less and be pushed a little more.

    here's a great link to some siggraph papers that talk about physics and dynamics (from the ground up).

    warning: bone up on your calculus, as it's used heavily in these articles
    http://www-2.cs.cmu.edu/~baraff/sigcourse/index.html

Posting Permissions

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