Public Group

# Having Trouble converting a Rectangle to a AABB

This topic is 3803 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi all, I've looked all over the place all day. I have this RECT {0, 0, 5120, 5120} now to convert this to a AABB is this the right way AABB.min.x = 0; AABB.min.y = 0; AABB.min.z = 0; AABB.max.x = 5120; AABB.max.y = 10; AABB.max.z = 5120; please need help I can Get it to work if I use D3DXCreateBox and then use D3DXComputeBoundingBox with bounds but I cant keep calling this all the time in the render function.

##### Share on other sites
(asuming C++ here)

that rect initialisation initialises like so

RECT r = {left, top, right, bottom}
RECT r = {0, 0, 5120, 5120}

(from http://msdn2.microsoft.com/en-us/library/a5ch4fda(VS.71).aspx )

therefore your bounding box should look more like

AABB.min.x = r.left;
AABB.min.y = r.bottom;

AABB.max.x = r.right;
AABB.max.y = r.top

No idea where you're grabbing your z components from, but that's the AABB based on the XY dimensions.

##### Share on other sites
Quote:
 Original post by Winegumsyour bounding box should look more likeAABB.min.x = r.left;AABB.min.y = r.bottom;AABB.max.x = r.right;AABB.max.y = r.top

This will make the AABB's width and height be twice the amount of the RECT. Also, with RECTs, bottom is greater than top (because in screen coordinates, y increases down). So it should be:

AABB.min.x = r.left / 2.0f;
AABB.min.y = r.top / 2.0f;

AABB.max.x = r.right / 2.0f;
AABB.max.y = r.bottom / 2.0f;

##### Share on other sites
oh yeah they work to well there total culling I dont think there right

1. 1
Rutin
24
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 9
• 46
• 41
• 23
• 13
• ### Forum Statistics

• Total Topics
631746
• Total Posts
3002021
×