move text-specific inverted y axis logic from vertex_cache to placement_finder

This commit is contained in:
Jiri Drbalek 2014-10-31 18:38:59 +00:00
parent 60ea198aa3
commit cb46131bc5
2 changed files with 7 additions and 7 deletions

View file

@ -328,7 +328,9 @@ double placement_finder::normalize_angle(double angle)
{ {
angle += 2.0 * M_PI; angle += 2.0 * M_PI;
} }
return angle; // y axis is inverted.
// See note about coordinate systems in placement_finder::find_point_placement().
return -angle;
} }
double placement_finder::get_spacing(double path_length, double layout_width) const double placement_finder::get_spacing(double path_length, double layout_width) const

View file

@ -45,14 +45,12 @@ vertex_cache::vertex_cache(vertex_cache && rhs)
double vertex_cache::current_segment_angle() double vertex_cache::current_segment_angle()
{ {
return std::atan2(-(current_segment_->pos.y - segment_starting_point_.y), return std::atan2(current_segment_->pos.y - segment_starting_point_.y,
current_segment_->pos.x - segment_starting_point_.x); current_segment_->pos.x - segment_starting_point_.x);
} }
double vertex_cache::angle(double width) double vertex_cache::angle(double width)
{ {
// IMPORTANT NOTE: See note about coordinate systems in placement_finder::find_point_placement()
// for imformation about why the y axis is inverted!
double tmp = width + position_in_segment_; double tmp = width + position_in_segment_;
if ((tmp <= current_segment_->length) && (tmp >= 0)) if ((tmp <= current_segment_->length) && (tmp >= 0))
{ {
@ -68,8 +66,8 @@ double vertex_cache::angle(double width)
if (move(width)) if (move(width))
{ {
pixel_position const& old_pos = s.get_state().position(); pixel_position const& old_pos = s.get_state().position();
return std::atan2(-(current_position_.y - old_pos.y), return std::atan2(current_position_.y - old_pos.y,
current_position_.x - old_pos.x); current_position_.x - old_pos.x);
} }
else else
{ {