make dragging more durable

This commit is contained in:
Val Erastov 2014-11-03 21:36:34 -08:00
parent 8d5019f108
commit e83d605a39
3 changed files with 21 additions and 4 deletions

View file

@ -64,6 +64,23 @@ TCAD.constraints.ConstantWrapper = function(constr, mask) {
}
};
TCAD.constraints.Weighted = function(constr, weight) {
this.params = constr.params;
this.error = function() {
return constr.error() * weight;
};
this.gradient = function(out) {
constr.gradient(out);
for (var i = 0; i < out.length; i++) {
out[i] *= weight;
}
}
};
TCAD.constraints.EqualsTo = function(params, value) {
this.params = params;

View file

@ -87,7 +87,7 @@ TCAD.parametric.System.prototype.calcResidual = function(r) {
err *= 0.5;
return err;
}
};
TCAD.parametric.System.prototype.calcGrad_ = function(out) {
var i;
@ -200,7 +200,7 @@ TCAD.parametric.lock1 = function(constrs, locked) {
TCAD.parametric.lock2Equals2 = function(constrs, locked) {
var _locked = [];
for (var i = 0; i < locked.length; ++i) {
_locked.push(new TCAD.constraints.EqualsTo([locked[i]], locked[i].get()));
_locked.push(new TCAD.constraints.Weighted(new TCAD.constraints.EqualsTo([locked[i]], locked[i].get()), 0.1));
}
return _locked;
};
@ -209,7 +209,7 @@ TCAD.parametric.prepare = function(constrs, locked, alg) {
// this.lock1(constrs, locked);
var lockingConstrs = this.lock2Equals2(constrs, locked);
Array.prototype.push.apply( constrs, lockingConstrs );
// Array.prototype.push.apply( constrs, lockingConstrs );
var sys = new TCAD.parametric.System(constrs);

View file

@ -252,7 +252,7 @@ TCAD.TWO.ParametricManager.prototype.prepare = function(locked, alg) {
}
for (i = 0; i < this.system.length; ++i) {
var c = this.system[i];
if (c.NAME === 'equal' && c.coincident === true) {
if (c.NAME === 'equal' && c.coincident === true && false) { //Disable it
var found = false;
//if (!peq(c.p1, c.p2)) continue;
var p0 = c.p1.id;