struct Godot::Vector3

Overview

3-element structure that can be used to represent 3D coordinates or vectors with 32-bit floating point precision.

Defined in:

libgodot/types.cr

Constant 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

Instance Method Summary

Constructor Detail

def self.new(x : Float32 = 0.0_f32, y : Float32 = 0.0_f32, z : Float32 = 0.0_f32) #

[View source]
def self.new(x : Number, y : Number, z : Number) #

[View source]

Instance Method Detail

def *(scalar : Number) : Vector3 #

[View source]
def *(other : Vector3) : Vector3 #

[View source]
def +(other : Vector3) : Vector3 #

[View source]
def -(other : Vector3) : Vector3 #

[View source]
def - : Vector3 #

[View source]
def /(scalar : Number) : Vector3 #

[View source]
def /(other : Vector3) : Vector3 #

[View source]
def abs : Vector3 #

[View source]
def angle_to(to : Vector3) : Float32 #

Returns the unsigned angle in radians between this vector and other.


[View source]
def bounce(normal : Vector3) : Vector3 #

Returns a new vector bounced off a plane defined by the given normal.


[View source]
def ceil : Vector3 #

[View source]
def clamp(min : Vector3, max : Vector3) : Vector3 #

Clamps each component between min and max.


[View source]
def cross(other : Vector3) : Vector3 #

[View source]
def direction_to(other : Vector3) : Vector3 #

Returns the normalized direction from this vector toward other.


[View source]
def distance_squared_to(other : Vector3) : Float32 #

Returns the squared distance between this vector and other.


[View source]
def distance_to(other : Vector3) : Float32 #

Returns the distance between this vector and other.


[View source]
def dot(other : Vector3) : Float32 #

[View source]
def floor : Vector3 #

[View source]
def is_equal_approx(other : Vector3) : Bool #

[View source]
def is_normalized? : Bool #

[View source]
def is_zero_approx : Bool #

[View source]
def length : Float32 #

[View source]
def length_squared : Float32 #

[View source]
def lerp(to : Vector3, weight : Number) : Vector3 #

Linearly interpolates between this vector and to by weight.


[View source]
def limit_length(max_length : Number = 1.0) : Vector3 #

Clamps the vector's length to max_length.


[View source]
def max(other : Vector3) : Vector3 #

[View source]
def min(other : Vector3) : Vector3 #

[View source]
def move_toward(to : Vector3, delta : Number) : Vector3 #

Moves this vector toward to by the given delta amount, never exceeding to.


[View source]
def normalized : Vector3 #

[View source]
def project(b : Vector3) : Vector3 #

Projects this vector onto vector b.


[View source]
def reflect(normal : Vector3) : Vector3 #

Returns a new vector reflected from a plane defined by the given normal.


[View source]
def rotated(axis : Vector3, angle : Number) : Vector3 #

Rotates this vector around the given axis by the given angle in radians. Uses Rodrigues' rotation formula.


[View source]
def round : Vector3 #

[View source]
def sign : Vector3 #

[View source]
def 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.


[View source]
def slerp(to : Vector3, weight : Number) : Vector3 #

Spherically interpolates between this vector and to by weight.


[View source]
def slide(normal : Vector3) : Vector3 #

Returns a new vector slid along a plane defined by the given normal vector. Normal must be normalized.


[View source]
def to_i : Vector3i #

[View source]
def to_s(io : IO) : Void #
Description copied from struct Struct

Same as #inspect(io).


[View source]
def x : Float32 #

[View source]
def x=(x : Float32) #

[View source]
def xy : Vector2 #

[View source]
def xz : Vector2 #

[View source]
def y : Float32 #

[View source]
def y=(y : Float32) #

[View source]
def yz : Vector2 #

[View source]
def z : Float32 #

[View source]
def z=(z : Float32) #

[View source]