From aa52be8801613ccb021290e29d40c2a37d007fc6 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 11 Sep 2012 19:18:43 -0400 Subject: [PATCH] HexTile cleanup --- src/common/HexTile.cc | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/common/HexTile.cc b/src/common/HexTile.cc index 4ed8834..e9774bb 100644 --- a/src/common/HexTile.cc +++ b/src/common/HexTile.cc @@ -7,16 +7,6 @@ #define COS_120 (-0.5f) #define SIN_120 SIN_60 -/* points of a horizontal hexagon 2.0 units high */ -static const float hex_points[][2] = { - {HEX_WIDTH_TO_HEIGHT, 0.0}, - {HEX_WIDTH_TO_HEIGHT / 2.0, 1.0}, - {-HEX_WIDTH_TO_HEIGHT / 2.0, 1.0}, - {-HEX_WIDTH_TO_HEIGHT, 0.0}, - {-HEX_WIDTH_TO_HEIGHT / 2.0, -1.0}, - {HEX_WIDTH_TO_HEIGHT / 2.0, -1.0} -}; - HexTile::HexTile(float x, float y, float size) { m_x = x; @@ -26,8 +16,8 @@ HexTile::HexTile(float x, float y, float size) bool HexTile::point_within(float x, float y) { - x = 2.0 * (x - m_x) / m_size; - y = 2.0 * (y - m_y) / m_size; + x = 2.0 * (x - m_x); + y = 2.0 * (y - m_y); /* a point (x, y) at angle q rotates to (x', y') by f deg around the origin * according to: * x' = r*cos(q+f) = r*cos(q)*cos(f)-r*sin(q)*sin(f) @@ -40,13 +30,13 @@ bool HexTile::point_within(float x, float y) * x' = x * 0.5 - y * 0.8660254 * y' = y * 0.5 + x * 0.8660254 */ - if (fabsf(y) > 1.0) + if (fabsf(y) > m_size) return false; float y_60 = y * COS_60 + x * SIN_60; - if (fabsf(y_60) > 1.0) + if (fabsf(y_60) > m_size) return false; float y_120 = y * COS_120 + x * SIN_120; - if (fabsf(y_120) > 1.0) + if (fabsf(y_120) > m_size) return false; return true; }