separating axis test

Started by
13 comments, last by OvRLoRD 20 years, 3 months ago
EDIT : what Am i saying...

for 2D rectangle-tri separation axis test, the axes are

box.dir1 (because it is perpendicular to box.dir0)
box.dir0 (because it is perpendicular to box.dir1)

Vector2(-tri.edge0.y, tri.edge0.x); // vector perpendicular to edge0
Vector2(-tri.edge1.y, tri.edge1.x);// vector perpendicular to edge1
Vector2(-tri.edge2.y, tri.edge2.x);// vector perpendicular to edge2

if you cross product the segments of the box and triangle, you'd get a vector perpendicular to both, which would basically go through the screen, so not very useful


[edited by - oliii on January 16, 2004 6:50:27 PM]

Everything is better with Metal.

Advertisement
quote:Original post by BarnyardMessiah
Your triangle/triangle case is for non-planar triangles right?

Because if they had the possibility of being planar the test would look like this:

tri0.norm
tri1.norm

tri0.edg1 x tri1.edg1
tri0.edg1 x tri1.edg2
tri0.edg1 x tri1.edg3
tri0.edg1 x tri1.norm

add nausea...


... and I messed up on that one...

axes are

tri0.norm

tri0.edge0 x tri0.normal
tri0.edge1 x tri0.normal
tri0.edge2 x tri0.normal

tri1.edge0 x tri0.normal
tri1.edge1 x tri0.normal
tri1.edge2 x tri0.normal


that''s when (fabs(tri1.normal dot tri0.normal) > 0.9999f)

Everything is better with Metal.

thanks olii, i went to start coding and i realized the cross wouldn''t do anything either. but you already had it fixed by the time i came back to ask again.

lol

you''ve been a huge help

thanks again
np. :D

Everything is better with Metal.

I''ve modified the demo this morning, so it has oriented bounding boxes, colliding with AABBoxes, spheres, and other oriented bonding boxes. It''s using what I''ve described in this thread.

You can have a look at

pong collision

or grab it from my main page.

Everything is better with Metal.

This topic is closed to new replies.

Advertisement