diff --git a/include/mapnik/pixel_position.hpp b/include/mapnik/pixel_position.hpp index 991719c9c..cbfb3d145 100644 --- a/include/mapnik/pixel_position.hpp +++ b/include/mapnik/pixel_position.hpp @@ -27,7 +27,38 @@ namespace mapnik { -struct rotation; +struct rotation +{ + rotation() + : sin(0) + , cos(1.) + {} + rotation(double sin_, double cos_) + : sin(sin_) + , cos(cos_) + {} + rotation(double angle) + : sin(std::sin(angle)) + , cos(std::cos(angle)) + {} + void reset() + { + sin = 0.; + cos = 1.; + } + void init(double angle) + { + sin = std::sin(angle); + cos = std::cos(angle); + } + double sin; + double cos; + rotation operator~() const { return rotation(sin, -cos); } + rotation operator!() const { return rotation(-sin, cos); } + + double angle() const { return std::atan2(sin, cos); } +}; + struct pixel_position { double x; @@ -59,11 +90,17 @@ struct pixel_position } pixel_position rotate(rotation const& rot) const; + pixel_position operator~() const { return pixel_position(x, -y); } double length() { return std::sqrt(x * x + y * y); } }; +inline pixel_position pixel_position::rotate(rotation const& rot) const +{ + return pixel_position(x * rot.cos - y * rot.sin, x * rot.sin + y * rot.cos); +} + inline pixel_position operator*(double factor, pixel_position const& pos) { return pixel_position(factor * pos.x, factor * pos.y); diff --git a/include/mapnik/text/glyph_positions.hpp b/include/mapnik/text/glyph_positions.hpp index 6227391f2..80ffefb26 100644 --- a/include/mapnik/text/glyph_positions.hpp +++ b/include/mapnik/text/glyph_positions.hpp @@ -26,7 +26,6 @@ // mapnik #include #include -#include #include #include diff --git a/include/mapnik/text/placement_finder.hpp b/include/mapnik/text/placement_finder.hpp index 5c49e9012..10040b48d 100644 --- a/include/mapnik/text/placement_finder.hpp +++ b/include/mapnik/text/placement_finder.hpp @@ -27,7 +27,6 @@ #include #include #include -#include #include namespace mapnik { diff --git a/include/mapnik/text/rotation.hpp b/include/mapnik/text/rotation.hpp deleted file mode 100644 index 89cac2d45..000000000 --- a/include/mapnik/text/rotation.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef MAPNIK_ROTATION_HPP -#define MAPNIK_ROTATION_HPP - -#include - -namespace mapnik { - -struct rotation -{ - rotation() - : sin(0) - , cos(1.) - {} - rotation(double sin_, double cos_) - : sin(sin_) - , cos(cos_) - {} - rotation(double angle) - : sin(std::sin(angle)) - , cos(std::cos(angle)) - {} - void reset() - { - sin = 0.; - cos = 1.; - } - void init(double angle) - { - sin = std::sin(angle); - cos = std::cos(angle); - } - double sin; - double cos; - rotation operator~() const { return rotation(sin, -cos); } - rotation operator!() const { return rotation(-sin, cos); } - - double angle() const { return std::atan2(sin, cos); } -}; -} // namespace mapnik - -#endif // ROTATION_HPP diff --git a/include/mapnik/text/text_layout.hpp b/include/mapnik/text/text_layout.hpp index 06e01d447..b366e5454 100644 --- a/include/mapnik/text/text_layout.hpp +++ b/include/mapnik/text/text_layout.hpp @@ -33,7 +33,6 @@ #include #include #include -#include // stl #include diff --git a/src/text/glyph_positions.cpp b/src/text/glyph_positions.cpp index 8b1fbca39..b3fa96a55 100644 --- a/src/text/glyph_positions.cpp +++ b/src/text/glyph_positions.cpp @@ -22,7 +22,6 @@ // mapnik #include #include -#include #include // stl diff --git a/src/text/text_layout.cpp b/src/text/text_layout.cpp index 3be71243a..87c00a8ea 100644 --- a/src/text/text_layout.cpp +++ b/src/text/text_layout.cpp @@ -87,11 +87,6 @@ pixel_position evaluate_displacement(double dx, double dy, directions_e dir) } } -pixel_position pixel_position::rotate(rotation const& rot) const -{ - return pixel_position(x * rot.cos - y * rot.sin, x * rot.sin + y * rot.cos); -} - text_layout::text_layout(face_manager_freetype& font_manager, feature_impl const& feature, attributes const& attrs,