f32

package
v0.0.0-...-6c7272e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package f32 is a basic math library for float32.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(v float32) float32

Abs returns the absolute of v.

func MaxOf

func MaxOf(a float32, b ...float32) float32

MaxOf returns the maximum value of all the arguments.

func MinOf

func MinOf(a float32, b ...float32) float32

MinOf returns the minimum value of all the arguments.

func Round

func Round(v float32) int

Round rounds v to the nearest integer. Examples:

Round(-0.9) = -1
Round(-0.1) = 0
Round(0.0) = 0
Round(0.1) = 0
Round(0.9) = 1

func Sqrt

func Sqrt(v float32) float32

Sqrt returns the square root of v.

Types

type Vec3

type Vec3 [3]float32

V3D is a three element vector of float32. The elements are in the order X, Y, Z.

func Add3D

func Add3D(a, b Vec3) Vec3

Add3D returns the element-wise addition of vector a and b.

func Cross3D

func Cross3D(a, b Vec3) Vec3

Cross3D returns the cross product of vector a and b.

func Sub3D

func Sub3D(a, b Vec3) Vec3

Sub3D returns the element-wise subtraction of vector b from a.

func (Vec3) Magnitude

func (v Vec3) Magnitude() float32

Magnitude returns the magnitude of the vector.

func (Vec3) Normalize

func (v Vec3) Normalize() Vec3

Normalize returns the normalized vector of v.

func (Vec3) Scale

func (v Vec3) Scale(s float32) Vec3

Scale returns the element-wise scaling of v with s.

func (Vec3) SqrMagnitude

func (v Vec3) SqrMagnitude() float32

SqrMagnitude returns the magnitude of the vector.

func (Vec3) W

func (v Vec3) W(w float32) Vec4

W returns a V4D with the first three elements set to v and the fourth set to w.

type Vec4

type Vec4 [4]float32

V4D is a four element vector of float32. The elements are in the order X, Y, Z, W.

func Add4D

func Add4D(a, b Vec4) Vec4

Add4D returns the element-wise addition of vector a and b.

func Sub4D

func Sub4D(a, b Vec4) Vec4

Sub4D returns the element-wise subtraction of vector b from a.

func (Vec4) Magnitude

func (v Vec4) Magnitude() float32

Magnitude returns the magnitude of the vector.

func (Vec4) Normalize

func (v Vec4) Normalize() Vec4

Normalize returns the normalized vector of v.

func (Vec4) Scale

func (v Vec4) Scale(s float32) Vec4

Scale returns the element-wise scaling of v with s.

func (Vec4) SqrMagnitude

func (v Vec4) SqrMagnitude() float32

SqrMagnitude returns the magnitude of the vector.

func (Vec4) XYZ

func (v Vec4) XYZ() Vec3

XYZ returns a V3D formed from first three elements of v.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL