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/vector2.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
- .new(x : Float32 = 0.0_f32, y : Float32 = 0.0_f32)
- .new(x : Number, y : Number)
- .new(pointer : Pointer(Void))
Instance Method Summary
- #!=(other : Vector2) : Bool
- #*(scalar : Number) : Vector2
- #*(other : Vector2) : Vector2
- #+(other : Vector2) : Vector2
- #-(other : Vector2) : Vector2
- #- : Vector2
- #/(scalar : Number) : Vector2
- #/(other : Vector2) : Vector2
- #==(other : Vector2) : Bool
- #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
-
#bezier_interpolate(control_1 : Vector2, control_2 : Vector2, end_point : Vector2, t : Number) : Vector2
Bezier interpolation through control points.
-
#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.
-
#clampf(min_val : Number, max_val : Number) : Vector2
Clamps each component between scalar min and max values.
- #cross(other : Vector2) : Float32
-
#cubic_interpolate(b : Vector2, pre_a : Vector2, post_b : Vector2, weight : Number) : Vector2
Cubic interpolation between two vectors using pre_a and post_b tangents.
-
#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_finite? : Bool
- #is_normalized? : Bool
- #is_zero_approx : 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.
-
#posmod(mod_val : Number) : Vector2
Returns the vector with each component modulo scalar.
-
#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.
-
#snapped(step : Vector2) : Vector2
Snaps vector components to nearest multiple of step.
- #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.
Bezier interpolation through control points.
Returns a new vector bounced off a plane defined by the given normal.
Clamps each component between scalar min and max values.
Cubic interpolation between two vectors using pre_a and post_b tangents.
Returns the normalized direction from this vector toward other.
Returns the squared distance between this vector and other.
Linearly interpolates between this vector and to by weight.
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.
Spherically interpolates between this vector and to by weight.
Returns a new vector slid along a plane defined by the given normal.