struct
Godot::Vector3
- Godot::Vector3
- Struct
- Value
- Object
Overview
3-element structure that can be used to represent 3D coordinates or vectors with 32-bit floating point precision.
Defined in:
libgodot/types.crConstant Summary
-
BACK =
Vector3.new(0.0_f32, 0.0_f32, 1.0_f32) -
DOWN =
Vector3.new(0.0_f32, -1.0_f32, 0.0_f32) -
FORWARD =
Vector3.new(0.0_f32, 0.0_f32, -1.0_f32) -
INF =
Vector3.new(Float32::INFINITY, Float32::INFINITY, Float32::INFINITY) -
LEFT =
Vector3.new(-1.0_f32, 0.0_f32, 0.0_f32) -
ONE =
Vector3.new(1.0_f32, 1.0_f32, 1.0_f32) -
RIGHT =
Vector3.new(1.0_f32, 0.0_f32, 0.0_f32) -
UP =
Vector3.new(0.0_f32, 1.0_f32, 0.0_f32) -
ZERO =
Vector3.new(0.0_f32, 0.0_f32, 0.0_f32) -
Common constants
Constructors
- .new(x : Float32 = 0.0_f32, y : Float32 = 0.0_f32, z : Float32 = 0.0_f32)
- .new(x : Number, y : Number, z : Number)
Instance Method Summary
- #*(scalar : Number) : Vector3
- #*(other : Vector3) : Vector3
- #+(other : Vector3) : Vector3
- #-(other : Vector3) : Vector3
- #- : Vector3
- #/(scalar : Number) : Vector3
- #/(other : Vector3) : Vector3
- #abs : Vector3
-
#angle_to(to : Vector3) : Float32
Returns the unsigned angle in radians between this vector and other.
-
#bounce(normal : Vector3) : Vector3
Returns a new vector bounced off a plane defined by the given normal.
- #ceil : Vector3
-
#clamp(min : Vector3, max : Vector3) : Vector3
Clamps each component between min and max.
- #cross(other : Vector3) : Vector3
-
#direction_to(other : Vector3) : Vector3
Returns the normalized direction from this vector toward other.
-
#distance_squared_to(other : Vector3) : Float32
Returns the squared distance between this vector and other.
-
#distance_to(other : Vector3) : Float32
Returns the distance between this vector and other.
- #dot(other : Vector3) : Float32
- #floor : Vector3
- #is_equal_approx(other : Vector3) : Bool
- #is_normalized? : Bool
- #is_zero_approx : Bool
- #length : Float32
- #length_squared : Float32
-
#lerp(to : Vector3, weight : Number) : Vector3
Linearly interpolates between this vector and to by weight.
-
#limit_length(max_length : Number = 1.0) : Vector3
Clamps the vector's length to max_length.
- #max(other : Vector3) : Vector3
- #min(other : Vector3) : Vector3
-
#move_toward(to : Vector3, delta : Number) : Vector3
Moves this vector toward to by the given delta amount, never exceeding to.
- #normalized : Vector3
-
#project(b : Vector3) : Vector3
Projects this vector onto vector b.
-
#reflect(normal : Vector3) : Vector3
Returns a new vector reflected from a plane defined by the given normal.
-
#rotated(axis : Vector3, angle : Number) : Vector3
Rotates this vector around the given axis by the given angle in radians.
- #round : Vector3
- #sign : Vector3
-
#signed_angle_to(to : Vector3, axis : Vector3) : Float32
Returns the signed angle in radians between this vector and other with respect to the given axis.
-
#slerp(to : Vector3, weight : Number) : Vector3
Spherically interpolates between this vector and to by weight.
-
#slide(normal : Vector3) : Vector3
Returns a new vector slid along a plane defined by the given normal vector.
- #to_i : Vector3i
-
#to_s(io : IO) : Void
Same as
#inspect(io). - #x : Float32
- #x=(x : Float32)
- #xy : Vector2
- #xz : Vector2
- #y : Float32
- #y=(y : Float32)
- #yz : Vector2
- #z : Float32
- #z=(z : Float32)
Constructor Detail
Instance Method Detail
Returns the unsigned angle in radians between this vector and other.
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 around the given axis by the given angle in radians. Uses Rodrigues' rotation formula.
Returns the signed angle in radians between this vector and other with respect to the given axis.
Spherically interpolates between this vector and to by weight.
Returns a new vector slid along a plane defined by the given normal vector. Normal must be normalized.