Skip to content

math.vec #

Constants #

const vec_epsilon = f32(10e-7)

fn vec2 #

fn vec2[T](x T, y T) Vec2[T]

vec2[T] returns a Vec2 of type T, with x and y fields set.

fn vec3 #

fn vec3[T](x T, y T, z T) Vec3[T]

vec3[T] returns a Vec3 of type T, with x,y and z fields set.

fn vec4 #

fn vec4[T](x T, y T, z T, w T) Vec4[T]

vec4[T] returns a Vec4 of type T, with x,y,z and w fields set.

fn (Vec2[T]) zero #

fn (mut v Vec2[T]) zero()

zero sets the x and y fields to 0.

fn (Vec2[T]) one #

fn (mut v Vec2[T]) one()

one sets the x and y fields to 1.

fn (Vec2[T]) copy #

fn (v Vec2[T]) copy() Vec2[T]

copy returns a copy of this vector.

fn (Vec2[T]) from #

fn (mut v Vec2[T]) from(u Vec2[T])

from sets the x and y fields from u.

fn (Vec2[T]) from_vec3 #

fn (mut v Vec2[T]) from_vec3[U](u Vec3[U])

from_vec3 sets the x and y fields from u.

fn (Vec2[T]) as_vec3 #

fn (v Vec2[T]) as_vec3[T]() Vec3[T]

as_vec3 returns a Vec3 with x and y fields set from v, z is set to 0.

fn (Vec2[T]) from_vec4 #

fn (mut v Vec2[T]) from_vec4[U](u Vec4[U])

from_vec4 sets the x and y fields from u.

fn (Vec2[T]) as_vec4 #

fn (v Vec2[T]) as_vec4[T]() Vec4[T]

as_vec4 returns a Vec4 with x and y fields set from v, z and w is set to 0.

fn (Vec2[T]) + #

fn (v Vec2[T]) + (u Vec2[T]) Vec2[T]
  • returns the resulting vector of the addition of v and u.

fn (Vec2[T]) add #

fn (v Vec2[T]) add(u Vec2[T]) Vec2[T]

add returns the resulting vector of the addition of v + u.

fn (Vec2[T]) add_scalar #

fn (v Vec2[T]) add_scalar[U](scalar U) Vec2[T]

add_scalar returns the resulting vector of the addition of the scalar value.

fn (Vec2[T]) plus #

fn (mut v Vec2[T]) plus(u Vec2[T])

plus adds vector u to the vector.

fn (Vec2[T]) plus_scalar #

fn (mut v Vec2[T]) plus_scalar[U](scalar U)

plus_scalar adds the scalar scalar to the vector.

fn (Vec2[T]) - #

fn (v Vec2[T]) - (u Vec2[T]) Vec2[T]
  • returns the resulting vector of the subtraction of v and u.

fn (Vec2[T]) sub #

fn (v Vec2[T]) sub(u Vec2[T]) Vec2[T]

sub returns the resulting vector of the subtraction of v - u.

fn (Vec2[T]) sub_scalar #

fn (v Vec2[T]) sub_scalar[U](scalar U) Vec2[T]

sub_scalar returns the resulting vector of the subtraction of the scalar value.

fn (Vec2[T]) subtract #

fn (mut v Vec2[T]) subtract(u Vec2[T])

subtract subtracts vector u from the vector.

fn (Vec2[T]) subtract_scalar #

fn (mut v Vec2[T]) subtract_scalar[U](scalar U)

subtract_scalar subtracts the scalar scalar from the vector.

fn (Vec2[T]) * #

fn (v Vec2[T]) * (u Vec2[T]) Vec2[T]
  • returns the resulting vector of the multiplication of v and u.

fn (Vec2[T]) mul #

fn (v Vec2[T]) mul(u Vec2[T]) Vec2[T]

mul returns the resulting vector of the multiplication of v * u.

fn (Vec2[T]) mul_scalar #

fn (v Vec2[T]) mul_scalar[U](scalar U) Vec2[T]

mul_scalar returns the resulting vector of the multiplication of the scalar value.

fn (Vec2[T]) multiply #

fn (mut v Vec2[T]) multiply(u Vec2[T])

multiply multiplies the vector with u.

fn (Vec2[T]) multiply_scalar #

fn (mut v Vec2[T]) multiply_scalar[U](scalar U)

multiply_scalar multiplies the vector with scalar.

fn (Vec2[T]) / #

fn (v Vec2[T]) / (u Vec2[T]) Vec2[T]

/ returns the resulting vector of the division of v and u.

fn (Vec2[T]) div #

fn (v Vec2[T]) div(u Vec2[T]) Vec2[T]

div returns the resulting vector of the division of v / u.

fn (Vec2[T]) div_scalar #

fn (v Vec2[T]) div_scalar[U](scalar U) Vec2[T]

div_scalar returns the resulting vector of the division by the scalar value.

fn (Vec2[T]) divide #

fn (mut v Vec2[T]) divide(u Vec2[T])

divide divides the vector by u.

fn (Vec2[T]) divide_scalar #

fn (mut v Vec2[T]) divide_scalar[U](scalar U)

divide_scalar divides the vector by scalar.

fn (Vec2[T]) magnitude #

fn (v Vec2[T]) magnitude() T

magnitude returns the magnitude, also known as the length, of the vector.

fn (Vec2[T]) magnitude_x #

fn (v Vec2[T]) magnitude_x() T

magnitude_x returns the magnitude, also known as the length, of the 1D vector field x, y is ignored.

fn (Vec2[T]) magnitude_y #

fn (v Vec2[T]) magnitude_y() T

magnitude_x returns the magnitude, also known as the length, of the 1D vector field y, x is ignored.

fn (Vec2[T]) dot #

fn (v Vec2[T]) dot(u Vec2[T]) T

dot returns the dot product of v and u.

fn (Vec2[T]) cross #

fn (v Vec2[T]) cross(u Vec2[T]) T

cross returns the cross product of v and u.

fn (Vec2[T]) unit #

fn (v Vec2[T]) unit() Vec2[T]

unit returns the unit vector. unit vectors always have a magnitude, or length, of exactly 1.

fn (Vec2[T]) perp_cw #

fn (v Vec2[T]) perp_cw() Vec2[T]

perp_cw returns the clockwise, or "left-hand", perpendicular vector of this vector.

fn (Vec2[T]) perp_ccw #

fn (v Vec2[T]) perp_ccw() Vec2[T]

perp_ccw returns the counter-clockwise, or "right-hand", perpendicular vector of this vector.

fn (Vec2[T]) perpendicular #

fn (v Vec2[T]) perpendicular(u Vec2[T]) Vec2[T]

perpendicular returns the u projected perpendicular vector to this vector.

fn (Vec2[T]) project #

fn (v Vec2[T]) project(u Vec2[T]) Vec2[T]

project returns the projected vector.

fn (Vec2[T]) eq #

fn (v Vec2[T]) eq(u Vec2[T]) bool

eq returns a bool indicating if the two vectors are equal.

fn (Vec2[T]) eq_epsilon #

fn (v Vec2[T]) eq_epsilon(u Vec2[T]) bool

eq_epsilon returns a bool indicating if the two vectors are equal within the module vec_epsilon const.

fn (Vec2[T]) eq_approx #

fn (v Vec2[T]) eq_approx[T, U](u Vec2[T], tolerance U) bool

eq_approx returns whether these vectors are approximately equal within tolerance.

fn (Vec2[T]) is_approx_zero #

fn (v Vec2[T]) is_approx_zero(tolerance T) bool

is_approx_zero returns whether this vector is equal to zero within tolerance.

fn (Vec2[T]) eq_scalar #

fn (v Vec2[T]) eq_scalar[U](scalar U) bool

eq_scalar returns a bool indicating if the x and y fields both equals scalar.

fn (Vec2[T]) distance #

fn (v Vec2[T]) distance(u Vec2[T]) T

distance returns the distance to the vector u.

fn (Vec2[T]) manhattan_distance #

fn (v Vec2[T]) manhattan_distance(u Vec2[T]) T

manhattan_distance returns the Manhattan Distance to the vector u.

fn (Vec2[T]) angle_between #

fn (v Vec2[T]) angle_between(u Vec2[T]) T

angle_between returns the angle in radians to the vector u.

fn (Vec2[T]) angle_towards #

fn (p1 Vec2[T]) angle_towards(p2 Vec2[T]) T

angle_towards returns the angle in radians between the horizontal axis, and a line passing through the first and second point, as if the first point was at the center of the coordinate system.

fn (Vec2[T]) angle #

fn (v Vec2[T]) angle() T

angle returns the angle in radians of the vector.

fn (Vec2[T]) abs #

fn (mut v Vec2[T]) abs()

abs sets x and y field values to their absolute values.

fn (Vec2[T]) clean #

fn (v Vec2[T]) clean[U](tolerance U) Vec2[T]

clean returns a vector with all fields of this vector set to zero (0) if they fall within tolerance.

fn (Vec2[T]) clean_tolerance #

fn (mut v Vec2[T]) clean_tolerance[U](tolerance U)

clean_tolerance sets all fields to zero (0) if they fall within tolerance.

fn (Vec2[T]) inv #

fn (v Vec2[T]) inv() Vec2[T]

inv returns the inverse, or reciprocal, of the vector.

fn (Vec2[T]) normalize #

fn (v Vec2[T]) normalize() Vec2[T]

normalize normalizes the vector.

fn (Vec2[T]) sum #

fn (v Vec2[T]) sum() T

sum returns a sum of all the fields.

fn (Vec3[T]) zero #

fn (mut v Vec3[T]) zero()

zero sets the x,y and z fields to 0.

fn (Vec3[T]) one #

fn (mut v Vec3[T]) one()

one sets the x,y and z fields to 1.

fn (Vec3[T]) copy #

fn (mut v Vec3[T]) copy() Vec3[T]

copy returns a copy of this vector.

fn (Vec3[T]) from #

fn (mut v Vec3[T]) from(u Vec3[T])

from sets the x,y and z fields from u.

fn (Vec3[T]) from_vec2 #

fn (mut v Vec3[T]) from_vec2[U](u Vec2[U])

from_vec2 sets the x and y fields from u.

fn (Vec3[T]) as_vec2 #

fn (mut v Vec3[T]) as_vec2[T]() Vec2[T]

as_vec2 returns a Vec2 with x and y fields set from v.

fn (Vec3[T]) from_vec4 #

fn (mut v Vec3[T]) from_vec4[U](u Vec4[U])

from_vec4 sets the x,y and z fields from u.

fn (Vec3[T]) as_vec4 #

fn (mut v Vec3[T]) as_vec4[T]() Vec4[T]

as_vec4 returns a Vec4 with x,y and z fields set from v, w is set to 0.

fn (Vec3[T]) + #

fn (v Vec3[T]) + (u Vec3[T]) Vec3[T]
  • returns the resulting vector of the addition of v and u.

fn (Vec3[T]) add #

fn (v Vec3[T]) add(u Vec3[T]) Vec3[T]

add returns the resulting vector of the addition of v + u.

fn (Vec3[T]) add_vec2 #

fn (v Vec3[T]) add_vec2[U](u Vec2[U]) Vec3[T]

add_vec2 returns the resulting vector of the addition of the x and y fields of u, z is left untouched.

fn (Vec3[T]) add_scalar #

fn (v Vec3[T]) add_scalar[U](scalar U) Vec3[T]

add_scalar returns the resulting vector of the addition of the scalar value.

fn (Vec3[T]) plus #

fn (mut v Vec3[T]) plus(u Vec3[T])

plus adds vector u to the vector.

fn (Vec3[T]) plus_vec2 #

fn (mut v Vec3[T]) plus_vec2[U](u Vec2[U])

plus_vec2 adds x and y fields of vector u to the vector, z is left untouched.

fn (Vec3[T]) plus_scalar #

fn (mut v Vec3[T]) plus_scalar[U](scalar U)

plus_scalar adds the scalar scalar to the vector.

fn (Vec3[T]) - #

fn (v Vec3[T]) - (u Vec3[T]) Vec3[T]
  • returns the resulting vector of the subtraction of v and u.

fn (Vec3[T]) sub #

fn (v Vec3[T]) sub(u Vec3[T]) Vec3[T]

sub returns the resulting vector of the subtraction of v - u.

fn (Vec3[T]) sub_scalar #

fn (v Vec3[T]) sub_scalar[U](scalar U) Vec3[T]

sub_scalar returns the resulting vector of the subtraction of the scalar value.

fn (Vec3[T]) subtract #

fn (mut v Vec3[T]) subtract(u Vec3[T])

subtract subtracts vector u from the vector.

fn (Vec3[T]) subtract_scalar #

fn (mut v Vec3[T]) subtract_scalar[U](scalar U)

subtract_scalar subtracts the scalar scalar from the vector.

fn (Vec3[T]) * #

fn (v Vec3[T]) * (u Vec3[T]) Vec3[T]
  • returns the resulting vector of the multiplication of v and u.

fn (Vec3[T]) mul #

fn (v Vec3[T]) mul(u Vec3[T]) Vec3[T]

mul returns the resulting vector of the multiplication of v * u.

fn (Vec3[T]) mul_scalar #

fn (v Vec3[T]) mul_scalar[U](scalar U) Vec3[T]

mul_scalar returns the resulting vector of the multiplication of the scalar value.

fn (Vec3[T]) multiply #

fn (mut v Vec3[T]) multiply(u Vec3[T])

multiply multiplies the vector with u.

fn (Vec3[T]) multiply_scalar #

fn (mut v Vec3[T]) multiply_scalar[U](scalar U)

multiply_scalar multiplies the vector with scalar.

fn (Vec3[T]) / #

fn (v Vec3[T]) / (u Vec3[T]) Vec3[T]

/ returns the resulting vector of the division of v and u.

fn (Vec3[T]) div #

fn (v Vec3[T]) div(u Vec3[T]) Vec3[T]

div returns the resulting vector of the division of v / u.

fn (Vec3[T]) div_scalar #

fn (v Vec3[T]) div_scalar[U](scalar U) Vec3[T]

div_scalar returns the resulting vector of the division by the scalar value.

fn (Vec3[T]) divide #

fn (mut v Vec3[T]) divide(u Vec3[T])

divide divides the vector by u.

fn (Vec3[T]) divide_scalar #

fn (mut v Vec3[T]) divide_scalar[U](scalar U)

divide_scalar divides the vector by scalar.

fn (Vec3[T]) magnitude #

fn (v Vec3[T]) magnitude() T

magnitude returns the magnitude, also known as the length, of the vector.

fn (Vec3[T]) dot #

fn (v Vec3[T]) dot(u Vec3[T]) T

dot returns the dot product of v and u.

fn (Vec3[T]) cross #

fn (v Vec3[T]) cross(u Vec3[T]) Vec3[T]

cross returns the cross product of v and u.

fn (Vec3[T]) unit #

fn (v Vec3[T]) unit() Vec3[T]

unit returns the unit vector. unit vectors always have a magnitude, or length, of exactly 1.

fn (Vec3[T]) perpendicular #

fn (v Vec3[T]) perpendicular(u Vec3[T]) Vec3[T]

perpendicular returns the u projected perpendicular vector to this vector.

fn (Vec3[T]) project #

fn (v Vec3[T]) project(u Vec3[T]) Vec3[T]

project returns the projected vector.

fn (Vec3[T]) eq #

fn (v Vec3[T]) eq(u Vec3[T]) bool

eq returns a bool indicating if the two vectors are equal.

fn (Vec3[T]) eq_epsilon #

fn (v Vec3[T]) eq_epsilon(u Vec3[T]) bool

eq_epsilon returns a bool indicating if the two vectors are equal within the module vec_epsilon const.

fn (Vec3[T]) eq_approx #

fn (v Vec3[T]) eq_approx[T, U](u Vec3[T], tolerance U) bool

eq_approx returns whether these vectors are approximately equal within tolerance.

fn (Vec3[T]) is_approx_zero #

fn (v Vec3[T]) is_approx_zero(tolerance f64) bool

is_approx_zero returns whether this vector is equal to zero within tolerance.

fn (Vec3[T]) eq_scalar #

fn (v Vec3[T]) eq_scalar[U](scalar U) bool

eq_scalar returns a bool indicating if the x,y and z fields all equals scalar.

fn (Vec3[T]) distance #

fn (v Vec3[T]) distance(u Vec3[T]) f64

distance returns the distance to the vector u.

fn (Vec3[T]) manhattan_distance #

fn (v Vec3[T]) manhattan_distance(u Vec3[T]) f64

manhattan_distance returns the Manhattan distance to the vector u.

fn (Vec3[T]) angle_between #

fn (v Vec3[T]) angle_between(u Vec3[T]) T

angle_between returns the angle in radians to the vector u.

fn (Vec3[T]) abs #

fn (mut v Vec3[T]) abs()

abs sets x, y and z field values to their absolute values.

fn (Vec3[T]) clean #

fn (v Vec3[T]) clean[U](tolerance U) Vec3[T]

clean returns a vector with all fields of this vector set to zero (0) if they fall within tolerance.

fn (Vec3[T]) clean_tolerance #

fn (mut v Vec3[T]) clean_tolerance[U](tolerance U)

clean_tolerance sets all fields to zero (0) if they fall within tolerance.

fn (Vec3[T]) inv #

fn (v Vec3[T]) inv() Vec3[T]

inv returns the inverse, or reciprocal, of the vector.

fn (Vec3[T]) normalize #

fn (v Vec3[T]) normalize() Vec3[T]

normalize normalizes the vector.

fn (Vec3[T]) sum #

fn (v Vec3[T]) sum() T

sum returns a sum of all the fields.

fn (Vec4[T]) zero #

fn (mut v Vec4[T]) zero()

zero sets the x,y,z and w fields to 0.

fn (Vec4[T]) one #

fn (mut v Vec4[T]) one()

one sets the x,y,z and w fields to 1.

fn (Vec4[T]) copy #

fn (v Vec4[T]) copy() Vec4[T]

copy returns a copy of this vector.

fn (Vec4[T]) from #

fn (mut v Vec4[T]) from(u Vec4[T])

from sets the x,y,z and w fields from u.

fn (Vec4[T]) from_vec2 #

fn (mut v Vec4[T]) from_vec2(u Vec2[T])

from_vec2 sets the x and y fields from u.

fn (Vec4[T]) as_vec2 #

fn (v Vec4[T]) as_vec2[U]() Vec2[U]

as_vec2 returns a Vec2 with x and y fields set from v.

fn (Vec4[T]) from_vec3 #

fn (mut v Vec4[T]) from_vec3[U](u Vec3[U])

from_vec3 sets the x,y and z fields from u.

fn (Vec4[T]) as_vec3 #

fn (v Vec4[T]) as_vec3[U]() Vec3[U]

as_vec3 returns a Vec3 with x,y and z fields set from v.

fn (Vec4[T]) + #

fn (v Vec4[T]) + (u Vec4[T]) Vec4[T]
  • returns the resulting vector of the addition of v and u.

fn (Vec4[T]) add #

fn (v Vec4[T]) add(u Vec4[T]) Vec4[T]

add returns the resulting vector of the addition of v + u.

fn (Vec4[T]) add_vec2 #

fn (v Vec4[T]) add_vec2[U](u Vec2[U]) Vec4[T]

add_vec2 returns the resulting vector of the addition of the x and y fields of u, z is left untouched.

fn (Vec4[T]) add_vec3 #

fn (v Vec4[T]) add_vec3[U](u Vec3[U]) Vec4[T]

add_vec3 returns the resulting vector of the addition of the x,y and z fields of u, w is left untouched.

fn (Vec4[T]) add_scalar #

fn (v Vec4[T]) add_scalar[U](scalar U) Vec4[T]

add_scalar returns the resulting vector of the addition of the scalar value.

fn (Vec4[T]) plus #

fn (mut v Vec4[T]) plus(u Vec4[T])

plus adds vector u to the vector.

fn (Vec4[T]) plus_scalar #

fn (mut v Vec4[T]) plus_scalar[U](scalar U)

plus_scalar adds the scalar scalar to the vector.

fn (Vec4[T]) - #

fn (v Vec4[T]) - (u Vec4[T]) Vec4[T]
  • returns the resulting vector of the subtraction of v and u.

fn (Vec4[T]) sub #

fn (v Vec4[T]) sub(u Vec4[T]) Vec4[T]

sub returns the resulting vector of the subtraction of v - u.

fn (Vec4[T]) sub_scalar #

fn (v Vec4[T]) sub_scalar[U](scalar U) Vec4[T]

sub_scalar returns the resulting vector of the subtraction of the scalar value.

fn (Vec4[T]) subtract #

fn (mut v Vec4[T]) subtract(u Vec4[T])

subtract subtracts vector u from the vector.

fn (Vec4[T]) subtract_scalar #

fn (mut v Vec4[T]) subtract_scalar[U](scalar U)

subtract_scalar subtracts the scalar scalar from the vector.

fn (Vec4[T]) * #

fn (v Vec4[T]) * (u Vec4[T]) Vec4[T]
  • returns the resulting vector of the multiplication of v and u.

fn (Vec4[T]) mul #

fn (v Vec4[T]) mul(u Vec4[T]) Vec4[T]

mul returns the resulting vector of the multiplication of v * u.

fn (Vec4[T]) mul_scalar #

fn (v Vec4[T]) mul_scalar[U](scalar U) Vec4[T]

mul_scalar returns the resulting vector of the multiplication of the scalar value.

fn (Vec4[T]) multiply #

fn (mut v Vec4[T]) multiply(u Vec4[T])

multiply multiplies the vector with u.

fn (Vec4[T]) multiply_scalar #

fn (mut v Vec4[T]) multiply_scalar[U](scalar U)

multiply_scalar multiplies the vector with scalar.

fn (Vec4[T]) / #

fn (v Vec4[T]) / (u Vec4[T]) Vec4[T]

/ returns the resulting vector of the division of v and u.

fn (Vec4[T]) div #

fn (v Vec4[T]) div(u Vec4[T]) Vec4[T]

div returns the resulting vector of the division of v / u.

fn (Vec4[T]) div_scalar #

fn (v Vec4[T]) div_scalar[U](scalar U) Vec4[T]

div_scalar returns the resulting vector of the division by the scalar value.

fn (Vec4[T]) divide #

fn (mut v Vec4[T]) divide(u Vec4[T])

divide divides the vector by u.

fn (Vec4[T]) divide_scalar #

fn (mut v Vec4[T]) divide_scalar[U](scalar U)

divide_scalar divides the vector by scalar.

fn (Vec4[T]) magnitude #

fn (v Vec4[T]) magnitude() T

magnitude returns the magnitude, also known as the length, of the vector.

fn (Vec4[T]) dot #

fn (v Vec4[T]) dot(u Vec4[T]) T

dot returns the dot product of v and u.

fn (Vec4[T]) cross_xyz #

fn (v Vec4[T]) cross_xyz(u Vec4[T]) Vec4[T]

cross_xyz returns the cross product of v and u's x,y and z fields.

fn (Vec4[T]) unit #

fn (v Vec4[T]) unit() Vec4[T]

unit returns the unit vector. unit vectors always have a magnitude, or length, of exactly 1.

fn (Vec4[T]) perpendicular #

fn (v Vec4[T]) perpendicular(u Vec4[T]) Vec4[T]

perpendicular returns the u projected perpendicular vector to this vector.

fn (Vec4[T]) project #

fn (v Vec4[T]) project(u Vec4[T]) Vec4[T]

project returns the projected vector.

fn (Vec4[T]) eq #

fn (v Vec4[T]) eq(u Vec4[T]) bool

eq returns a bool indicating if the two vectors are equal.

fn (Vec4[T]) eq_epsilon #

fn (v Vec4[T]) eq_epsilon(u Vec4[T]) bool

eq_epsilon returns a bool indicating if the two vectors are equal within the module vec_epsilon const.

fn (Vec4[T]) eq_approx #

fn (v Vec4[T]) eq_approx[T, U](u Vec4[T], tolerance U) bool

eq_approx returns whether these vectors are approximately equal within tolerance.

fn (Vec4[T]) is_approx_zero #

fn (v Vec4[T]) is_approx_zero(tolerance f64) bool

is_approx_zero returns whether this vector is equal to zero within tolerance.

fn (Vec4[T]) eq_scalar #

fn (v Vec4[T]) eq_scalar[U](scalar U) bool

eq_scalar returns a bool indicating if the x,y,z and w fields all equals scalar.

fn (Vec4[T]) distance #

fn (v Vec4[T]) distance(u Vec4[T]) f64

distance returns the distance to the vector u.

fn (Vec4[T]) manhattan_distance #

fn (v Vec4[T]) manhattan_distance(u Vec4[T]) f64

manhattan_distance returns the Manhattan distance to the vector u.

fn (Vec4[T]) abs #

fn (mut v Vec4[T]) abs()

abs sets x, y, z and w field values to their absolute values.

fn (Vec4[T]) clean #

fn (v Vec4[T]) clean[U](tolerance U) Vec4[T]

clean returns a vector with all fields of this vector set to zero (0) if they fall within tolerance.

fn (Vec4[T]) clean_tolerance #

fn (mut v Vec4[T]) clean_tolerance[U](tolerance U)

clean_tolerance sets all fields to zero (0) if they fall within tolerance.

fn (Vec4[T]) inv #

fn (v Vec4[T]) inv() Vec4[T]

inv returns the inverse, or reciprocal, of the vector.

fn (Vec4[T]) normalize #

fn (v Vec4[T]) normalize() Vec4[T]

normalize normalizes the vector.

fn (Vec4[T]) sum #

fn (v Vec4[T]) sum() T

sum returns a sum of all the fields.

struct Vec2 #

struct Vec2[T] {
pub mut:
	x T
	y T
}

Vec2[T] is a generic struct representing a vector in 2D space.

struct Vec3 #

struct Vec3[T] {
pub mut:
	x T
	y T
	z T
}

Vec3[T] is a generic struct representing a vector in 3D space.

struct Vec4 #

struct Vec4[T] {
pub mut:
	x T
	y T
	z T
	w T
}

Vec4[T] is a generic struct representing a vector in 4D space.