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

Holds a coordinate in integers. More...

Detailed Description

Holds a coordinate in integers.

Public Member Functions

 Int3 (Vector3 position)
 
 Int3 (int _x, int _y, int _z)
 
override bool Equals (System.Object o)
 
bool Equals (Int3 other)
 
override int GetHashCode ()
 
Int3 Normal2D ()
 Normal in 2D space (XZ).
 
override string ToString ()
 Returns a nicely formatted string representing the vector.
 

Static Public Member Functions

static float Angle (Int3 lhs, Int3 rhs)
 Angle between the vectors in radians.
 
static int Dot (Int3 lhs, Int3 rhs)
 
static long DotLong (Int3 lhs, Int3 rhs)
 
static operator Int3 (Vector3 ob)
 
static implicit operator string (Int3 ob)
 
static operator Vector3 (Int3 ob)
 
static bool operator!= (Int3 lhs, Int3 rhs)
 
static Int3 operator* (Int3 lhs, int rhs)
 
static Int3 operator* (Int3 lhs, float rhs)
 
static Int3 operator* (Int3 lhs, double rhs)
 
static Int3 operator* (Int3 lhs, Vector3 rhs)
 
static Int3 operator+ (Int3 lhs, Int3 rhs)
 
static Int3 operator- (Int3 lhs, Int3 rhs)
 
static Int3 operator- (Int3 lhs)
 
static Int3 operator/ (Int3 lhs, float rhs)
 
static bool operator== (Int3 lhs, Int3 rhs)
 

Public Attributes

const float FloatPrecision = 1000F
 Precision as a float
 
const int Precision = 1000
 Precision for the integer coordinates.
 
const float PrecisionFactor = 0.001F
 1 divided by Precision
 
int x
 
int y
 
int z
 

Properties

int costMagnitude [get]
 Magnitude used for the cost between two nodes.
 
float magnitude [get]
 Returns the magnitude of the vector.
 
float sqrMagnitude [get]
 The squared magnitude of the vector.
 
long sqrMagnitudeLong [get]
 The squared magnitude of the vector.
 
int this[int i] [get, set]
 
float worldMagnitude [get]
 The magnitude in world units.
 
static Int3 zero [get]
 

Static Private Attributes

static Int3 _zero = new Int3(0, 0, 0)
 

Constructor & Destructor Documentation

Int3 ( Vector3  position)
Int3 ( int  _x,
int  _y,
int  _z 
)

Member Function Documentation

static float Angle ( Int3  lhs,
Int3  rhs 
)
static

Angle between the vectors in radians.

static int Dot ( Int3  lhs,
Int3  rhs 
)
static
static long DotLong ( Int3  lhs,
Int3  rhs 
)
static
override bool Equals ( System.Object  o)
bool Equals ( Int3  other)
override int GetHashCode ( )
Int3 Normal2D ( )

Normal in 2D space (XZ).

Equivalent to Cross(this, Int3(0,1,0) ) except that the Y coordinate is left unchanged with this operation.

static operator Int3 ( Vector3  ob)
explicitstatic
static implicit operator string ( Int3  ob)
static
static operator Vector3 ( Int3  ob)
explicitstatic
static bool operator!= ( Int3  lhs,
Int3  rhs 
)
static
static Int3 operator* ( Int3  lhs,
int  rhs 
)
static
static Int3 operator* ( Int3  lhs,
float  rhs 
)
static
static Int3 operator* ( Int3  lhs,
double  rhs 
)
static
static Int3 operator* ( Int3  lhs,
Vector3  rhs 
)
static
static Int3 operator+ ( Int3  lhs,
Int3  rhs 
)
static
static Int3 operator- ( Int3  lhs,
Int3  rhs 
)
static
static Int3 operator- ( Int3  lhs)
static
static Int3 operator/ ( Int3  lhs,
float  rhs 
)
static
static bool operator== ( Int3  lhs,
Int3  rhs 
)
static
override string ToString ( )

Returns a nicely formatted string representing the vector.

Member Data Documentation

Int3 _zero = new Int3(0, 0, 0)
staticprivate
const float FloatPrecision = 1000F

Precision as a float

const int Precision = 1000

Precision for the integer coordinates.

One world unit is divided into [value] pieces. A value of 1000 would mean millimeter precision, a value of 1 would mean meter precision (assuming 1 world unit = 1 meter). This value affects the maximum coordinates for nodes as well as how large the cost values are for moving between two nodes. A higher value means that you also have to set all penalty values to a higher value to compensate since the normal cost of moving will be higher.

const float PrecisionFactor = 0.001F

1 divided by Precision

int x
int y
int z

Property Documentation

int costMagnitude
get

Magnitude used for the cost between two nodes.

The default cost between two nodes can be calculated like this:

int cost = (node1.position-node2.position).costMagnitude;

This is simply the magnitude, rounded to the nearest integer

float magnitude
get

Returns the magnitude of the vector.

The magnitude is the 'length' of the vector from 0,0,0 to this point. Can be used for distance calculations:

Debug.Log ("Distance between 3,4,5 and 6,7,8 is: "+(new Int3(3,4,5) - new Int3(6,7,8)).magnitude);
float sqrMagnitude
get

The squared magnitude of the vector.

long sqrMagnitudeLong
get

The squared magnitude of the vector.

int this[int i]
getset
float worldMagnitude
get

The magnitude in world units.

Deprecated:
This property is deprecated. Use magnitude or cast to a Vector3
Int3 zero
staticget

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