Make rotations default to 360/n degrees (uniform about a circle)

if no constraints set the rotation.

[git-p4: depot-paths = "//depot/solvespace/": change = 1827]
This commit is contained in:
Jonathan Westhues 2008-07-08 22:13:49 -08:00
parent 4c42f329cd
commit dd23aa11a2
2 changed files with 23 additions and 2 deletions

View File

@ -378,7 +378,7 @@ void Group::Generate(IdList<Entity,hEntity> *entity,
AddParam(param, h.param(1), gc.y);
AddParam(param, h.param(2), gc.z);
// The rotation quaternion
AddParam(param, h.param(3), 15*PI/180);
AddParam(param, h.param(3), 30*PI/180);
AddParam(param, h.param(4), gn.x);
AddParam(param, h.param(5), gn.y);
AddParam(param, h.param(6), gn.z);

View File

@ -629,8 +629,29 @@ void TextWindow::EditControlDone(char *s) {
if(e) {
SS.UndoRemember();
double ev = e->Eval();
if((int)ev < 1) {
Error("Can't repeat fewer than 1 time.");
break;
}
Group *g = SS.GetGroup(edit.group);
g->valA = e->Eval();
g->valA = ev;
if(g->type == Group::ROTATE) {
int i, c = 0;
for(i = 0; i < SS.constraint.n; i++) {
if(SS.constraint.elem[i].group.v == g->h.v) c++;
}
// If the group does not contain any constraints, then
// set the numerical guess to space the copies uniformly
// over one rotation. Don't touch the guess if we're
// already constrained, because that would break
// convergence.
if(c == 0) {
SS.GetParam(g->h.param(3))->val = PI/(2*ev);
}
}
SS.MarkGroupDirty(g->h);
SS.later.generateAll = true;