evec

package
v2.0.0-dev0.0.14 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: BSD-3-Clause Imports: 3 Imported by: 1

README

Docs: GoDoc

Package evec has vector types for emergent, including Vector2i which is a 2D vector with int values, using the API based on math32.Vector2i. This is distinct from math32.Vector2i 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 Vector2i which is a 2D vector with int values, using the API based on math32.Vector2i. This is distinct from math32.Vector2i 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

This section is empty.

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 int32 //enums:enum

Dims is a list of vector dimension (component) names

const (
	X Dims = iota
	Y
	Z
	W
)
const DimsN Dims = 4

DimsN is the highest valid value for type Dims, plus one.

func DimsValues

func DimsValues() []Dims

DimsValues returns all possible values for the type Dims.

func (Dims) Desc

func (i Dims) Desc() string

Desc returns the description of the Dims value.

func (Dims) Int64

func (i Dims) Int64() int64

Int64 returns the Dims value as an int64.

func (Dims) MarshalText

func (i Dims) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*Dims) SetInt64

func (i *Dims) SetInt64(in int64)

SetInt64 sets the Dims value from an int64.

func (*Dims) SetString

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

SetString sets the Dims value from its string representation, and returns an error if the string is invalid.

func (Dims) String

func (i Dims) String() string

String returns the string representation of this Dims value.

func (*Dims) UnmarshalText

func (i *Dims) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (Dims) Values

func (i Dims) Values() []enums.Enum

Values returns all possible values for the type Dims.

type Vector2i

type Vector2i struct {
	X int
	Y int
}

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

func NewVector2i

func NewVector2i(x, y int) Vector2i

NewVector2i returns a new Vector2i with the specified x and y components.

func NewVector2iFromVector2Ceil

func NewVector2iFromVector2Ceil(v math32.Vector2) Vector2i

NewVector2iFromVector2Ceil converts from floating point math32.Vector2 vector to int, using ceil

func NewVector2iFromVector2Floor

func NewVector2iFromVector2Floor(v math32.Vector2) Vector2i

NewVector2iFromVector2Floor converts from floating point math32.Vector2 vector to int, using floor

func NewVector2iFromVector2Round

func NewVector2iFromVector2Round(v math32.Vector2) Vector2i

NewVector2iFromVector2Round converts from floating point math32.Vector2 vector to int, using rounding

func NewVector2iScalar

func NewVector2iScalar(s int) Vector2i

NewVector2iScalar returns a new Vector2i with all components set to scalar.

func (Vector2i) Add

func (v Vector2i) Add(other Vector2i) Vector2i

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

func (Vector2i) AddScalar

func (v Vector2i) AddScalar(s int) Vector2i

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

func (*Vector2i) Clamp

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

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 (*Vector2i) ClampScalar

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

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

func (Vector2i) Dim

func (v Vector2i) Dim(dim Dims) int

Dim returns this vector component

func (Vector2i) Div

func (v Vector2i) Div(other Vector2i) Vector2i

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

func (Vector2i) DivScalar

func (v Vector2i) DivScalar(scalar int) Vector2i

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

func (*Vector2i) FromArray

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

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

func (Vector2i) IsEqual

func (v Vector2i) IsEqual(other Vector2i) bool

IsEqual returns if this vector is equal to other.

func (Vector2i) IsNil

func (v Vector2i) IsNil() bool

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

func (Vector2i) Max

func (v Vector2i) Max(other Vector2i) Vector2i

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

func (Vector2i) Min

func (v Vector2i) Min(other Vector2i) Vector2i

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

func (Vector2i) Mul

func (v Vector2i) Mul(other Vector2i) Vector2i

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

func (Vector2i) MulScalar

func (v Vector2i) MulScalar(s int) Vector2i

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

func (Vector2i) Negate

func (v Vector2i) Negate() Vector2i

Negate returns vector with each component negated.

func (*Vector2i) Set

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

Set sets this vector X and Y components.

func (*Vector2i) SetAdd

func (v *Vector2i) SetAdd(other Vector2i)

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

func (*Vector2i) SetAddScalar

func (v *Vector2i) SetAddScalar(s int)

SetAddScalar sets this to addition with scalar.

func (*Vector2i) SetByName

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

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

func (*Vector2i) SetDim

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

SetDim sets this vector component value by its dimension index

func (*Vector2i) SetDiv

func (v *Vector2i) SetDiv(other Vector2i)

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

func (*Vector2i) SetDivScalar

func (v *Vector2i) SetDivScalar(s int)

SetDivScalar sets this to division by scalar.

func (*Vector2i) SetMax

func (v *Vector2i) SetMax(other Vector2i)

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

func (*Vector2i) SetMin

func (v *Vector2i) SetMin(other Vector2i)

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

func (*Vector2i) SetMul

func (v *Vector2i) SetMul(other Vector2i)

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

func (*Vector2i) SetMulScalar

func (v *Vector2i) SetMulScalar(s int)

SetMulScalar sets this to multiplication by scalar.

func (*Vector2i) SetNegate

func (v *Vector2i) SetNegate()

SetNegate negates each of this vector's components.

func (*Vector2i) SetScalar

func (v *Vector2i) SetScalar(s int)

SetScalar sets all vector components to same scalar value.

func (*Vector2i) SetSub

func (v *Vector2i) SetSub(other Vector2i)

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

func (*Vector2i) SetSubScalar

func (v *Vector2i) SetSubScalar(s int)

SetSubScalar sets this to subtraction of scalar.

func (*Vector2i) SetZero

func (v *Vector2i) SetZero()

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

func (Vector2i) Sub

func (v Vector2i) Sub(other Vector2i) Vector2i

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

func (Vector2i) SubScalar

func (v Vector2i) SubScalar(s int) Vector2i

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

func (Vector2i) ToArray

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

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

func (Vector2i) ToVector2

func (v Vector2i) ToVector2() math32.Vector2

ToVector2 returns floating point math32.Vector2 from int

Jump to

Keyboard shortcuts

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