Class: Line

Line(a, b)

new Line(a, b)

Creates an instance of Line.
Parameters:
Name Type Description
a Vertex The line's first point.
b Vertex The line's second point.
Source:

Members

a :Vertex

Type:
Source:

b :Vertex

Type:
Source:

Methods

angle(line) → {number}

Get the angle between this and the passed line (in radians).
Parameters:
Name Type Description
line Line The line to calculate the angle to.
Source:
Returns:
this
Type
number

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

intersection(line) → {Vertex}

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

length()

Get the length of this line.
Source:

normalize() → {Line}

Normalize this line (set to length 1).
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.
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).
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.
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.
Source:
Returns:
The SVG string representing this line.
Type
string

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]:
[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