f64

package
v3.3.0+incompatible Latest Latest
Warning

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

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

Documentation

Overview

Package f64 is a basic math library for float64.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromBits

func FromBits(val uint64, expBits, manBits uint32) float64

FromBits takes binary representation of floating-point value with user-defined bit sizes and expands it to full float64.

func MaxOf

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

MaxOf returns the maximum value of all the arguments.

func MinOf

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

MinOf returns the minimum value of all the arguments.

func Round

func Round(v float64) 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

Types

type Vec3

type Vec3 [3]float64

V3D is a three element vector of float64. 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() float64

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 float64) Vec3

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

func (Vec3) SqrMagnitude

func (v Vec3) SqrMagnitude() float64

SqrMagnitude returns the magnitude of the vector.

func (Vec3) W

func (v Vec3) W(w float64) Vec4

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

type Vec4

type Vec4 [4]float64

V4D is a four element vector of float64. 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() float64

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 float64) Vec4

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

func (Vec4) SqrMagnitude

func (v Vec4) SqrMagnitude() float64

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