Fizzy / docs / ref / Vector2.md
Vector2
A vector of two doubles. Unlike Dimension2, a Vector2 has no units, and it therefore not used to store points.
Creation
The long form :
Vector2( 10, 20 )
The short form :
( 10, 10 )
The brackets are actually optional, but adding them adds clarity. When passed as an argument to a function or method, the brackets become mandatory :
foo( ( 10, 10 ) ) // Correct
foo( 10, 10 ) // Wrong - two parameters of type Double, not a Vector2.
Fields
Name | Type | Comments |
---|---|---|
X | Double | |
Y | Double | |
Angle | Angle | |
Length | Double |
Methods
Name | Parameters | Return Type | Comments |
---|---|---|---|
format | String | String | Uses Java's DecimalFormat |
normalise | none | Vector2 | Creates a vector of length 1, in the same direction. |
rotate | Angle | Vector2 | Rotates the vector about the origin. |
clamp | min : Vector2, max : Vector2 | Vector2 |