From 1674443ab2cbb068bc0e338988445b60fd1a3b80 Mon Sep 17 00:00:00 2001 From: Jonathan Westhues Date: Thu, 12 Jun 2008 21:32:55 -0800 Subject: [PATCH] Fix stupidity in the rotate ops; first of all it was saving the axis of rotation numerically, so that the associative thing breaks, and then it also wasn't saving the point on the axis in the file, so that snapped back to (0, 0, 0) on reload. Now it goes off the hEntity for a point on the axis and a vector in its direction. [git-p4: depot-paths = "//depot/solvespace/": change = 1790] --- group.cpp | 26 +++++++++++++------------- sketch.h | 1 - 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/group.cpp b/group.cpp index 8157268..78fd1d4 100644 --- a/group.cpp +++ b/group.cpp @@ -101,21 +101,18 @@ void Group::MenuGroup(int id) { break; case GraphicsWindow::MNU_GROUP_ROT: { - Vector n; if(gs.points == 1 && gs.n == 1 && SS.GW.LockedInWorkplane()) { - g.predef.p = (SS.GetEntity(gs.point[0]))->PointGetNum(); + g.predef.origin = gs.point[0]; Entity *w = SS.GetEntity(SS.GW.ActiveWorkplane()); - n = (w->Normal()->NormalN()); + g.predef.entityB = w->Normal()->h; g.activeWorkplane = w->h; } else if(gs.points == 1 && gs.vectors == 1 && gs.n == 2) { - g.predef.p = (SS.GetEntity(gs.point[0]))->PointGetNum(); - n = SS.GetEntity(gs.vector[0])->VectorGetNum(); + g.predef.origin = gs.point[0]; + g.predef.entityB = gs.vector[0]; } else { Error("Bad selection for new rotation."); return; } - n = n.WithMagnitude(1); - g.predef.q = Quaternion::From(0, n.x, n.y, n.z); g.type = ROTATE; g.opA = SS.GW.activeGroup; g.exprA = Expr::From(3)->DeepCopyKeep(); @@ -395,13 +392,16 @@ void Group::GenerateEquations(IdList *l) { // The axis and center of rotation are specified numerically #define EC(x) (Expr::From(x)) #define EP(x) (Expr::From(h.param(x))) - AddEq(l, (EC(predef.p.x))->Minus(EP(0)), 0); - AddEq(l, (EC(predef.p.y))->Minus(EP(1)), 1); - AddEq(l, (EC(predef.p.z))->Minus(EP(2)), 2); + ExprVector orig = SS.GetEntity(predef.origin)->PointGetExprs(); + AddEq(l, (orig.x)->Minus(EP(0)), 0); + AddEq(l, (orig.y)->Minus(EP(1)), 1); + AddEq(l, (orig.z)->Minus(EP(2)), 2); // param 3 is the angle, which is free - AddEq(l, (EC(predef.q.vx))->Minus(EP(4)), 3); - AddEq(l, (EC(predef.q.vy))->Minus(EP(5)), 4); - AddEq(l, (EC(predef.q.vz))->Minus(EP(6)), 5); + Vector axis = SS.GetEntity(predef.entityB)->VectorGetNum(); + axis = axis.WithMagnitude(1); + AddEq(l, (EC(axis.x))->Minus(EP(4)), 3); + AddEq(l, (EC(axis.y))->Minus(EP(5)), 4); + AddEq(l, (EC(axis.z))->Minus(EP(6)), 5); } else if(type == EXTRUDE) { if(predef.entityB.v != Entity::FREE_IN_3D.v) { // The extrusion path is locked along a line, normal to the diff --git a/sketch.h b/sketch.h index d4bf6c4..d427b62 100644 --- a/sketch.h +++ b/sketch.h @@ -112,7 +112,6 @@ public: struct { Quaternion q; - Vector p; hEntity origin; hEntity entityB; hEntity entityC;