Skip to content

Commit f0296b2

Browse files
committed
removing sqrt
1 parent 5cae4ee commit f0296b2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

js/verlet-js/constraint.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ function DistanceConstraint(a, b, stiffness, distance /*optional*/) {
3636

3737
DistanceConstraint.prototype.relax = function(stepCoef) {
3838
var normal = this.a.pos.sub(this.b.pos);
39-
var m = normal.length();
40-
normal.mutableScale(((this.distance - m)/m)*this.stiffness*stepCoef);
39+
var m = normal.length2();
40+
normal.mutableScale(((this.distance*this.distance - m)/m)*this.stiffness*stepCoef);
4141
this.a.pos.mutableAdd(normal);
4242
this.b.pos.mutableSub(normal);
4343
}

0 commit comments

Comments
 (0)