VecBase class
Shared base class of Vec and Direction. We do this instead of having
Direction inherit directly from Vec so that we can avoid it inheriting
an ==
operator, which would prevent it from being used in switch
statements. Instead, Direction uses identity equality.
Properties
- area → int
-
Gets the area of a Rect whose corners are (0, 0) and this Vec.
no setter
-
cardinalNeighbors
→ List<
Vec> -
The four Vecs surrounding this one to the north, south, east, and west.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
intercardinalNeighbors
→ List<
Vec> -
The four Vecs surrounding this one to the northeast, southeast, southwest,
and northwest.
no setter
- kingLength → int
-
Gets the king length of the Vec, which is the number of squares a king on
a chessboard would need to move from (0, 0) to reach the endpoint of the
Vec. Also known as Chebyshev distance.
no setter
- length → num
-
The Cartesian length of the vector.
no setter
- lengthSquared → int
-
no setter
- nearestDirection → Direction
-
The Direction that most closely approximates the angle of this Vec.
no setter
-
neighbors
→ List<
Vec> -
The eight Vecs surrounding this one to the north, south, east, and west
and points in between.
no setter
- rookLength → int
-
Gets the rook length of the Vec, which is the number of squares a rook on
a chessboard would need to move from (0, 0) to reach the endpoint of the
Vec. Also known as Manhattan or taxicab distance.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- x → int
-
final
- y → int
-
final
Methods
-
abs(
) → Vec - Returns a new Vec with the absolute value of the coordinates of this one.
-
contains(
Vec pos) → bool -
Returns
true
ifpos
is within a rectangle from (0,0) to this vector (half-inclusive). -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
offset(
int x, int y) → Vec -
Returns a new Vec whose coordinates are this one's translated by
x
andy
. -
offsetX(
int x) → Vec -
Returns a new Vec whose coordinates are this one's but with the X
coordinate translated by
x
. -
offsetY(
int y) → Vec -
Returns a new Vec whose coordinates are this one's but with the Y
coordinate translated by
y
. -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator *(
int other) → Vec -
Scales this Vec by
other
. -
operator +(
Object other) → Vec -
Adds
other
to this Vec. -
operator -(
Object other) → Vec -
Substracts
other
from this Vec. -
operator <(
Object other) → bool -
Returns
true
if the magnitude of this vector is less thanother
. -
operator <=(
Object other) → bool -
Returns
true
if the magnitude of this vector is less than or equal toother
. -
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator >(
Object other) → bool -
Returns
true
if the magnitude of this vector is greater thanother
. -
operator >=(
Object other) → bool -
Returns
true
if the magnitude of this vector is greater than or equal toother
. -
operator ~/(
int other) → Vec -
Scales this Vec by
other
.