vecint

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: BSD-3-Clause Imports: 1 Imported by: 6

README

vecint

Package vecint 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 vecint 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 some use-cases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Vector2i

type Vector2i struct {
	X int
	Y int
}

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

func Vec2i

func Vec2i(x, y int) Vector2i

Vec2i returns a new Vector2i with the given x and y components.

func Vector2iFromVector2Ceil

func Vector2iFromVector2Ceil(v math32.Vector2) Vector2i

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

func Vector2iFromVector2Floor

func Vector2iFromVector2Floor(v math32.Vector2) Vector2i

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

func Vector2iFromVector2Round

func Vector2iFromVector2Round(v math32.Vector2) Vector2i

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

func Vector2iScalar

func Vector2iScalar(scalar int) Vector2i

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

func (Vector2i) Add

func (v Vector2i) Add(other Vector2i) Vector2i

Add adds the other given vector to this one and returns the result as 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's 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) Dim

func (v Vector2i) Dim(dim math32.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) FromSlice

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

FromSlice sets this vector's components from the given slice, starting at offset.

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 the 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) SetDim

func (v *Vector2i) SetDim(dim math32.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(scalar 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) SetScalar

func (v *Vector2i) SetScalar(scalar 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 all of the vector's components to 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) ToSlice

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

ToSlice copies this vector's components to the given slice, 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