Sylvester version: 0.1.0 onwards
anchor– a 3D
Vectorcorresponding to a point on the line
direction– a normalized 3D
Vectorrepresenting the line’s direction
Line class is designed to model infinite straight lines in
3 dimensions. It is possible to specify lines using 2D
Vectors, but they will be stored
Line instance as 3D vectors whose third element is zero.
Lines created in this way are thus 3D lines confined to the
x-y plane. You can also specify 2D vectors as
arguments for many of
Line’s instance methods –
again, these will be interpreted as 3D vectors with a zero third
Line.create(anchor, direction) 0.1.0
Line instance with the specified properties.
direction can each be either 2- or
3-dimensional arrays or
and they will be stored in the
Line’s properties as 3D
vectors. (The third element will be zero if a 2D vector was supplied.)
direction will be
normalized before being saved.
The following are all fine:
var A = Line.create([4,8], [1,5]); var B = Line.create($V([4,8]), $V([1,5])); var C = Line.create([9,2,5], $V([8,2,0]));
For situations where x, y and z are used to refer to co-ordinates, x corresponds to the first element of a vector, y the second and z the third.
This method is aliased as
Line.X, Line.Y, Line.Z 0.1.0
Line instances representing the x, y and z axes respectively.
true iff the vector
point is a point that
lies on the receiver.
Returns a copy of the receiver.
line is equal to the receiver,
that is, if they both represent the same region of space. Their
direction properties do not have to be
identical for this to be the case. As long as
line.anchor is a
point on the receiver, and
line.direction is (anti)parallel to
the receiver’s direction, then this method returns
true iff the receiver has a unique point of
obj, which can be either a
true iff the receiver and
parallel lines. Their direction vectors can point in opposite directions
– two lines with opposing directions represent the same set of
true iff the receiver lies in the given
the point on the receiver that is closest to
obj, which can be
Vector or a
Line. If a
null if the lines are parallel – there is no
unique closest point.
rotate(angle, axis) 0.1.0
Returns the result of rotating the receiver by
axis, which can be a
Line, or a
Vector. If a
the receiver is rotated about a line whose anchor is
whose direction is
[0, 0, 1]. This is useful for working in
var L = Line.X.rotate(Math.PI/2, $V([5,0])); var test = L.eql(Line.create([5,0], [0,1])); // Returns true - the 90-degree rotation leaves Line.X parallel to the y axis
Be careful when working with
axis as a
– rotations are performed in a right-handed fashion about the
setVectors(anchor, direction) 0.1.0
Sets the receiver’s properties accordingly. See create.
Returns the result of translating the receiver by adding
vector to its
can be a 2- or 3- dimensional array or
Vector. If 2-dimensional, a zero
third component will be added.