Class: Vector

Vector(vertA, vertB)

new Vector(vertA, vertB)

The constructor.
Parameters:
Name Type Description
vertA Vertex The start vertex of the vector.
vertB Vertex The end vertex of the vector.
Source:

Extends

Members

a :Vertex

Type:
Inherited From:
Source:

b :Vertex

Type:
Inherited From:
Source:

Methods

add(amount) → {Line}

Add the given vertex from this line's end points.
Parameters:
Name Type Description
amount Vertex The amount (x,y) to add.
Inherited From:
Source:
Returns:
this
Type
Line

angle(lineopt) → {number}

Get the angle between this and the passed line (in radians).
Parameters:
Name Type Attributes Description
line Line <optional>
(optional) The line to calculate the angle to. If null the baseline (x-axis) will be used.
Inherited From:
Source:
Returns:
this
Type
number

clone() → {Line}

Create a deep clone of this line.
Overrides:
Source:
Returns:
A copy if this line.
Type
Line

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.
Inherited From:
Source:
Returns:
The line position t of minimal distance to p.
Type
number

intersection(line) → {Vertex}

Get the intersection if this line and the specified line.
Parameters:
Name Type Description
line Line The second line.
Inherited From:
Source:
Returns:
The intersection (may lie outside the end-points).
Type
Vertex

length()

Get the length of this line.
Inherited From:
Source:

moveTo(newA) → {Line}

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.
Inherited From:
Source:
Returns:
this
Type
Line

normalize() → {Line}

Normalize this line (set to length 1).
Inherited From:
Source:
Returns:
this
Type
Line

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.
Inherited From:
Source:
Returns:
The absolute minimal distance.
Type
number

scale(factor) → {Line}

Scale this line by the given factor.
Parameters:
Name Type Description
factor number The factor for scaling (1.0 means no scale).
Inherited From:
Source:
Returns:
this
Type
Line

sub(amount) → {Line}

Substract the given vertex from this line's end points.
Parameters:
Name Type Description
amount Vertex The amount (x,y) to substract.
Inherited From:
Source:
Returns:
this
Type
Line

toSVGString(p) → {string}

Create an SVG representation of this line.
Parameters:
Name Type Description
p options A set of options, like the 'classname' to use for the line object.
Overrides:
Source:
Returns:
The SVG string representing this line.
Type
string

totring() → {string}

Create a string representation of this line.
Inherited From:
Source:
Returns:
The string representing this line.
Type
string

vertAt(t) → {Vertex}

Get line point at position t in [0 ... 1]:
[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.
Inherited From:
Source:
Returns:
The vertex a position t.
Type
Vertex