can anyone please help how to calculate a bounding box for a triangle ? i have no clue how to do it
can anyone please help how to calculate a bounding box for a triangle ? i have no clue how to do it
It's just min and max of all the coordinates.
bb.left = min of all the x coordinates
etc.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Start by writing macros or functions min2 / max2. These take two numbers and return the minimum, maximum.
Then build min3(), max3() on top of those functions.
Now the bounding box is upper left the minimum, lower right the maximum. You need to call for x and then fot y. If you need origin / width. height instead of co-ordinates, just subtract the minimum values from the maximum values to get the dimensions.
I'm the author of MiniBasic: How to write a script interpreter and Basic Algorithms
Visit my website for lots of associated C programming resources.
https://github.com/MalcolmMcLean