Contact vector and rotation.

Started by
1 comment, last by MadsGustaf 16 years ago
Hello. I have two polygons (lets just say squares). I only want to handle collision response if the square is colliding against one specific side. Without rotation, i would just look if the contact vector was above or equal to the squares top border coordinates. When the squares are rotating, i am not quite sure how i would do this. [Edited by - MadsGustaf on April 1, 2008 12:16:57 PM]
•°*”˜˜”*°•.˜”*°•..•°*”˜.•°*”˜˜”*°•..•°*”˜˜”*°•.˜”*°•.˜”*°•. Mads .•°*”˜.•°*”˜.•°*”˜˜”*°•.˜”*°•..•°*”˜.•°*”˜.•°*”˜ ˜”*°•.˜”*°•.˜”*°•..•°*”˜I am going to live forever... or die trying!
Advertisement
Each side of a polygon is a line segment. So I think you can just do a polygon-line segment collision test, which itself is just:
- if either end of the line segment is inside the polygon, there is a collision
- otherwise, if any of the edges of the polygon intersect the line segment (a series of line segment-line segment intersection tests), there is a collision
This is what i would want:

Click Me

in case 1) i dont want to handle any specific collisions (as the green square does not intersect with the side of the red square outlined by the blue line). This is what i currently have on all sides of the square.

In case 2) the green square does intersect the blue line of the red square, so i would like to proceed a special collision response, but how do i determine if the green square is oversecting the blue line at any rotation?


The general physics collision/response is handled by the physics engine, but i have acces to the vertices of the squares, rotations and contact vectors.
•°*”˜˜”*°•.˜”*°•..•°*”˜.•°*”˜˜”*°•..•°*”˜˜”*°•.˜”*°•.˜”*°•. Mads .•°*”˜.•°*”˜.•°*”˜˜”*°•.˜”*°•..•°*”˜.•°*”˜.•°*”˜ ˜”*°•.˜”*°•.˜”*°•..•°*”˜I am going to live forever... or die trying!

This topic is closed to new replies.

Advertisement