Vec2 class

Immutable 2D vector.

Constructors

Vec2(double x, double y)
Creates a vector from x/y components.
const
Vec2.fromJson(Map<String, dynamic> json)
Deserializes a vector from JSON.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
isFinite bool
Whether both components are finite.
no setter
norm double
Magnitude.
no setter
normSquared double
Squared magnitude.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
x double
X-axis component.
final
y double
Y-axis component.
final

Methods

dot(Vec2 other) double
Dot product.
normalizedOr(Vec2 fallback) Vec2
Normalized vector, or fallback if magnitude is zero.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Serializes this vector to JSON.
toString() String
A string representation of this object.
inherited

Operators

operator *(double scalar) Vec2
Scalar multiplication.
operator +(Vec2 other) Vec2
Vector addition.
operator -(Vec2 other) Vec2
Vector subtraction.
operator /(double scalar) Vec2
Scalar division.
operator ==(Object other) bool
The equality operator.
inherited

Constants

zero → const Vec2
Zero vector constant.