Be explicit about type of angles: either Radians or Degrees.

Angles are always doubles.
Internally use radians as much as possible.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1605 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2011-01-09 14:49:59 +00:00
parent a59248ae95
commit 53bbcfe9a9
38 changed files with 248 additions and 195 deletions
+3 -3
View File
@@ -129,8 +129,8 @@ void SymbolPartRotateAction::perform(bool to_undo) {
angle = -angle;
}
void SymbolPartRotateAction::rotateTo(double newAngle) {
double oldAngle = angle;
void SymbolPartRotateAction::rotateTo(Radians newAngle) {
Radians oldAngle = angle;
angle = newAngle;
// constrain?
if (constrain) {
@@ -141,7 +141,7 @@ void SymbolPartRotateAction::rotateTo(double newAngle) {
if (oldAngle != angle) rotateBy(angle - oldAngle);
}
void SymbolPartRotateAction::rotateBy(double deltaAngle) {
void SymbolPartRotateAction::rotateBy(Radians deltaAngle) {
// Rotation 'matrix'
transform(
Matrix2D(cos(deltaAngle), -sin(deltaAngle)
+3 -3
View File
@@ -85,13 +85,13 @@ class SymbolPartRotateAction : public SymbolPartMatrixAction {
virtual void perform(bool to_undo);
/// Update this action to rotate to a different angle
void rotateTo(double newAngle);
void rotateTo(Radians newAngle);
/// Update this action to rotate by a deltaAngle
void rotateBy(double deltaAngle);
void rotateBy(Radians deltaAngle);
private:
double angle; ///< How much to rotate?
Radians angle; ///< How much to rotate?
public:
bool constrain; ///< Constrain movement?
};
+2 -2
View File
@@ -459,8 +459,8 @@ void SymmetryMoveAction::move(const Vector2D& deltaDelta) {
symmetry.handle = snap_vector(symmetry.center + original + delta, snap) - symmetry.center;
if (constrain) {
// constrain to multiples of 2pi/24 i.e. 24 stops
double angle = atan2(symmetry.handle.y, symmetry.handle.x);
double mult = (2 * M_PI) / 24;
Radians angle = atan2(symmetry.handle.y, symmetry.handle.x);
Radians mult = (2 * M_PI) / 24;
angle = floor(angle / mult + 0.5) * mult;
symmetry.handle = Vector2D(cos(angle), sin(angle)) * symmetry.handle.length();
}