evec

package
v1.4.31 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: BSD-3-Clause Imports: 4 Imported by: 43

README

Docs: GoDoc

Package evec has vector types for emergent, including Vec2i which is a 2D vector with int values, using the API based on mat32.Vec2i. This is distinct from mat32.Vec2i because it uses int instead of int32, and the int is significantly easier to deal with for layer sizing params etc.

Documentation

Overview

Package evec has vector types for emergent, including Vec2i which is a 2D vector with int values, using the API based on mat32.Vec2i. This is distinct from mat32.Vec2i because it uses int instead of int32, and the int is significantly easier to deal with for layer sizing params etc.

Index

Constants

This section is empty.

Variables

View Source
var KiT_Dims = kit.Enums.AddEnum(DimsN, kit.NotBitFlag, nil)

Functions

func Max32i

func Max32i(a, b int) int

Max32i returns the max of the two int numbers.

func Min32i

func Min32i(a, b int) int

Min32i returns the min of the two int numbers.

Types

type Dims

type Dims int

Dims is a list of vector dimension (component) names

const (
	X Dims = iota
	Y
	Z
	W
	DimsN
)

func (*Dims) FromString

func (i *Dims) FromString(s string) error

func (Dims) String

func (i Dims) String() string

type Vec2i

type Vec2i struct {
	X int
	Y int
}

Vec2i is a 2D vector/point with X and Y int components.

func NewVec2i

func NewVec2i(x, y int) Vec2i

NewVec2i returns a new Vec2i with the specified x and y components.

func NewVec2iFmVec2Ceil added in v1.1.22

func NewVec2iFmVec2Ceil(v mat32.Vec2) Vec2i

NewVec2iFmVec2Ceil converts from floating point mat32.Vec2 vector to int, using ceil

func NewVec2iFmVec2Floor added in v1.1.22

func NewVec2iFmVec2Floor(v mat32.Vec2) Vec2i

NewVec2iFmVec2Floor converts from floating point mat32.Vec2 vector to int, using floor

func NewVec2iFmVec2Round added in v1.1.22

func NewVec2iFmVec2Round(v mat32.Vec2) Vec2i

NewVec2iFmVec2Round converts from floating point mat32.Vec2 vector to int, using rounding

func NewVec2iScalar

func NewVec2iScalar(s int) Vec2i

NewVec2iScalar returns a new Vec2i with all components set to scalar.

func (Vec2i) Add

func (v Vec2i) Add(other Vec2i) Vec2i

Add adds other vector to this one and returns result in a new vector.

func (Vec2i) AddScalar

func (v Vec2i) AddScalar(s int) Vec2i

AddScalar adds scalar s to each component of this vector and returns new vector.

func (*Vec2i) Clamp

func (v *Vec2i) Clamp(min, max Vec2i)

Clamp sets this vector components to be no less than the corresponding components of min and not greater than the corresponding component of max. Assumes min < max, if this assumption isn't true it will not operate correctly.

func (*Vec2i) ClampScalar

func (v *Vec2i) ClampScalar(minVal, maxVal int)

ClampScalar sets this vector components to be no less than minVal and not greater than maxVal.

func (Vec2i) Dim

func (v Vec2i) Dim(dim Dims) int

Dim returns this vector component

func (Vec2i) Div

func (v Vec2i) Div(other Vec2i) Vec2i

Div divides each component of this vector by the corresponding one from other vector and returns resulting vector.

func (Vec2i) DivScalar

func (v Vec2i) DivScalar(scalar int) Vec2i

DivScalar divides each component of this vector by the scalar s and returns resulting vector. If scalar is zero, returns zero.

func (*Vec2i) FromArray

func (v *Vec2i) FromArray(array []int, offset int)

FromArray sets this vector's components from the specified array and offset.

func (Vec2i) IsEqual

func (v Vec2i) IsEqual(other Vec2i) bool

IsEqual returns if this vector is equal to other.

func (Vec2i) IsNil

func (v Vec2i) IsNil() bool

IsNil returns true if all values are 0 (uninitialized).

func (Vec2i) Max

func (v Vec2i) Max(other Vec2i) Vec2i

Max returns max of this vector components vs. other vector.

func (Vec2i) Min

func (v Vec2i) Min(other Vec2i) Vec2i

Min returns min of this vector components vs. other vector.

func (Vec2i) Mul

func (v Vec2i) Mul(other Vec2i) Vec2i

Mul multiplies each component of this vector by the corresponding one from other and returns resulting vector.

func (Vec2i) MulScalar

func (v Vec2i) MulScalar(s int) Vec2i

MulScalar multiplies each component of this vector by the scalar s and returns resulting vector.

func (Vec2i) Negate

func (v Vec2i) Negate() Vec2i

Negate returns vector with each component negated.

func (*Vec2i) Set

func (v *Vec2i) Set(x, y int)

Set sets this vector X and Y components.

func (*Vec2i) SetAdd

func (v *Vec2i) SetAdd(other Vec2i)

SetAdd sets this to addition with other vector (i.e., += or plus-equals).

func (*Vec2i) SetAddScalar

func (v *Vec2i) SetAddScalar(s int)

SetAddScalar sets this to addition with scalar.

func (*Vec2i) SetByName

func (v *Vec2i) SetByName(name string, value int)

SetByName sets this vector component value by its case insensitive name: "x" or "y".

func (*Vec2i) SetDim

func (v *Vec2i) SetDim(dim Dims, value int)

SetDim sets this vector component value by its dimension index

func (*Vec2i) SetDiv

func (v *Vec2i) SetDiv(other Vec2i)

SetDiv sets this to division by other vector (i.e., /= or divide-equals).

func (*Vec2i) SetDivScalar

func (v *Vec2i) SetDivScalar(s int)

SetDivScalar sets this to division by scalar.

func (*Vec2i) SetMax

func (v *Vec2i) SetMax(other Vec2i)

SetMax sets this vector components to the maximum value of itself and other vector.

func (*Vec2i) SetMin

func (v *Vec2i) SetMin(other Vec2i)

SetMin sets this vector components to the minimum values of itself and other vector.

func (*Vec2i) SetMul

func (v *Vec2i) SetMul(other Vec2i)

SetMul sets this to multiplication with other vector (i.e., *= or times-equals).

func (*Vec2i) SetMulScalar

func (v *Vec2i) SetMulScalar(s int)

SetMulScalar sets this to multiplication by scalar.

func (*Vec2i) SetNegate

func (v *Vec2i) SetNegate()

SetNegate negates each of this vector's components.

func (*Vec2i) SetScalar

func (v *Vec2i) SetScalar(s int)

SetScalar sets all vector components to same scalar value.

func (*Vec2i) SetSub

func (v *Vec2i) SetSub(other Vec2i)

SetSub sets this to subtraction with other vector (i.e., -= or minus-equals).

func (*Vec2i) SetSubScalar

func (v *Vec2i) SetSubScalar(s int)

SetSubScalar sets this to subtraction of scalar.

func (*Vec2i) SetZero

func (v *Vec2i) SetZero()

SetZero sets this vector X and Y components to be zero.

func (Vec2i) Sub

func (v Vec2i) Sub(other Vec2i) Vec2i

Sub subtracts other vector from this one and returns result in new vector.

func (Vec2i) SubScalar

func (v Vec2i) SubScalar(s int) Vec2i

SubScalar subtracts scalar s from each component of this vector and returns new vector.

func (Vec2i) ToArray

func (v Vec2i) ToArray(array []int, offset int)

ToArray copies this vector's components to array starting at offset.

func (Vec2i) ToVec2 added in v1.1.22

func (v Vec2i) ToVec2() mat32.Vec2

ToVec2 returns floating point mat32.Vec2 from int

Jump to

Keyboard shortcuts

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