Class: VertTuple
VertTuple(a, b)
new VertTuple(a, b)
Creates an instance.
Parameters:
Name | Type | Description |
---|---|---|
a |
Vertex | The tuple's first point. |
b |
Vertex | The tuple's second point. |
- Source:
Methods
(static) setLength(length) → {T}
Set the length of this vector to the given amount. This only works if this
vector is not a null vector.
Parameters:
Name | Type | Description |
---|---|---|
length |
number | The desired length. |
- Source:
Returns:
this (for chaining)
- Type
- T
add(amount) → {Line}
Add the given vertex to this line's end points.
Parameters:
Name | Type | Description |
---|---|---|
amount |
XYCoords | The amount (x,y) to add. |
- Source:
Returns:
this
- Type
- Line
angle(line) → {number}
Get the angle between this and the passed line (in radians).
Parameters:
Name | Type | Description |
---|---|---|
line |
VertTuple | (optional) The line to calculate the angle to. If null the baseline (x-axis) will be used. |
- Source:
Returns:
this
- Type
- number
cloneLine() → {T}
Create a deep clone of this instance.
- Source:
Returns:
A type safe clone if this instance.
- Type
- T
colinear(line)
Checks if this and the given line are co-linear.
The constant Vertex.EPSILON is used for tolerance.
Parameters:
Name | Type | Description |
---|---|---|
line |
VertTuple |
- Source:
Returns:
true if both lines are co-linear.
denominator(line) → {Number}
Get the denominator of this and the given line.
If the denominator is zero (or close to zero) both line are co-linear.
Parameters:
Name | Type | Description |
---|---|---|
line |
VertTuple |
- Source:
Returns:
- Type
- Number
getClosestPoint(p) → {Vertex}
Get the closest point on this line to the specified point.
Parameters:
Name | Type | Description |
---|---|---|
p |
Vertex | The point (vertex) to measre the distance to. |
- Source:
Returns:
The point on the line that is closest to p.
- Type
- Vertex
getClosestT(p) → {number}
Get the closest position T from this line to the specified point.
The counterpart for this function is Line.vertAt(Number).
Parameters:
Name | Type | Description |
---|---|---|
p |
Vertex | The point (vertex) to measre the distance to. |
- Source:
Returns:
The line position t of minimal distance to p.
- Type
- number
length()
Get the length of this line.
- Source:
moveTo(newA) → {VertTuple}
Move this line to a new location.
Parameters:
Name | Type | Description |
---|---|---|
newA |
Vertex | The new desired location of 'a'. Vertex 'b' will be moved, too. |
- Source:
Returns:
this
- Type
- VertTuple
normalize() → {VertTuple}
Normalize this line (set to length 1).
- Source:
Returns:
this
- Type
- VertTuple
pointDistance(p) → {number}
The the minimal distance between this line and the specified point.
Parameters:
Name | Type | Description |
---|---|---|
p |
Vertex | The point (vertex) to measre the distance to. |
- Source:
Returns:
The absolute minimal distance.
- Type
- number
scale(factor) → {VertTuple}
Scale this line by the given factor.
Parameters:
Name | Type | Description |
---|---|---|
factor |
number | The factor for scaling (1.0 means no scale). |
- Source:
Returns:
this
- Type
- VertTuple
sub(amount) → {VertTuple}
Substract the given vertex from this line's end points.
Parameters:
Name | Type | Description |
---|---|---|
amount |
XYCoords | The amount (x,y) to substract. |
- Source:
Returns:
this
- Type
- VertTuple
totring() → {string}
Create a string representation of this line.
- Source:
Returns:
The string representing this line.
- Type
- string
vertAt(t) → {Vertex}
Get line point at position t in [0 ... 1]:
The counterpart of this function is Line.getClosestT(Vertex).
[P(0)]=[A]--------------------[P(t)]------[B]=[P(1)]
The counterpart of this function is Line.getClosestT(Vertex).
Parameters:
Name | Type | Description |
---|---|---|
t |
number | The position scalar. |
- Source:
Returns:
The vertex a position t.
- Type
- Vertex