Move rotation
struct definition into pixel_position.hpp
This commit is contained in:
parent
ecfccdd36c
commit
b7fdeeeb02
7 changed files with 38 additions and 51 deletions
|
@ -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);
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
// mapnik
|
||||
#include <mapnik/geometry/box2d.hpp>
|
||||
#include <mapnik/pixel_position.hpp>
|
||||
#include <mapnik/text/rotation.hpp>
|
||||
#include <mapnik/marker_cache.hpp>
|
||||
#include <mapnik/text/glyph_info.hpp>
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include <mapnik/pixel_position.hpp>
|
||||
#include <mapnik/text/text_layout.hpp>
|
||||
#include <mapnik/text/glyph_positions.hpp>
|
||||
#include <mapnik/text/rotation.hpp>
|
||||
#include <mapnik/util/noncopyable.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
#ifndef MAPNIK_ROTATION_HPP
|
||||
#define MAPNIK_ROTATION_HPP
|
||||
|
||||
#include <cmath>
|
||||
|
||||
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
|
|
@ -33,7 +33,6 @@
|
|||
#include <mapnik/text/itemizer.hpp>
|
||||
#include <mapnik/font_engine_freetype.hpp>
|
||||
#include <mapnik/text/evaluated_format_properties_ptr.hpp>
|
||||
#include <mapnik/text/rotation.hpp>
|
||||
|
||||
// stl
|
||||
#include <vector>
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
// mapnik
|
||||
#include <mapnik/text/glyph_positions.hpp>
|
||||
#include <mapnik/pixel_position.hpp>
|
||||
#include <mapnik/text/rotation.hpp>
|
||||
#include <mapnik/text/glyph_info.hpp>
|
||||
|
||||
// stl
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue