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/vector3.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)
MODEL_BOTTOM = Vector3.new(0.0_f32, -1.0_f32, 0.0_f32)
MODEL_FRONT = Vector3.new(0.0_f32, 0.0_f32, -1.0_f32)
MODEL_LEFT = Vector3.new(-1.0_f32, 0.0_f32, 0.0_f32)
MODEL_REAR = Vector3.new(0.0_f32, 0.0_f32, 1.0_f32)
MODEL_RIGHT = Vector3.new(1.0_f32, 0.0_f32, 0.0_f32)
MODEL_TOP = Vector3.new(0.0_f32, 1.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) #

def self.new(x : Number, y : Number, z : Number) #

def self.new(pointer : Pointer(Void)) #

Instance Method Detail

def !=(other : Vector3) : Bool #

def *(scalar : Number) : Vector3 #

def *(other : Vector3) : Vector3 #

def +(other : Vector3) : Vector3 #

def -(other : Vector3) : Vector3 #

def - : Vector3 #

def /(scalar : Number) : Vector3 #

def /(other : Vector3) : Vector3 #

def ==(other : Vector3) : Bool #

def abs : Vector3 #

def angle_to(to : Vector3) : Float32 #

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


def bezier_interpolate(control_1 : Vector3, control_2 : Vector3, end_point : Vector3, t : Number) : Vector3 #

Bezier interpolation through control points.


def bounce(normal : Vector3) : Vector3 #

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


def ceil : Vector3 #

def clamp(min : Vector3, max : Vector3) : Vector3 #

Clamps each component between min and max.


def clampf(min_val : Number, max_val : Number) : Vector3 #

Clamps each component between scalar min and max values.


def cross(other : Vector3) : Vector3 #

def cubic_interpolate(b : Vector3, pre_a : Vector3, post_b : Vector3, weight : Number) : Vector3 #

Cubic interpolation between two vectors using pre_a and post_b tangents.


def direction_to(other : Vector3) : Vector3 #

Returns the normalized direction from this vector toward other.


def distance_squared_to(other : Vector3) : Float32 #

Returns the squared distance between this vector and other.


def distance_to(other : Vector3) : Float32 #

Returns the distance between this vector and other.


def dot(other : Vector3) : Float32 #

def floor : Vector3 #

def is_equal_approx(other : Vector3) : Bool #

def is_finite? : Bool #

def is_normalized? : Bool #

def is_zero_approx : Bool #

def is_zero_approx? : Bool #

def length : Float32 #

def length_squared : Float32 #

def lerp(to : Vector3, weight : Number) : Vector3 #

Linearly interpolates between this vector and to by weight.


def limit_length(max_length : Number = 1.0) : Vector3 #

Clamps the vector's length to max_length.


def max(other : Vector3) : Vector3 #

def min(other : Vector3) : Vector3 #

def move_toward(to : Vector3, delta : Number) : Vector3 #

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


def normalized : Vector3 #

def posmod(mod_val : Number) : Vector3 #

Returns the vector with each component modulo scalar.


def project(b : Vector3) : Vector3 #

Projects this vector onto vector b.


def reflect(normal : Vector3) : Vector3 #

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


def rotated(axis : Vector3, angle : Number) : Vector3 #

Rotates this vector around the given axis by the given angle in radians.


def round : Vector3 #

def sign : Vector3 #

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.


def slerp(to : Vector3, weight : Number) : Vector3 #

Spherically interpolates between this vector and to by weight.


def slide(normal : Vector3) : Vector3 #

Returns a new vector slid along a plane defined by the given normal vector.


def snapped(step : Vector3) : Vector3 #

Snaps vector components to nearest multiple of step.


def to_i : Vector3i #

def to_s(io : IO) : Void #
Description copied from struct Struct

Same as #inspect(io).


def x : Float32 #

def x=(x : Float32) #

def xy : Vector2 #

def xz : Vector2 #

def y : Float32 #

def y=(y : Float32) #

def yz : Vector2 #

def z : Float32 #

def z=(z : Float32) #