Usage (signatures)
board.create('segment', [point1, point2, lengthopt]);
Create a segment from two points, coordinate arrays or functions. In the latter two cases the point will be constructed automatically as a fixed invisible point. It is possible to provide a function returning an array or a point, instead of providing an array or a point.
If the third variable is supplied then the segment has a fixed length (which may be a function, too) determined by the absolute value of that number.
Parameters
| Name | Type | Attributes | Description |
|---|---|---|---|
point1 |
PointLike | First point |
|
point2 |
PointLike | Second point |
|
length |
number | function |
<optional> |
The points are adapted - if possible - such that their distance is equal to the absolute value of this number. |
Examples
Create segment providing two points
var p1 = board.create('point', [4.5, 2.0]);
var p2 = board.create('point', [1.0, 1.0]);
var l1 = board.create('segment', [p1, p2]);
Create segments with fixed length
var p1 = board.create('point', [4.0, 1.0]);
var p2 = board.create('point', [1.0, 1.0]);
// AB
var l1 = board.create('segment', [p1, p2]);
var p3 = board.create('point', [4.0, 2.0]);
var p4 = board.create('point', [1.0, 2.0]);
// CD
var l2 = board.create('segment', [p3, p4, 3]); // Fixed length
var p5 = board.create('point', [4.0, 3.0]);
var p6 = board.create('point', [1.0, 4.0]);
// EF
var l3 = board.create('segment', [p5, p6, function(){ return l1.L();} ]); // Fixed, but dependent length
Attributes
Own
none
Inherited
Members
Own
none
Inherited
Methods
Own
none
Inherited
Events
Own
none
Inherited
Throws
-
If the element cannot be constructed with the given parent objects an exception is thrown.
- Type
- Exception
Details
- Type
- JXG.Line
- See
- Source
- base/line.js, line 1547