Improve arguments reading in Line constructors.

Avoid parameter overriding.
This commit is contained in:
Jürg Lehni 2012-12-27 19:12:30 +01:00
parent 03b5d58e79
commit fdb4bab479

View file

@ -34,15 +34,16 @@ var Line = this.Line = Base.extend(/** @lends Line# */{
// intersection outside the line segment are allowed.
// With two parameters, the 2nd parameter is a direction, and infinite
// is automatially true, since we're describing an infinite line.
point1 = Point.read(arguments);
point2 = Point.read(arguments);
if (arguments.length == 3) {
this.point = point1;
this.vector = point2.subtract(point1);
this.infinite = infinite;
var _point1 = Point.read(arguments),
_point2 = Point.read(arguments),
_infinite = Base.readValue(arguments);
if (_infinite !== undefined) {
this.point = _point1;
this.vector = _point2.subtract(_point1);
this.infinite = _infinite;
} else {
this.point = point1;
this.vector = point2;
this.point = _point1;
this.vector = _point2;
this.infinite = true;
}
},