# Elgrint::MRect class

### Declared in elStructs.h

## Description

Describes a 3D non-rotated box-like region in space, aka "rectangle" or "rect".

Read more...

## Data members:

Name | Type | Init value | Description |
---|---|---|---|

x | MPointElem | 0 | Same as the x element of MPoint. |

y | MPointElem | 0 | Same as the y element of MPoint. |

z | MPointElem | 0 | Same as the z element of MPoint. |

w | MSizeElem | 0 | Same as the w element of MSize. |

h | MSizeElem | 0 | Same as the h element of MSize. |

d | MSizeElem | 0 | Same as the d element of MSize. |

## Initializers:

Name | Description |
---|---|

MRect() | Default constructor. Sets data members (elements) to their initial values. |

MRect(p,s) | Init constructor. Sets data members (elements) to the specified values. |

MRect(p,aw,ah) | Init constructor. Sets data members to the specified or default values. |

MRect(ax,ay,az,aw,ah,ad) | Init constructor. Sets data members (elements) to the specified values. |

MRect(ax,ay,s) | Init constructor. Sets data members to the specified or default values. |

MRect(ax,ay,aw,ah) | Init constructor. Sets data members to the specified or default values. |

## Revealers:

Name | Description |
---|---|

crossWith(r) | Calculates the intersection of two valid rects. |

includes2D(p) | Returns true iff p is located inside this rect, while ignoring the z coordinates. |

includes2D(r) | Returns true iff the entire r is located inside this rect, while ignoring the z coordinates. |

includes3D(p) | Returns true iff p is located inside this rect, accounting for the z coordinate as well. |

includes3D(r) | Returns true iff the entire r is located inside this rect, accounting for the z coordinates. |

isEmpty2D() | Returns true iff the rect has zero area on the XY plane (i.e. w*h == 0). |

isEmpty3D() | Returns true iff the rect has zero volume (i.e. w==0 || h==0 || d==0). |

p1() | Returns the coordinates of the top-left corner of MRect. |

p2() | Returns the coordinates of the bottom-right corner of MRect (but already outside of this MRect). |

size() | Returns the size of MRect. |

unionWith(r) | Calculates the union of two valid rects. |

## Global functions:

Name | Description |
---|---|

operator!=(r1,r2) | Logical opposite of operator==. |

operator+(r,dp) | Returns r shifted by dp (or less). |

operator+(r,ds) | Returns r with its size increased by ds (or less). |

operator-(r,dp) | Returns r shifted by -dp (or less). |

operator-(r,ds) | Returns r with its size decreased by ds (or less). |

operator<<(r1,r2) | Validates r1 using r2 and returns the result. |

operator<<(str,r) | Appends r to str in an "x,y,z,w,h,d" form with component identifiers. |

operator<<=(r1,r2) | Validates r1 using values in r2. |

operator==(r1,r2) | Returns true iff r1 and r2 are equal (with 1E-9 fault tolerance). |

## Details

MRect is the union of all the elements of MPoint and MSize. Its six data members describe a boxed region of space, whose edges are parallel to the coordinate axes (no rotation).

'MRect' is used for describing the position and size of a window, and for specifying a bounding box for various painting functions, among other things.

## Remarks

- The word "rect" is not short for "rectangle", because rectangle is a 2D shape, while rect is 3D (the word "box" is less intuitive and is already taken by selector windows). That being said, as long as 3D windows and graphics are not supported, the words "rect" and "rectangle" can be used interchangeably

## Let us know

Please Contact us to report any errors on this page, or to suggest any improvements.