kzc_rectangle.hpp File Reference

2-dimensional rectangle. More...

Classes

struct  KzcRectangle
 Structure for rectangle. More...
 

Functions

KZ_INLINE struct KzcRectangle kzcRectangle (kzFloat x, kzFloat y, kzFloat width, kzFloat height)
 Creates a rectangle from a point (x,y) and size (width,height). More...
 
KZ_INLINE struct KzcRectangle kzcRectangleFromPoints (kzFloat x1, kzFloat y1, kzFloat x2, kzFloat y2)
 Creates a rectangle from two points defining arbitrary opposite corners. More...
 
KZ_INLINE struct KzcRectangle kzcRectangleFromVectors (const struct KzcVector2 *point1, const struct KzcVector2 *point2)
 Creates a rectangle from two points defining arbitrary opposite corners. More...
 
KZ_INLINE struct KzcRectangle kzcCreateAxisAlignedBoundingRectangle (const struct KzcVector2 *point1, const struct KzcVector2 *point2, const struct KzcVector2 *point3, const struct KzcVector2 *point4)
 Creates a bounding rectangle from four points describing arbitrary corner points. More...
 
KZ_INLINE struct KzcRectangle kzcRectangleFromVectorAndSize (const struct KzcVector2 *point, const struct KzcVector2 *size)
 Creates a rectangle from a point vector and size vector. More...
 
KZ_INLINE kzBool kzcRectangleIsEmpty (const struct KzcRectangle *rectangle)
 Checks if the rectangle is empty. More...
 
KZ_INLINE kzBool kzcRectangleContainsPoint (const struct KzcRectangle *rectangle, const struct KzcVector2 *point)
 Checks if the given point is inside the given rectangle. More...
 
KZ_INLINE kzBool kzcRectangleContainsRectangle (const struct KzcRectangle *rectangle, const struct KzcRectangle *otherRectangle)
 Checks if the given rectangle contains the given other rectangle completely. More...
 
KZ_INLINE kzBool kzcRectangleOverlaps (const struct KzcRectangle *rectangle1, const struct KzcRectangle *rectangle2)
 Checks if the two given rectangles overlap at least partially. More...
 
bool operator== (KzcRectangle rectangle1, KzcRectangle rectangle2)
 Test if rectangles are equal. More...
 
KZ_INLINE kzBool kzcRectangleIsEqual (const struct KzcRectangle *rectangle1, const struct KzcRectangle *rectangle2)
 Checks if the two given rectangles are same. More...
 
KZ_INLINE kzBool kzcRectangleIsAlmostEqual (const struct KzcRectangle *rectangle1, const struct KzcRectangle *rectangle2)
 Checks if the two given rectangles are approximately same. More...
 
KZ_INLINE struct KzcRectangle kzcRectangleUnion (const struct KzcRectangle *rectangle1, const struct KzcRectangle *rectangle2)
 Calculates bound rectangle for union of two rectangles. More...
 
KZ_INLINE kzBool kzcRectangleGrow (const struct KzcRectangle *increment, struct KzcRectangle *destination)
 Grows target rectangle as an union of another rectangle. More...
 
KZ_INLINE struct KzcRectangle kzcRectangleIntersection (const struct KzcRectangle *rectangle1, const struct KzcRectangle *rectangle2)
 Calculates intersection of two rectangles. More...
 
KZ_INLINE kzFloat kzcRectangleGetArea (const struct KzcRectangle *rectangle)
 Calculates the area of a rectangle. More...
 

Variables

const struct KzcRectangle KZC_RECTANGLE_EMPTY
 Constant zero area rectangle in origin. More...
 

Detailed Description

2-dimensional rectangle.

The rectangle sizes remain non-negative for all operations as long as the input sizes are non-negative.

Copyright 2008-2017 by Rightware. All rights reserved.

Function Documentation

KZ_INLINE struct KzcRectangle kzcRectangle ( kzFloat  x,
kzFloat  y,
kzFloat  width,
kzFloat  height 
)

Creates a rectangle from a point (x,y) and size (width,height).

KZ_INLINE struct KzcRectangle kzcRectangleFromPoints ( kzFloat  x1,
kzFloat  y1,
kzFloat  x2,
kzFloat  y2 
)

Creates a rectangle from two points defining arbitrary opposite corners.

KZ_INLINE struct KzcRectangle kzcRectangleFromVectors ( const struct KzcVector2 point1,
const struct KzcVector2 point2 
)

Creates a rectangle from two points defining arbitrary opposite corners.

KZ_INLINE struct KzcRectangle kzcCreateAxisAlignedBoundingRectangle ( const struct KzcVector2 point1,
const struct KzcVector2 point2,
const struct KzcVector2 point3,
const struct KzcVector2 point4 
)

Creates a bounding rectangle from four points describing arbitrary corner points.

KZ_INLINE struct KzcRectangle kzcRectangleFromVectorAndSize ( const struct KzcVector2 point,
const struct KzcVector2 size 
)

Creates a rectangle from a point vector and size vector.

KZ_INLINE kzBool kzcRectangleIsEmpty ( const struct KzcRectangle rectangle)

Checks if the rectangle is empty.

KZ_INLINE kzBool kzcRectangleContainsPoint ( const struct KzcRectangle rectangle,
const struct KzcVector2 point 
)

Checks if the given point is inside the given rectangle.

The rectangle is closed from left/right but open from right/bottom.

KZ_INLINE kzBool kzcRectangleContainsRectangle ( const struct KzcRectangle rectangle,
const struct KzcRectangle otherRectangle 
)

Checks if the given rectangle contains the given other rectangle completely.

KZ_INLINE kzBool kzcRectangleOverlaps ( const struct KzcRectangle rectangle1,
const struct KzcRectangle rectangle2 
)

Checks if the two given rectangles overlap at least partially.

bool operator== ( KzcRectangle  rectangle1,
KzcRectangle  rectangle2 
)
inline

Test if rectangles are equal.

Parameters
rectangle1First rectangle.
rectangle2Second rectangle.
Returns
True if equal, false if not.
KZ_INLINE kzBool kzcRectangleIsEqual ( const struct KzcRectangle rectangle1,
const struct KzcRectangle rectangle2 
)

Checks if the two given rectangles are same.

KZ_INLINE kzBool kzcRectangleIsAlmostEqual ( const struct KzcRectangle rectangle1,
const struct KzcRectangle rectangle2 
)

Checks if the two given rectangles are approximately same.

KZ_INLINE struct KzcRectangle kzcRectangleUnion ( const struct KzcRectangle rectangle1,
const struct KzcRectangle rectangle2 
)

Calculates bound rectangle for union of two rectangles.

KZ_INLINE kzBool kzcRectangleGrow ( const struct KzcRectangle increment,
struct KzcRectangle destination 
)

Grows target rectangle as an union of another rectangle.

Return true if union is actually larger than the original.

KZ_INLINE struct KzcRectangle kzcRectangleIntersection ( const struct KzcRectangle rectangle1,
const struct KzcRectangle rectangle2 
)

Calculates intersection of two rectangles.

KZ_INLINE kzFloat kzcRectangleGetArea ( const struct KzcRectangle rectangle)

Calculates the area of a rectangle.

Variable Documentation

const struct KzcRectangle KZC_RECTANGLE_EMPTY

Constant zero area rectangle in origin.