Thread: calculating bounding box for triangle

  1. #1
    Registered User
    Join Date
    Sep 2020
    Posts
    6

    calculating bounding box for triangle

    can anyone please help how to calculate a bounding box for a triangle ? i have no clue how to do it

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,207
    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.

  3. #3
    Registered User
    Join Date
    May 2012
    Posts
    441
    Quote Originally Posted by olf View Post
    can anyone please help how to calculate a bounding box for a triangle ? i have no clue how to do it
    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


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Isometric Bounding Box Algorithims
    By leeor_net in forum C Programming
    Replies: 7
    Last Post: 04-09-2004, 11:53 PM
  2. Need help with bounding functions!
    By Lisa in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2002, 02:02 AM
  3. Bounding box collision detection?
    By Crossbow in forum Game Programming
    Replies: 5
    Last Post: 07-13-2002, 05:20 PM
  4. bounding box collision detection
    By DavidP in forum Game Programming
    Replies: 7
    Last Post: 07-07-2002, 11:43 PM
  5. Replies: 1
    Last Post: 01-30-2002, 01:04 PM

Tags for this Thread