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

Holds a coordinate in integers. More...

+ Collaboration diagram for Int3:

Public Member Functions

 Int3 (Vector3 position)
 
 Int3 (int _x, int _y, int _z)
 
override bool Equals (System.Object o)
 
override int GetHashCode ()
 
Int3 NormalizeTo (int newMagn)
 
override string ToString ()
 Returns a nicely formatted string representing the vector.
 

Static Public Member Functions

static int Dot (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, Vector3 rhs)
 
static Int3 operator+ (Int3 lhs, Int3 rhs)
 
static Int3 operator- (Int3 lhs, Int3 rhs)
 
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 safeMagnitude [get]
 To avoid number overflows.
 
float safeSqrMagnitude [get]
 To avoid number overflows.
 
float sqrMagnitude [get]
 The squared magnitude of the vector.
 
int this[int i] [get]
 
int unsafeSqrMagnitude [get]
 
float worldMagnitude [get]
 The magnitude in world units.
 
static Int3 zero [get]
 

Static Private Attributes

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

Detailed Description

Holds a coordinate in integers.

Member Data Documentation

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.

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;
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 safeMagnitude
get

To avoid number overflows.

Deprecated:
Int3.magnitude now uses the same implementation
float safeSqrMagnitude
get

To avoid number overflows.

The returned value is the squared magnitude of the world distance (i.e divided by Precision)

Deprecated:
.sqrMagnitude is now per default safe (Int3.unsafeSqrMagnitude can be used for unsafe operations)
int unsafeSqrMagnitude
get
Warning
Can cause number overflows if the magnitude is too large

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