Detecting if a tri is inside an axis-aligned cube

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

Recommended Posts

how i do that? some approach to that is using ray-tracing collision and classifying the tri vertices about their side of cube planes, but i'm wondering if there is a faster way....

Share on other sites
you said axis-aligned so basically you're just checking against the box's min and max values along the axial directions.

bool isTriInside(Vertex *vertices){    for (int i = 0; i < 3; ++i )    {        if ( vertices.x < box.minX || vertices.x > box.maxX            || vertices.y < box.minY || vertices.y > box.maxY            || vertices.z < box.minZ || vertices.z > box.maxZ )        {            //this vertex is outside the box            return false;        }    }    return true;}

Share on other sites
the seperating planes algorithm is what you need.

google is better at explaining than me.

Share on other sites
Quote:
 Original post by Palidineyou said axis-aligned so basically you're just checking against the box's min and max values along the axial directions.*** Source Snippet Removed ***

quite incorrect.

Share on other sites
Quote:
 Original post by Eelcoquite incorrect.

no, it's correct. he said "axis-aligned", not Object Oriented BOunding Box, in which case you have to check against the planes. with axis aligned you just have to check the coords.

-me

Share on other sites
Palidine, your algorithm just check if the vertices is inside the cube
a poly could overlap a cube with all it's vertices outside the cube

Eelco, is "seperating planes algorithm" the fastest way for this case?

Share on other sites
Quote:
 Original post by Jungle BoyPalidine, your algorithm just check if the vertices is in the cubea poly could overlap an cube with all it's vertices outside the cubeEelco, is "seperating planes algorithm" the fastest way for this case?thx for your replies

Ah, you said inside, which i took to mean "contained by", not "intersecting".

-me

Share on other sites
sorry for the "axis-oriented", the correct is "axis-aligned"
just edited the title....

Share on other sites
Quote:
 Palidine, your algorithm just check if the vertices is inside the cubea poly could overlap a cube with all it's vertices outside the cube.
I take it from this that you don't want a 'tri in axis-aligned cube' test, but rather a 'tri intersects axis-aligned cube' test. In that case eelco's suggestion may be your best bet.

What's the test for? Is it a pre-processing step, e.g. octree construction? Or something else? Depending on the context, different solutions may be more or less appropriate. It's hard to say though without knowing more about the application.

Share on other sites
sorry again, it should be "tri intersects or inside an axis-aligned cube"
just a poor english issue

i need to know which tris are intersecting/inside octree's cubes

1. 1
Rutin
36
2. 2
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• 14
• Forum Statistics

• Total Topics
633343
• Total Posts
3011434
• Who's Online (See full list)

There are no registered users currently online

×