new Vertex(x, y)
The constructor for the vertex class.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The x-coordinate of the new vertex. |
y |
number | The y-coordinate of the new vertex. |
Members
x :Vertex
Type:
y :Vertex
Type:
Methods
add(x, yopt) → {Vertex}
Add the passed amount to x- and y- component of this vertex.
This function works with add( {number}, {number} ) and add( {Vertex} ), as well.
This function works with add( {number}, {number} ) and add( {Vertex} ), as well.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
x |
number | Vertex | The amount to add to x (or a vertex itself). | |
y |
number |
<optional> |
The amount to add to y. |
Returns:
this
- Type
- Vertex
addXY(x, y) → {Vertex}
Add the passed amounts to the x- and y- components of this vertex.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The amount to add to x. |
y |
number | The amount to add to y. |
Returns:
this
- Type
- Vertex
clone() → {Vertex}
Create a copy of this vertex.
Returns:
A new vertex, an exact copy of this.
- Type
- Vertex
difference(vert) → {Vertex}
Get the difference to the passed point.
The difference is (vert.x-this.x, vert.y-this.y).
The difference is (vert.x-this.x, vert.y-this.y).
Parameters:
Name | Type | Description |
---|---|---|
vert |
Vertex | The vertex to measure the x-y-difference to. |
Returns:
A new vertex.
- Type
- Vertex
distance(vert) → {number}
Get the distance to the passed point (in euclidean metric)
Parameters:
Name | Type | Description |
---|---|---|
vert |
Vertex | The vertex to measure the distance to. |
Returns:
- Type
- number
equals(vertex) → {boolean}
Check if this vertex equals the passed one.
This function uses an internal epsilon as tolerance.
This function uses an internal epsilon as tolerance.
Parameters:
Name | Type | Description |
---|---|---|
vertex |
Vertex | The vertex to compare this with. |
Returns:
- Type
- boolean
inv() → {Vertex}
Change this vertex (x,y) to its inverse (-x,-y).
Returns:
this
- Type
- Vertex
multiplyScalar(scalar) → {Vertex}
Multiply both components of this vertex with the given scalar.
Note: as in
https://threejs.org/docs/#api/math/Vector2.multiplyScalar
Note: as in
https://threejs.org/docs/#api/math/Vector2.multiplyScalar
Parameters:
Name | Type | Description |
---|---|---|
scalar |
number | The scale factor; 1.0 means no change. |
Returns:
this
- Type
- Vertex
round() → {Vertex}
Round the two components x and y of this vertex.
Returns:
this
- Type
- Vertex
scale(factor, centeropt) → {Vertex}
This is a vector-like behavior and 'scales' this vertex
towards/from a given center.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
factor |
number | The factor to 'scale' this vertex; 1.0 means no change. | |
center |
Vertex |
<optional> |
The origin of scaling; default is (0,0). |
Returns:
this
- Type
- Vertex
set(x, y) → {Vertex}
Set the x- and y- component of this vertex.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The new x-component. |
y |
number | The new y-component. |
Returns:
this
- Type
- Vertex
setX(x) → {Vertex}
Set the x-component of this vertex.
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The new x-component. |
Returns:
this
- Type
- Vertex
setY(y) → {Vertex}
Set the y-component of this vertex.
Parameters:
Name | Type | Description |
---|---|---|
y |
number | The new y-component. |
Returns:
this
- Type
- Vertex
sub(x, yopt) → {Vertex}
Substract the passed amount from x- and y- component of this vertex.
This function works with sub( {number}, {number} ) and sub( {Vertex} ), as well.
This function works with sub( {number}, {number} ) and sub( {Vertex} ), as well.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
x |
number | Vertex | The amount to substract from x (or a vertex itself). | |
y |
number |
<optional> |
The amount to substract from y. |
Returns:
this
- Type
- Vertex
toString() → {string}
Get a string representation of this vertex.
Returns:
The string representation of this vertex.
- Type
- string