aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Pos.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Minecraft.World/Pos.cpp')
-rw-r--r--Minecraft.World/Pos.cpp67
1 files changed, 36 insertions, 31 deletions
diff --git a/Minecraft.World/Pos.cpp b/Minecraft.World/Pos.cpp
index 3fad76e8..e673ecc3 100644
--- a/Minecraft.World/Pos.cpp
+++ b/Minecraft.World/Pos.cpp
@@ -18,9 +18,9 @@ Pos::Pos(int x, int y, int z)
Pos::Pos(Pos *position)
{
- this->x = position->x;
- this->y = position->y;
- this->z = position->z;
+ x = position->x;
+ y = position->y;
+ z = position->z;
}
//@Override
@@ -71,9 +71,9 @@ void Pos::set(int x, int y, int z)
void Pos::set(Pos *pos)
{
- this->x = pos->x;
- this->y = pos->y;
- this->z = pos->z;
+ x = pos->x;
+ y = pos->y;
+ z = pos->z;
}
Pos *Pos::above()
@@ -145,93 +145,93 @@ void Pos::move(int x, int y, int z)
void Pos::move(Pos pos)
{
- this->x += pos.x;
- this->y += pos.y;
- this->z += pos.z;
+ x += pos.x;
+ y += pos.y;
+ z += pos.z;
}
void Pos::moveX(int steps)
{
- this->x += steps;
+ x += steps;
}
void Pos::moveY(int steps)
{
- this->y += steps;
+ y += steps;
}
void Pos::moveZ(int steps)
{
- this->z += steps;
+ z += steps;
}
void Pos::moveUp(int steps)
{
- this->y += steps;
+ y += steps;
}
void Pos::moveUp()
{
- this->y++;
+ y++;
}
void Pos::moveDown(int steps)
{
- this->y -= steps;
+ y -= steps;
}
void Pos::moveDown()
{
- this->y--;
+ y--;
}
void Pos::moveEast(int steps)
{
- this->x += steps;
+ x += steps;
}
void Pos::moveEast()
{
- this->x++;
+ x++;
}
void Pos::moveWest(int steps)
{
- this->x -= steps;
+ x -= steps;
}
void Pos::moveWest()
{
- this->x--;
+ x--;
}
void Pos::moveNorth(int steps)
{
- this->z -= steps;
+ z -= steps;
}
void Pos::moveNorth()
{
- this->z--;
+ z--;
}
void Pos::moveSouth(int steps)
{
- this->z += steps;
+ z += steps;
}
void Pos::moveSouth()
{
- this->z++;
+ z++;
}
double Pos::dist(int x, int y, int z)
{
- int dx = this->x - x;
- int dy = this->y - y;
- int dz = this->z - z;
+ double dx = this->x - x;
+ double dy = this->y - y;
+ double dz = this->z - z;
- return sqrt( (double) dx * dx + dy * dy + dz * dz);
+ return sqrt( dx * dx + dy * dy + dz * dz);
}
double Pos::dist(Pos *pos)
@@ -241,8 +241,13 @@ double Pos::dist(Pos *pos)
float Pos::distSqr(int x, int y, int z)
{
- int dx = this->x - x;
- int dy = this->y - y;
- int dz = this->z - z;
+ float dx = this->x - x;
+ float dy = this->y - y;
+ float dz = this->z - z;
return dx * dx + dy * dy + dz * dz;
+}
+
+float Pos::distSqr(Pos *pos)
+{
+ return distSqr(pos->x, pos->y, pos->z);
} \ No newline at end of file