mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
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:
@@ -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)
|
||||
|
||||
@@ -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?
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
+1
-1
@@ -170,7 +170,7 @@ int Style::update(Context& ctx) {
|
||||
else {int tb = int(top + bottom); top = (tb - height) / 2; bottom = (tb + height) / 2; }
|
||||
// adjust rotation point
|
||||
if (angle != 0 && (automatic_side & (AUTO_LEFT | AUTO_TOP))) {
|
||||
double s = sin(angle * M_PI / 180), c = cos(angle * M_PI / 180);
|
||||
double s = sin(deg_to_rad(angle)), c = cos(deg_to_rad(angle));
|
||||
if (automatic_side & AUTO_LEFT) { // attach right corner instead of left
|
||||
left = left + width * (1 - c);
|
||||
top = top + width * s;
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ class Style : public IntrusivePtrVirtualBase {
|
||||
Scriptable<double> left, top; ///< Position of this field
|
||||
Scriptable<double> width, height; ///< Position of this field
|
||||
Scriptable<double> right, bottom; ///< Position of this field
|
||||
Scriptable<int> angle; ///< Rotation of the box
|
||||
Scriptable<Degrees> angle; ///< Rotation of the box
|
||||
Scriptable<bool> visible; ///< Is this field visible?
|
||||
CachedScriptableMask mask; ///< Mask image
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <util/reflect.hpp>
|
||||
#include <util/defaultable.hpp>
|
||||
#include <util/angle.hpp>
|
||||
|
||||
class Game;
|
||||
class StyleSheet;
|
||||
@@ -98,7 +99,7 @@ class StyleSheetSettings : public IntrusivePtrBase<StyleSheetSettings> {
|
||||
|
||||
// Rendering/display settings
|
||||
Defaultable<double> card_zoom;
|
||||
Defaultable<int> card_angle;
|
||||
Defaultable<Degrees> card_angle;
|
||||
Defaultable<bool> card_anti_alias;
|
||||
Defaultable<bool> card_borders;
|
||||
Defaultable<bool> card_draw_editing;
|
||||
|
||||
+1
-1
@@ -255,7 +255,7 @@ String SymbolSymmetry::expectedName() const {
|
||||
Bounds SymbolSymmetry::calculateBounds(const Vector2D& origin, const Matrix2D& m, bool is_identity) {
|
||||
Bounds bounds;
|
||||
// See SymbolViewer::draw
|
||||
double b = 2 * handle.angle();
|
||||
Radians b = 2 * handle.angle();
|
||||
int copies = kind == SYMMETRY_REFLECTION ? this->copies & ~1 : this->copies;
|
||||
FOR_EACH_CONST(p, parts) {
|
||||
for (int i = 0 ; i < copies ; ++i) {
|
||||
|
||||
Reference in New Issue
Block a user