struct
Godot::Vector2
- Godot::Vector2
- Struct
- Value
- Object
Overview
2-element structure that can be used to represent 2D coordinates or vectors with 32-bit floating point precision.
Defined in:
libgodot/types.crConstant Summary
-
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
Instance Method Summary
- #*(scalar : Number) : Vector2
- #*(other : Vector2) : Vector2
- #+(other : Vector2) : Vector2
- #-(other : Vector2) : Vector2
- #- : Vector2
- #/(scalar : Number) : Vector2
- #/(other : Vector2) : Vector2
- #abs : Vector2
-
#angle : Float32
Returns the angle in radians of this vector with respect to the positive X-axis.
-
#angle_to(to : Vector2) : Float32
Returns the unsigned angle in radians between this vector and other.
-
#angle_to_point(to : Vector2) : Float32
Returns the angle in radians between this vector and the given point.
- #aspect : Float32
-
#bounce(normal : Vector2) : Vector2
Returns a new vector bounced off a plane defined by the given normal.
- #ceil : Vector2
-
#clamp(min : Vector2, max : Vector2) : Vector2
Clamps each component between min and max.
- #cross(other : Vector2) : Float32
-
#direction_to(other : Vector2) : Vector2
Returns the normalized direction from this vector toward other.
-
#distance_squared_to(other : Vector2) : Float32
Returns the squared distance between this vector and other.
-
#distance_to(other : Vector2) : Float32
Returns the distance between this vector and other.
- #dot(other : Vector2) : Float32
- #floor : Vector2
- #is_equal_approx(other : Vector2) : Bool
- #is_normalized? : Bool
- #is_zero_approx : Bool
- #length : Float32
- #length_squared : Float32
-
#lerp(to : Vector2, weight : Number) : Vector2
Linearly interpolates between this vector and to by weight.
-
#limit_length(max_length : Number = 1.0) : Vector2
Clamps the vector's length to max_length.
- #max(other : Vector2) : Vector2
- #min(other : Vector2) : Vector2
-
#move_toward(to : Vector2, delta : Number) : Vector2
Moves this vector toward to by the given delta amount, never exceeding to.
- #normalized : Vector2
-
#orthogonal : Vector2
Returns the vector rotated 90 degrees counter-clockwise.
-
#perpendicular : Vector2
Alias for orthogonal.
-
#project(b : Vector2) : Vector2
Projects this vector onto vector b.
-
#reflect(normal : Vector2) : Vector2
Returns a new vector reflected from a plane defined by the given normal.
-
#rotated(angle : Number) : Vector2
Rotates this vector by the given angle in radians.
- #round : Vector2
- #sign : Vector2
-
#slerp(to : Vector2, weight : Number) : Vector2
Spherically interpolates between this vector and to by weight.
-
#slide(normal : Vector2) : Vector2
Returns a new vector slid along a plane defined by the given normal.
- #to_i : Vector2i
-
#to_s(io : IO) : Void
Same as
#inspect(io). - #x : Float32
- #x=(x : Float32)
- #y : Float32
- #y=(y : Float32)
Constructor Detail
Instance Method Detail
Returns the angle in radians of this vector with respect to the positive X-axis.
Returns the unsigned angle in radians between this vector and other.
Returns the angle in radians between this vector and the given point.
Returns a new vector bounced off a plane defined by the given normal.
Clamps each component between min and max.
Returns the normalized direction from this vector toward other.
Returns the squared distance between this vector and other.
Returns the distance between this vector and other.
Linearly interpolates between this vector and to by weight.
Clamps the vector's length to max_length.
Moves this vector toward to by the given delta amount, never exceeding to.
Returns a new vector reflected from a plane defined by the given normal.
Rotates this vector by the given angle in radians.
Spherically interpolates between this vector and to by weight.
Returns a new vector slid along a plane defined by the given normal.