Skip to main content
gamedev.net
🔒 Locked

quad-quad interception

Started by cannonicus 2 replies 900+ views
Original Post
cannonicus
cannonicus
Hello What is the fastest way of checking whether or not 2 quads are partially or completly overlapping each others in 2d? I guess one could check for line interception between all lines in the quads, but that would be 16 pretty costly computations. There should be a better way. Thanks in advance //Emil
Emil Jonssonvild
oliii
oliii
axis aligned? rotated?
Everything is better with Metal.
cannonicus
cannonicus
one of them will always be axis aligned. the other one can be both rotated and scewed, but it will always be a quad.

I will use this to determin if a section of my 2d sidescroller terrain (the axis alined quad) is partially or completly inside the camera frustum (the skewed / rotated quad).
Emil Jonssonvild
Zakwayda
Zakwayda
Quote:
one of them will always be axis aligned. the other one can be both rotated and scewed, but it will always be a quad.

I will use this to determin if a section of my 2d sidescroller terrain (the axis alined quad) is partially or completly inside the camera frustum (the skewed / rotated quad).
As oliii will probably tell you as well, the separating axis theorem may be what you're looking for. In 2d, it can very quickly determine intersection or non-intersection between the shapes you mention.

However, for frustum culling of any sort, accuracy is often sacrificed for a slightly faster test. The standard AABB/frustum test culls the AABB against the planes of the frustum; this method can easily be adapted to 2d. It's basically the SAT, except that only the axes from the frustum planes are tested (resulting in the occasional false positive).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.