Search code examples
image-processingconventionsconvention

Convention for order of coordinates when defining a rectangle


Given a coordinate system (e.g. pixel grid), you can define a rectangle with four numbers: two x-axis values (sides of rectangle) and two y-axis values (top/bottom of rectangle). My question is, is there a widely used and/or accepted convention for what order these values should be? What order would be the most familiar to those in the image processing world?


Solution

  • There is no "convention" as different uses might need different representations.
    FWIW, rectangles are usually defined in one of two ways:

    1. Origin (x,y) + Size (width x height)
    2. Top Left (x0,y0) + Bottom-Right (x1, y1)

    That being said, there are many permutations of these and often class methods will provide conversions and multiple constructors might support multiple initializations.