1
0
mirror of https://github.com/aseprite/aseprite.git synced 2025-02-19 06:40:42 +00:00

Fix rotation in straight angle (fix )

This commit is contained in:
David Capello 2015-08-14 10:57:40 -03:00
parent a5536359bb
commit 56de0fe989
2 changed files with 13 additions and 7 deletions

@ -396,7 +396,7 @@ void PixelsMovement::moveImage(const gfx::Point& pos, MoveModifier moveModifier)
if ((moveModifier & AngleSnapMovement) == AngleSnapMovement) {
// TODO make this configurable
static const double keyAngles[] = {
0.0, 26.565, 45.0, 63.435, 90.0, 116.565, 135.0, 153.435, -180.0,
0.0, 26.565, 45.0, 63.435, 90.0, 116.565, 135.0, 153.435, 180.0,
180.0, -153.435, -135.0, -116, -90.0, -63.435, -45.0, -26.565
};

@ -11,6 +11,7 @@
#include "gfx/transformation.h"
#include "gfx/point.h"
#include "gfx/size.h"
#include "fixmath/fixmath.h"
#include <cmath>
@ -72,13 +73,18 @@ PointT<double> Transformation::rotatePoint(
const PointT<double>& pivot,
double angle)
{
double cos = std::cos(-angle);
double sin = std::sin(-angle);
double dx = (point.x-pivot.x);
double dy = (point.y-pivot.y);
using namespace fixmath;
fixed fixangle = ftofix(-angle);
fixangle = fixmul(fixangle, radtofix_r);
fixed cos = fixcos(fixangle);
fixed sin = fixsin(fixangle);
fixed dx = fixsub(ftofix(point.x), ftofix(pivot.x));
fixed dy = fixsub(ftofix(point.y), ftofix(pivot.y));
return PointT<double>(
pivot.x + dx*cos - dy*sin,
pivot.y + dy*cos + dx*sin);
fixtof(fixadd(ftofix(pivot.x), fixsub(fixmul(dx, cos), fixmul(dy, sin)))),
fixtof(fixadd(ftofix(pivot.y), fixadd(fixmul(dy, cos), fixmul(dx, sin)))));
}
Rect Transformation::transformedBounds() const