math

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: MIT Imports: 5 Imported by: 0

README

Math

Primitive math utilities to be used by the remaining of the library. Math imports nothing, everything else imports it. There is a slight hierarchy to the sub-packages found in math.

Sample

Sample serves as a group of definitions for defining a mapping from one numeric value to another. Another term for this is "function" or "mapping" but golang already took both of those keywords so I settled on "sample". Code throughout polyform uses the definitions like sample.FloatToVec2 to indicate this method maps a float to a Vector 2 value.

There are also some general utility functions for building common mappings between two domains of numbers.

  • Compose - Takes an array of sample functions and feeds the output value from one function into the input value to the next function before finally returning the final value.
    • ComposeFloat
    • ComposeVec2
    • ComposeVec3
  • LinearMapping - Remaps some float value between A and B to sample a line in N-Dimensional space linearly.
    • LinearFloatMapping
    • LinearVector2Mapping
    • LinearVector3Mapping
  • Trig
    • Sin - Maps a float value to a sin wave with some specified amplitude and frequency.
    • Cos - Maps a float value to a sin wave with some specified amplitude and frequency.

Curves

Curves builds off of the sample package. The one restriction it makes is that the input domain is restricted to float values between 0 and 1. This is where more common animation curves reside.

Noise

Different noise algorithms commonly used in procedural generation.

SDF

SDF implementations of different geometry primitives, along with common math functions. Basically slowly picking through Inigo Quilez's Distfunction article as I need them in my different projects.

TRS

Math around Translation / Rotation / Scale Matrices

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddNode added in v0.23.0

type AddNode = nodes.Struct[AddNodeData]

type AddNodeData added in v0.23.0

type AddNodeData struct {
	A nodes.Output[float64]
	B nodes.Output[float64]
}

func (AddNodeData) Out added in v0.23.0

type DifferenceNode

type DifferenceNode = nodes.Struct[DifferenceNodeData[float64]]

============================================================================

type DifferenceNodeData added in v0.23.0

type DifferenceNodeData[T vector.Number] struct {
	A nodes.Output[T]
	B nodes.Output[T]
}

func (DifferenceNodeData[T]) Out added in v0.23.0

func (cn DifferenceNodeData[T]) Out() nodes.StructOutput[T]

type DivideNode

type DivideNode = nodes.Struct[DivideNodeData[float64]]

============================================================================

type DivideNodeData added in v0.23.0

type DivideNodeData[T vector.Number] struct {
	Dividend nodes.Output[T]
	Divisor  nodes.Output[T]
}

func (DivideNodeData[T]) Description added in v0.23.0

func (DivideNodeData[T]) Description() string

func (DivideNodeData[T]) Out added in v0.23.0

func (cn DivideNodeData[T]) Out() nodes.StructOutput[T]

type Multiply

type Multiply = nodes.Struct[MultiplyNodeData[float64]]

============================================================================

type MultiplyNodeData added in v0.23.0

type MultiplyNodeData[T vector.Number] struct {
	A nodes.Output[T]
	B nodes.Output[T]
}

func (MultiplyNodeData[T]) Out added in v0.23.0

func (cn MultiplyNodeData[T]) Out() nodes.StructOutput[T]

type Round

type Round = nodes.Struct[RoundNodeData]

type RoundNodeData added in v0.23.0

type RoundNodeData struct {
	In nodes.Output[float64]
}

func (RoundNodeData) Float added in v0.23.0

func (RoundNodeData) Int added in v0.23.0

func (cn RoundNodeData) Int() nodes.StructOutput[int]

type SumNode

type SumNode = nodes.Struct[SumNodeData[float64]]

============================================================================

type SumNodeData added in v0.23.0

type SumNodeData[T vector.Number] struct {
	Values []nodes.Output[T]
}

func (SumNodeData[T]) Out added in v0.23.0

func (cn SumNodeData[T]) Out() nodes.StructOutput[T]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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