Classes
Members
slope
Slope of the line - angle to axe x in radians from 0 to 2PI
- Source:
Methods
contains(pt) → {boolean}
Returns true if segment contains point
- Source:
Parameters:
Name | Type | Description |
---|---|---|
pt |
Point
|
Query point |
Returns:
- Type:
-
boolean
distanceTo(shape) → {number|Segment}
Calculate distance and shortest segment from segment to shape and return as array [distance, shortest segment]
- Source:
Parameters:
Name | Type | Description |
---|---|---|
shape |
Shape
|
Shape of the one of supported types Point, Line, Circle, Segment, Arc, Polygon or Planar Set |
Returns:
-
- Type:
-
number
distance from segment to shape -
- Type:
-
Segment
shortest segment between segment and shape (started at segment, ended at shape)
equalTo(seg) → {boolean}
Returns true if equals to query segment, false otherwise
- Source:
Parameters:
Name | Type | Description |
---|---|---|
seg |
Seg
|
query segment |
Returns:
- Type:
-
boolean
intersect(shape) → {Array.<Point>}
Returns array of intersection points between segment and other shape
- Source:
Parameters:
Name | Type | Description |
---|---|---|
shape |
Shape
|
Shape of the one of supported types |
Returns:
- Type:
-
Array.<Point>
isZeroLength() → {boolean}
Returns true if segment start is equal to segment end up to DP_TOL
- Source:
Returns:
- Type:
-
boolean
pointAtLength(length) → {Point}
Get point at given length
- Source:
Parameters:
Name | Type | Description |
---|---|---|
length |
number
|
The length along the segment |
Returns:
- Type:
-
Point
reverse() → {Segment}
Returns new segment with swapped start and end points
- Source:
Returns:
- Type:
-
Segment
sortPoints(pts) → {Array.<Point>}
Sort given array of points from segment start to end, assuming all points lay on the segment
- Source:
Parameters:
Name | Type | Description |
---|---|---|
pts |
Array.<Point>
|
array of points |
split(pt) → {Array.<Segment>}
When point belongs to segment, return array of two segments split by given point,
if point is inside segment. Returns clone of this segment if query point is incident
to start or end point of the segment. Returns empty array if point does not belong to segment
- Source:
Parameters:
Name | Type | Description |
---|---|---|
pt |
Point
|
Query point |
Returns:
- Type:
-
Array.<Segment>
svg(attrs) → {string}
Return string to draw segment in svg
- Source:
Parameters:
Name | Type | Description |
---|---|---|
attrs |
Object
|
an object with attributes for svg path element,
like "stroke", "strokeWidth" Defaults are stroke:"black", strokeWidth:"1" |
Returns:
- Type:
-
string
tangentInEnd() → {Vector}
Return unit vector in the direction from end to start
- Source:
Returns:
- Type:
-
Vector
tangentInStart() → {Vector}
Returns unit vector in the direction from start to end
- Source:
Returns:
- Type:
-
Vector