Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
Hamolicious edited this page Jul 5, 2021 · 3 revisions

A 3 dimensional vector data structure. I highly recommend reading the instantiation page before anything else to get an understanding of what *args will take

Properties

Property Description
x the 0th element of the vector
y the 1st element of the vector
z the 2nd element of the vector
w same as x
h same as y
d same as z
r same as x
g same as y
b same as z
length calculates and returns the magnitude of the vector

Methods

Method Description
__init__(*args) Have a look at the instantiation page
random_unit() Static method, returns a vector where x, y and z are between -1 and 1
random_pos() Static method, returns a vector where x, y and z are between 0 and 1
zero() Static method, returns a zero vector, same as instantiating an empty vector Vec3d()
get() returns all elements as a list in float form
get_int() returns all elements as a list in integer form
set(*args) same as __init__(*args)
copy() returns a copy of the vector
clear() sets all elements to 0
dist_sqrt(*args) returns the distance to the passed in vector (uses sqrt)
cross_product(*args) calculate the Cross Product of 2 vectors
dist(*args) returns the distance squared to the passed in vector (does not use sqrt so will be much faster)
get_magnitude() same as length
normalise() normalises the vector in place
clamp(*args) clamps each element to the passed in value
add(*args) adds each element with the passed in elements
sub(*args) subtracts each element with the passed in elements
mult(*args) multiplies each element with the passed in elements
div(*args) divides each element with the passed in elements
linear_interpolate(*args, t=0.5) linearly interpolates the vector to the passed in values
dot_product(*args) returns the dot product to the passed in values
rotate_x(a) rotates the vector around the origin (0, 0, 0) by a radians degrees
rotate_y(a) rotates the vector around the origin (0, 0, 0) by a radians degrees
rotate_z(a) rotates the vector around the origin (0, 0, 0) by a radians degrees
Clone this wiki locally