blob: 62abbde14ab451c77ff88184350dba9a28384b68 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#pragma once
#include "point.hpp"
#include "src/tile-constants.hpp"
#include <mg/Functions.h>
namespace floormat {
constexpr uint32_t point::distance(point a, point b)
{
Vector2i dist;
dist += (a.coord() - b.coord())*iTILE_SIZE2;
dist += Vector2i(a.offset()) - Vector2i(b.offset());
return (uint32_t)Math::ceil(Math::sqrt(Vector2(dist).dot()));
}
constexpr uint32_t point::distance_l2(point a, point b)
{
Vector2i dist;
dist += (a.coord() - b.coord())*iTILE_SIZE2;
dist += Vector2i(a.offset()) - Vector2i(b.offset());
return (uint32_t)Math::abs(dist).sum();
}
} // namespace floormat
|