geom

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package geom provides 2D geometry primitives.

Types:

  • Vec2: 2D vector with Scan/String for serialization
  • Rect: rectangle (X, Y, Width, Height) with intersection, union, containment
  • Mat3x2: 2D affine transformation matrix (translate, scale, rotate, invert)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mat3x2

type Mat3x2 struct {
	Xx, Yx, Xy, Yy, X0, Y0 float64
}

3x2的平面变换矩阵, 兼容cairo库

func (*Mat3x2) Det

func (m *Mat3x2) Det() (x float64)

func (*Mat3x2) Init

func (m *Mat3x2) Init(xx, yx, xy, yy, x0, y0 float64)

func (*Mat3x2) InitIdentity

func (m *Mat3x2) InitIdentity()

func (*Mat3x2) InitRotate

func (m *Mat3x2) InitRotate(radians float64)

func (*Mat3x2) InitScale

func (m *Mat3x2) InitScale(sx, sy float64)

func (*Mat3x2) InitTranslate

func (m *Mat3x2) InitTranslate(tx, ty float64)

func (*Mat3x2) Invert

func (m *Mat3x2) Invert() bool

func (*Mat3x2) Multiply

func (a *Mat3x2) Multiply(b *Mat3x2) (c Mat3x2)

func (*Mat3x2) MultiplyWidth

func (a *Mat3x2) MultiplyWidth(b *Mat3x2)

func (*Mat3x2) Rotate

func (m *Mat3x2) Rotate(radians float64)

func (*Mat3x2) Scale

func (m *Mat3x2) Scale(sx, sy float64)

func (*Mat3x2) Transform

func (m *Mat3x2) Transform(x, y float64) (x1, y1 float64)

func (*Mat3x2) TransformVec

func (m *Mat3x2) TransformVec(x, y float64) (x1, y1 float64)

func (*Mat3x2) Translate

func (m *Mat3x2) Translate(tx, ty float64)

type Rect

type Rect struct {
	X      float64
	Y      float64
	Width  float64
	Height float64
}

func (Rect) AdjustCopy

func (a Rect) AdjustCopy(dx1, dx2, dy1, dy2 float64) (r Rect)

func (Rect) Area

func (a Rect) Area() float64

func (Rect) Bottom

func (a Rect) Bottom() float64

func (Rect) Center

func (a Rect) Center() (x, y float64)

func (Rect) Center1

func (a Rect) Center1() Vec2

func (Rect) Contains

func (a Rect) Contains(x, y float64) bool

func (Rect) ExpandCopy

func (a Rect) ExpandCopy(offset float64) Rect

func (Rect) IntersectCopy

func (a Rect) IntersectCopy(b Rect) (ret Rect)

func (Rect) IsEmpty

func (a Rect) IsEmpty() bool

func (Rect) IsIntersects

func (a Rect) IsIntersects(b Rect) bool

func (Rect) IsNormal

func (a Rect) IsNormal() bool

func (Rect) IsZero

func (a Rect) IsZero() bool

func (Rect) Left

func (a Rect) Left() float64

func (*Rect) Normalize

func (a *Rect) Normalize()

func (Rect) NormalizeCopy

func (a Rect) NormalizeCopy() (r Rect)

func (Rect) Right

func (a Rect) Right() float64

func (*Rect) Scan

func (this *Rect) Scan(state fmt.ScanState, verb rune) error

func (Rect) ShrinkCopy

func (a Rect) ShrinkCopy(offset float64) Rect

func (*Rect) Size

func (this *Rect) Size() (float64, float64)

func (Rect) String

func (a Rect) String() string

func (Rect) Top

func (a Rect) Top() float64

func (Rect) UniteCopy

func (a Rect) UniteCopy(b Rect) (ret Rect)

type Vec2

type Vec2 struct {
	X, Y float64
}

func (*Vec2) Scan

func (this *Vec2) Scan(state fmt.ScanState, verb rune) error

func (Vec2) String

func (a Vec2) String() string

Jump to

Keyboard shortcuts

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