# XNA 4.0 Plane size

Possibly a dumb question, but do planes stretch on to infinity? I can't define a spanning area for it, and would have to do some sort of check for collisions like if(x intersects BoundingBox and Plane?

Edit: I'm trying to do wall collision and would like to take into account diagonal walls, which would be impossible for bounding boxes as they are axis aligned.

• It might help if you said what you are actually trying to do here, as there may be other solutions that work better. Mar 17, 2013 at 9:48

A plane is only defined by a normal vector and a position. The position is the 'center' of the plan and the normal vector is where 'up' is. Other than that a plane has no bounds, it is indeed infinite. If you would just like a square piece of ground (or wall or whatever) you should just use BoundingBox since they have a position and bounds so they should suit your needs.

It sounds like you already conceived of using planes to define arbitrarily shaped regions. It's not necessarily the most efficient method, but you can use them for collision detection. The planes can represent half-spaces, informally meaning that one half of space is on one side of the plane.

An axis-aligned bounding box is a specific case of using six halfspaces, two for each axis with opposite directions. If a point is on the positive side of all six planes, it is within the bounding box. If a point is on the wrong side of any plane, you immediately know it does not intersect the box, and you can skip further checks.

The same method can be used for an oriented bounding box (different plane normals) or for shapes other than rectangular prisms. Wikipedia calls them convex polytopes.

So for your purposes, you could use planes to define your diagonal walls. Planes are purple, your player is red.

If your player's position, projected onto the plane's normal vector (dot product), is less than the plane's distance from the origin in the direction of its normal (accounting for some radius of size of the player), then that player has not collided with the wall. If it exceeds that check value, then you know the distance and direction to push your player back out of collision.

Unforuntely, you don't get the early-exit benefit because you aren't using convex shapes, but you can still accomplish what you want.