2-element structure that can be used to represent 2D coordinates or vectors with 32-bit floating point precision.
Constants
DOWN =
Vector2.new(0.0_f32, 1.0_f32)
INF =
Vector2.new(
Float32::INFINITY,
Float32::INFINITY)
LEFT =
Vector2.new(-1.0_f32, 0.0_f32)
ONE =
Vector2.new(1.0_f32, 1.0_f32)
RIGHT =
Vector2.new(1.0_f32, 0.0_f32)
UP =
Vector2.new(0.0_f32, -1.0_f32)
ZERO =
Vector2.new(0.0_f32, 0.0_f32)
Constructors
new(x : Float32 = 0.0_f32, y : Float32 = 0.0_f32)
Sourcenew(x : Number, y : Number)
SourceInstance methods
angle
Returns the angle in radians of this vector with respect to the positive X-axis.
SourceReturns the unsigned angle in radians between this vector and other.
Sourceangle_to_point(to :
Vector2) :
Float32 Returns the angle in radians between this vector and the given point.
SourceReturns a new vector bounced off a plane defined by the given normal.
SourceClamps each component between min and max.
SourceReturns the normalized direction from this vector toward other.
Sourcedistance_squared_to(other :
Vector2) :
Float32 Returns the squared distance between this vector and other.
Sourcedistance_to(other :
Vector2) :
Float32 Returns the distance between this vector and other.
SourceLinearly interpolates between this vector and to by weight.
Sourcelimit_length(max_length :
Number = 1.0) :
Vector2 Clamps the vector's length to max_length.
SourceMoves this vector toward to by the given delta amount, never exceeding to.
Sourceorthogonal
Returns the vector rotated 90 degrees counter-clockwise.
SourceProjects this vector onto vector b.
SourceReturns a new vector reflected from a plane defined by the given normal.
SourceRotates this vector by the given angle in radians.
SourceSpherically interpolates between this vector and to by weight.
SourceReturns a new vector slid along a plane defined by the given normal.
Source