src/app/graphs/automatic-layout.ts
A simple 2D vector class. The value of this vector is essentially immutable, every operation returns a new vector!
Properties |
Methods |
|
constructor(x: number, y: number)
|
Defined in src/app/graphs/automatic-layout.ts:9
|
Vector constructor |
Public x |
Type : number
|
Defined in src/app/graphs/automatic-layout.ts:8
|
Public y |
Type : number
|
Defined in src/app/graphs/automatic-layout.ts:9
|
Public add | ||||||||
add(other: Vector)
|
||||||||
Defined in src/app/graphs/automatic-layout.ts:64
|
||||||||
Add this vector and another vector
Parameters :
Returns :
Vector
A new vector, the sum of this vector and the other vector |
Public addSelf | ||||||||
addSelf(other: Vector)
|
||||||||
Defined in src/app/graphs/automatic-layout.ts:73
|
||||||||
Add another vector on this vector
Parameters :
Returns :
Vector
This vector |
Public distanceToLine | ||||||||||||
distanceToLine(sourcePoint: Vector, targetPoint: Vector)
|
||||||||||||
Defined in src/app/graphs/automatic-layout.ts:123
|
||||||||||||
Calculate the distance of a point, as represented by this vector, to a line, as defined by two other points. Note that the length of the line is infinite, and that this function calculates the distance to this infinitely long line. If this is not desired, the #isBehind function can be used to determine if a point is outside the defined line segment.
Parameters :
Returns :
number
The distance to the infinitely long line |
Public dot | ||||||||
dot(other: Vector)
|
||||||||
Defined in src/app/graphs/automatic-layout.ts:109
|
||||||||
Calculate the dot product
Parameters :
Returns :
number
dot(this, other) |
Static isBehind | ||||||||||||||||
isBehind(source: Vector, target: Vector, point: Vector)
|
||||||||||||||||
Defined in src/app/graphs/automatic-layout.ts:29
|
||||||||||||||||
Check if the vector pointing from
Parameters :
Returns :
boolean
dot(target - source, point - source) < 0 |
Public isZero |
isZero()
|
Defined in src/app/graphs/automatic-layout.ts:135
|
Check if both components of this vector are zero
Returns :
boolean
True if it is zero |
Public length |
length()
|
Defined in src/app/graphs/automatic-layout.ts:47
|
Length of the vector
Returns :
number
|
Public normalize |
normalize()
|
Defined in src/app/graphs/automatic-layout.ts:55
|
Normalize the vector
Returns :
Vector
A new, normalized vector |
Public perpendicularClockwise |
perpendicularClockwise()
|
Defined in src/app/graphs/automatic-layout.ts:92
|
Rotate this vector by 90 degrees in the clockwise direction
Returns :
Vector
A new, rotated vector |
Public perpendicularCounterClockwise |
perpendicularCounterClockwise()
|
Defined in src/app/graphs/automatic-layout.ts:100
|
Rotate this vector by 90 degrees in the counter-clockwise direction
Returns :
Vector
A new, rotated vector |
Public scale | ||||||||
scale(factor: number)
|
||||||||
Defined in src/app/graphs/automatic-layout.ts:40
|
||||||||
Scale the vector
Parameters :
Returns :
Vector
A new, scaled vector |
Public subtract | ||||||||
subtract(other: Vector)
|
||||||||
Defined in src/app/graphs/automatic-layout.ts:84
|
||||||||
Subtract this vector and another vector
Parameters :
Returns :
Vector
A new vector, the difference of this vector and the other vector |