Dungeon Architect  17.0.0
DungeonArchitect.Utils.MathUtils Class Reference

Various math utility functions More...

Static Public Member Functions

static Rectangle Copy (Rectangle other)
 Copies the rectangle object More...
 
static Vector3 Divide (Vector3 a, Vector3 b)
 Divides two vector3 objects More...
 
static Vector3 ToVector3 (IntVector v)
 Converts an IntVector to a Vector3 More...
 
static Vector3 ToVector3 (Vector3Int v)
 
static Vector4 ToVector4 (Vector3 v, float w)
 
static IntVector WorldToGrid (Vector3 WorldCoord, Vector3 GridCellSize)
 Converts the world coordinates to grid coordinates More...
 
static Vector3 GridToWorld (Vector3 GridCellSize, IntVector v)
 Converts the grid coordinate to world coordinate More...
 
static Vector3 GridToWorld (Vector3 GridCellSize, Vector3 v)
 Converts the grid coordinate to world coordinate More...
 
static IntVector ToIntVector (Vector3 v)
 Converts an IntVector to a Vector3, with the XYZ components floored More...
 
static Vector3Int FloorToVector3Int (Vector3 v)
 
static Vector3Int RoundToVector3Int (Vector3 v)
 
static Vector3 V3FloorToInt (Vector3 v)
 
static Vector3 V3RoundToInt (Vector3 v)
 
static Vector3 ComponentMin (Vector3 a, Vector3 b)
 
static Vector3 ComponentMax (Vector3 a, Vector3 b)
 
static IntVector RoundToIntVector (Vector3 v)
 Rounds to an IntVector, with the XYZ components rounded to the nearest int More...
 
static Vector3 SnapToGrid (Vector3 position, Vector3 gridCellSize)
 Snaps the position to the nearest grid cell location More...
 
static Vector3 SnapToGrid (Vector3 position, Vector3 gridCellSize, bool useRounding)
 Snaps the position to the nearest grid cell location More...
 
static bool Intersects (Rect a, Rect b)
 Checks if the two rectangles intersect More...
 
static Vector2 ClosestPointOnRect (Rect rect, Vector2 p)
 
static Rect ExpandRect (Rect bounds, float amount)
 
static Vector2 ClampToRect (Vector2 position, Rect bounds)
 
static void FlipYZ (ref Bounds bounds)
 Flips the coordinates for 2D mode More...
 
static Vector3 FlipYZ (Vector3 bounds)
 Flips the coordinates for 2D mode More...
 
static IntVector FlipYZ (IntVector bounds)
 Flips the coordinates for 2D mode More...
 
static void Abs (ref Vector3 v)
 
static void Swap< T > (ref T a, ref T b)
 
static void Shuffle< T > (List< T > Array, System.Random Random)
 
static void Shuffle< T > (T[] Array, System.Random Random)
 
static int[] GetShuffledIndices (int Count, System.Random Random)
 
static Bounds TransformBounds (Matrix4x4 transform, Bounds bounds)
 
static Bounds TransformBoundsX (Matrix4x4 transform, Bounds localBounds)
 
static bool V3Equals (Vector3 a, Vector3 b)
 
static bool V3Equals (Vector3 a, Vector3 b, float threshold)
 
static byte ToByte (float value01)
 
static Vector3 ReflectVector (Vector3 direction, Vector3 normal)
 

Static Public Attributes

static readonly int INVALID_LOCATION = -1000000
 Flag to indicate an invalid location More...
 

Detailed Description

Various math utility functions

Definition at line 11 of file MathUtils.cs.

Member Function Documentation

◆ Copy()

static Rectangle DungeonArchitect.Utils.MathUtils.Copy ( Rectangle  other)
static

Copies the rectangle object

Parameters
otherThe object to copy
Returns
The copied object

Definition at line 18 of file MathUtils.cs.

◆ Divide()

static Vector3 DungeonArchitect.Utils.MathUtils.Divide ( Vector3  a,
Vector3  b 
)
static

Divides two vector3 objects

Parameters
a
b
Returns
The divided vector

Definition at line 29 of file MathUtils.cs.

◆ FlipYZ() [1/3]

static IntVector DungeonArchitect.Utils.MathUtils.FlipYZ ( IntVector  bounds)
static

Flips the coordinates for 2D mode

Returns
The Y.
Parameters
boundsBounds.

Definition at line 263 of file MathUtils.cs.

◆ FlipYZ() [2/3]

static void DungeonArchitect.Utils.MathUtils.FlipYZ ( ref Bounds  bounds)
static

Flips the coordinates for 2D mode

Parameters
boundsBounds.

Definition at line 239 of file MathUtils.cs.

◆ FlipYZ() [3/3]

static Vector3 DungeonArchitect.Utils.MathUtils.FlipYZ ( Vector3  bounds)
static

Flips the coordinates for 2D mode

Returns
The Y.
Parameters
boundsBounds.

Definition at line 251 of file MathUtils.cs.

◆ GridToWorld() [1/2]

static Vector3 DungeonArchitect.Utils.MathUtils.GridToWorld ( Vector3  GridCellSize,
IntVector  v 
)
static

Converts the grid coordinate to world coordinate

Parameters
GridCellSizeThe grid cell size
vThe input grid coordinate
Returns
The resulting world coordinate

Definition at line 70 of file MathUtils.cs.

◆ GridToWorld() [2/2]

static Vector3 DungeonArchitect.Utils.MathUtils.GridToWorld ( Vector3  GridCellSize,
Vector3  v 
)
static

Converts the grid coordinate to world coordinate

Parameters
GridCellSizeThe grid cell size
vThe input grid coordinate
Returns
The resulting world coordinate

Definition at line 81 of file MathUtils.cs.

◆ Intersects()

static bool DungeonArchitect.Utils.MathUtils.Intersects ( Rect  a,
Rect  b 
)
static

Checks if the two rectangles intersect

Parameters
outerThe outer rect
innerThe inner rect
Returns
True if they intersect, false otherwise

Definition at line 203 of file MathUtils.cs.

◆ RoundToIntVector()

static IntVector DungeonArchitect.Utils.MathUtils.RoundToIntVector ( Vector3  v)
static

Rounds to an IntVector, with the XYZ components rounded to the nearest int

Parameters
vThe input Vector3 to convert
Returns
The rounded IntVector

Definition at line 154 of file MathUtils.cs.

◆ SnapToGrid() [1/2]

static Vector3 DungeonArchitect.Utils.MathUtils.SnapToGrid ( Vector3  position,
Vector3  gridCellSize 
)
static

Snaps the position to the nearest grid cell location

Parameters
positionThe position to snap
gridCellSizeThe size of the grid cell
Returns
The snapped position

Definition at line 168 of file MathUtils.cs.

◆ SnapToGrid() [2/2]

static Vector3 DungeonArchitect.Utils.MathUtils.SnapToGrid ( Vector3  position,
Vector3  gridCellSize,
bool  useRounding 
)
static

Snaps the position to the nearest grid cell location

Parameters
positionThe position to snap
gridCellSizeThe size of the grid cell
useRoundingFlag to indicate if rounding is to be used. Uses floor if false
Returns
The snapped position

Definition at line 179 of file MathUtils.cs.

◆ ToIntVector()

static IntVector DungeonArchitect.Utils.MathUtils.ToIntVector ( Vector3  v)
static

Converts an IntVector to a Vector3, with the XYZ components floored

Parameters
vThe input Vector3 to convert
Returns
The corresponding IntVector, floored in each component

Definition at line 91 of file MathUtils.cs.

◆ ToVector3()

static Vector3 DungeonArchitect.Utils.MathUtils.ToVector3 ( IntVector  v)
static

Converts an IntVector to a Vector3

Parameters
vthe input int vector
Returns

Definition at line 42 of file MathUtils.cs.

◆ WorldToGrid()

static IntVector DungeonArchitect.Utils.MathUtils.WorldToGrid ( Vector3  WorldCoord,
Vector3  GridCellSize 
)
static

Converts the world coordinates to grid coordinates

Parameters
WorldCoordThe world cooridnate
GridCellSizeThe grid cell size
Returns
The resulting grid coordinate

Definition at line 60 of file MathUtils.cs.

Member Data Documentation

◆ INVALID_LOCATION

readonly int DungeonArchitect.Utils.MathUtils.INVALID_LOCATION = -1000000
static

Flag to indicate an invalid location

Definition at line 280 of file MathUtils.cs.


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