18 template<Position TILE_SIZE>
39 return toPoint(pos / TILE_SIZE);
46 template<Position TILE_SIZE>
55 return { (xy[1] + xy[0]) * TILE_SIZE[0] / 2.0_f, (xy[1] - xy[0]) * TILE_SIZE[1] / 2.0_f };
64 return toPoint(
Position{ xy_div[0] - xy_div[1] + 0.5_f, xy_div[0] + xy_div[1] - 0.5_f });
72 constexpr Position TILE_SIZE_HALF = TILE_SIZE / 2.0_f;
73 unsigned sum = size[0] + size[1];
74 return TILE_SIZE_HALF * (
Float)sum;
79 template<Position TILE_SIZE>
88 Position pos = { TILE_SIZE[0] * xy[0] , TILE_SIZE[1] / 2 * xy[1] };
91 pos[0] += TILE_SIZE[0] / 2;
101 constexpr Position TILE_SIZE_HALF = TILE_SIZE / 2.0_f;
109 Float sp = std::fabs(p1[0] * TILE_SIZE_HALF[1])
110 + std::fabs(p1[1] * TILE_SIZE_HALF[0]);
114 if (p1[0] > 0 && p1[1] > 0)
115 return p +
Point{ 0, 1 };
116 else if (p1[0] < 0 && p1[1] > 0)
117 return p +
Point{ -1, 1 };
118 else if (p1[0] < 0 && p1[1] < 0)
119 return p +
Point{ -1, -1 };
120 else if (p1[0] > 0 && p1[1] < 0)
121 return p +
Point{ 0, -1 };
constexpr Point World2Map(const Position &pos)
世界坐标 -> 地图坐标
constexpr Position Map2World(const Point &xy)
地图坐标 -> 世界坐标
constexpr Position GetSizeBound(const Size &size)
返回包围盒大小,传入地图格子数量
constexpr Position Map2World(const Point &xy)
地图坐标 -> 世界坐标
constexpr Point World2Map(const Position &pos)
世界坐标 -> 地图坐标
constexpr Position Map2World(const PointU &xy)
constexpr Position GetSize()
constexpr Position Map2World(const Point &xy)
地图坐标 -> 世界坐标
constexpr Point World2Map(const Position &pos)
世界坐标 -> 地图坐标
constexpr auto Mul(const C &container)
求积product
constexpr Array< Position::value_type, N > toPosition(const Array< T, N > &a)
转换到Position,已知长度
constexpr Array< Point::value_type, N > toPoint(const Array< T, N > &a)
转换到Point,已知长度