Comments on: SAT (Separating Axis Theorem) http://www.codezealot.org/archives/55 Development blog and open source repository by William Bittle Thu, 02 Jan 2014 12:51:55 +0000 hourly 1 http://wordpress.org/?v=3.8 By: William http://www.codezealot.org/archives/55#comment-99361 Fri, 20 Dec 2013 13:15:13 +0000 http://codezealot.org/?p=55#comment-99361 @Greg

Yes.

A vector represents two things: a direction and a magnitude (length). What I meant by “vector portion” was the direction. The axes that we used to test for collision are normalized (they have a length of 1) and as such represent only the direction of the MTV. For the magnitude of the MTV we use the overlap along the axis (we use the axis whose overlap is the smallest).

William

]]>
By: Greg http://www.codezealot.org/archives/55#comment-99232 Thu, 19 Dec 2013 20:34:03 +0000 http://codezealot.org/?p=55#comment-99232 “That axis and that overlap is the MTV, the axis being the vector portion, and the overlap being the magnitude portion.”

I’m a bit confused by this part, specifically what is meant by “vector portion.” Do you mean the MTV is a vector in the same direction as the axis, but with a magnitude equal to the overlap?

]]>
By: William http://www.codezealot.org/archives/55#comment-97808 Tue, 10 Dec 2013 23:32:28 +0000 http://codezealot.org/?p=55#comment-97808 @Sam

You can do collision detection against arbitrary curves, just not using SAT. SAT is designed for polygonal shapes. One option would be to implement a line segment shape that you then string together to make a piece-wise curve. Another option is just to implement a collision detection routine specifically for curves. .

William

]]>
By: Sam http://www.codezealot.org/archives/55#comment-97733 Tue, 10 Dec 2013 11:55:34 +0000 http://codezealot.org/?p=55#comment-97733 Thanks for the quick reply! I have actually read that article you linked but I couldn’t seem to work out how they had done it.
So from what I understand, if I have a shape like the one I described in the last comment, I take the axis from the center of the curve to each vertex of the other shape, as well as all of the axis’s of the other shape?
I was mainly interested in this type of collision for games that would have terrain such as hills and slopes that aren’t straight, but I assume it would be easier to just use many covex shapes such as rotated rectangles to form the outer part of the hill and just test against all of them, since the types of terrain I am thinking of would not be circular?

]]>
By: William http://www.codezealot.org/archives/55#comment-97652 Mon, 09 Dec 2013 13:13:43 +0000 http://codezealot.org/?p=55#comment-97652 @Sam

The shape you describe is concave, not convex. As such, SAT will not work on it (however, see this , for a way to get around it for circular concave shapes). SAT can work with any convex circular shape (Circles, Capsules, half circles, circular sections, etc) without really any extra work. In these cases always test the axis from the center of the arc to each vertex of the other shape (you can eliminate some of the vertices to test if you examine which voronoi region of the polygon the center of the arc lies). You will run into problems if the curved shape is not circular (ellipse, arbitrary bezier, cubic, etc).

That said, depending on the goal, you can decompose the concave shape into many convex shapes. This will work just fine, you just have more shapes to detect collision with.

William

]]>
By: Sam http://www.codezealot.org/archives/55#comment-97201 Sat, 07 Dec 2013 08:46:38 +0000 http://codezealot.org/?p=55#comment-97201 Amazing article, I learnt a lot from this, however I am having some trouble with detecting collision with a polygon and a curved shape, what I am trying to achieve is collsion detection with a shape that is simliar to a hill or a curved ramp (if you can imagine a right hand triangle with a hypotenuse that is curved inwards towards the right angle). I’m just not really sure which of the above methods would work, I presume I would break the shape down into many smaller triangles and use SAT on each one but I’m not so confident that it would work, any advice would be great, thanks!

]]>
By: William http://www.codezealot.org/archives/55#comment-87755 Wed, 23 Oct 2013 12:15:18 +0000 http://codezealot.org/?p=55#comment-87755 The number of planes you need to test on is dependent on the number of faces in the two shapes. For example, if we are trying to test if a box and a tetrahedron are intersecting we need to get all the planes to project onto from both shapes. Looking at the box first, there are 6 faces. Normally this would mean 6 planes to test, but since some of the faces are parallel, we only need to test the 3 non-parallel faces. For the tetrahedron, we have 4 faces. No faces are parallel in this shape so we have 4 planes to test. In total we have 7 planes to project both shapes onto. Once you’ve done the projection onto a plane, then you can use whats described in the post.

Having said this, I think I’ve read somewhere that you can do 3D SAT a little different to save some work, but I don’t remember where I read that. A Google search might help here.

William

]]>
By: Sarasca http://www.codezealot.org/archives/55#comment-87636 Tue, 22 Oct 2013 21:11:44 +0000 http://codezealot.org/?p=55#comment-87636 Hi,

i want to use the SAT & MTV for a 3D-Javagame.

So i have a 3D-Object and project that Object onto a 2D-Plane. After that is done i just follow this tutorial. Am i right with the thought that i have to project the same 3D-Object onto two other 2D-Planes from different angles (top, side, front), in order to get the full 3D-Object? Or do i have to project it even more?

]]>
By: 黒本 瞳 http://www.codezealot.org/archives/55#comment-73185 Wed, 07 Aug 2013 04:24:55 +0000 http://codezealot.org/?p=55#comment-73185 Usually I do not read post on blogs, but I wish to say that this write-up very forced me to take a look at and do so! Your writing style has been surprised me. Thank you, very nice article.

]]>
By: Benno http://www.codezealot.org/archives/55#comment-64806 Wed, 05 Jun 2013 12:51:46 +0000 http://codezealot.org/?p=55#comment-64806 Hey,

Very great tutorial, thanks a lot.

I´ve implemented a SAT but it does not work completely properly.
I sent you an E-Mail with my code. Maybe you are able and have the time to find the mistake even though it is no java code.

Thanks, Benno

]]>