A* Pathfinding Project  3.6.6
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
IntRect Struct Reference

Integer Rectangle. More...

Detailed Description

Integer Rectangle.

Works almost like UnityEngine.Rect but with integer coordinates

Public Member Functions

 IntRect (int xmin, int ymin, int xmax, int ymax)
 
bool Contains (int x, int y)
 
void DebugDraw (Matrix4x4 matrix, Color col)
 Draws some debug lines representing the rect.
 
override bool Equals (System.Object _b)
 
IntRect Expand (int range)
 Returns a new rect which is expanded by range in all directions.
 
IntRect ExpandToContain (int x, int y)
 Returns a new IntRect which is expanded to contain the point.
 
override int GetHashCode ()
 
bool IsValid ()
 Returns if this rectangle is valid.
 
IntRect Offset (Int2 offset)
 Returns a new rect which is offset by the specified amount.
 
IntRect Offset (int x, int y)
 Returns a new rect which is offset by the specified amount.
 
IntRect Rotate (int r)
 Returns a new rect rotated around the origin 90*r degrees.
 
override string ToString ()
 

Static Public Member Functions

static IntRect Intersection (IntRect a, IntRect b)
 Returns the intersection rect between the two rects.
 
static bool Intersects (IntRect a, IntRect b)
 Returns if the two rectangles intersect each other.
 
static bool operator!= (IntRect a, IntRect b)
 
static bool operator== (IntRect a, IntRect b)
 
static IntRect Union (IntRect a, IntRect b)
 Returns a new rect which contains both input rects.
 

Public Attributes

int xmax
 
int xmin
 
int ymax
 
int ymin
 

Properties

int Height [get]
 
int Width [get]
 

Static Private Attributes

static readonly int[] Rotations
 Matrices for rotation.
 

Constructor & Destructor Documentation

IntRect ( int  xmin,
int  ymin,
int  xmax,
int  ymax 
)

Member Function Documentation

bool Contains ( int  x,
int  y 
)
void DebugDraw ( Matrix4x4  matrix,
Color  col 
)

Draws some debug lines representing the rect.

override bool Equals ( System.Object  _b)
IntRect Expand ( int  range)

Returns a new rect which is expanded by range in all directions.

Parameters
rangeHow far to expand. Negative values are permitted.
IntRect ExpandToContain ( int  x,
int  y 
)

Returns a new IntRect which is expanded to contain the point.

override int GetHashCode ( )
static IntRect Intersection ( IntRect  a,
IntRect  b 
)
static

Returns the intersection rect between the two rects.

The intersection rect is the area which is inside both rects. If the rects do not have an intersection, an invalid rect is returned.

See Also
IsValid
static bool Intersects ( IntRect  a,
IntRect  b 
)
static

Returns if the two rectangles intersect each other.

bool IsValid ( )

Returns if this rectangle is valid.

An invalid rect could have e.g xmin > xmax. Rectamgles with a zero area area invalid.

IntRect Offset ( Int2  offset)

Returns a new rect which is offset by the specified amount.

IntRect Offset ( int  x,
int  y 
)

Returns a new rect which is offset by the specified amount.

static bool operator!= ( IntRect  a,
IntRect  b 
)
static
static bool operator== ( IntRect  a,
IntRect  b 
)
static
IntRect Rotate ( int  r)

Returns a new rect rotated around the origin 90*r degrees.

Ensures that a valid rect is returned.

override string ToString ( )
static IntRect Union ( IntRect  a,
IntRect  b 
)
static

Returns a new rect which contains both input rects.

This rectangle may contain areas outside both input rects as well in some cases.

Member Data Documentation

readonly int [] Rotations
staticprivate
Initial value:
= {
1, 0,
0, 1,
0, 1,
-1, 0,
-1, 0,
0,-1,
0,-1,
1, 0
}

Matrices for rotation.

Each group of 4 elements is a 2x2 matrix. The XZ position is multiplied by this. So

//A rotation by 90 degrees clockwise, second matrix in the array
(5,2) * ((0, 1), (-1, 0)) = (2,-5)
int xmax
int xmin
int ymax
int ymin

Property Documentation

int Height
get
int Width
get

The documentation for this struct was generated from the following file: