geom

package module
v0.0.0-...-c16f11d Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: Unlicense Imports: 3 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Geom

type Geom [3][2]float64

func Identity2d

func Identity2d() (g Geom)

func Rotate2d

func Rotate2d(theta float64) (p Geom)

func Scale2d

func Scale2d(x, y float64) (p Geom)

func Shear2d

func Shear2d(x, y float64) (p Geom)

func Translate2d

func Translate2d(x, y float64) Geom

func Window2d

func Window2d(w, h int) Geom

func (Geom) Apply

func (g Geom) Apply(vec [3]float64) (o [3]float64)

func (Geom) ApplyPt

func (g Geom) ApplyPt(p Point) Point

func (Geom) ApplyRect

func (g Geom) ApplyRect(r Rectangle) Rectangle

func (Geom) Inverse

func (g Geom) Inverse() (b Geom)

func (Geom) Mul

func (g Geom) Mul(b Geom) (c Geom)

func (Geom) Rotate

func (g Geom) Rotate(theta float64) Geom

func (Geom) Scale

func (g Geom) Scale(x, y float64) Geom

func (Geom) Shear

func (g Geom) Shear(x, y float64) Geom

func (*Geom) String

func (g *Geom) String() string

func (Geom) To3d

func (g Geom) To3d() Geom3d

func (Geom) Translate

func (g Geom) Translate(x, y float64) Geom

func (Geom) Transpose

func (g Geom) Transpose() (b Geom)

type Geom3d

type Geom3d [4][4]float64

func Frustum3d

func Frustum3d(left, right, bottom, top, near, far float64) Geom3d

func Identity3d

func Identity3d() (g Geom3d)

func Ortho3d

func Ortho3d(zoom, width, height, near, far float64) Geom3d

Ortho3d generates an orthographic projection matrix. Zoom is the relative size of one unit in world coordinates. If width and height are equal to window width and height respectively, zoom is the size of one uint in pixels.

func Perspective3d

func Perspective3d(fov, aspect, near, far float64) Geom3d

Perspective3d generates a perspective projection matrix. Fov is the angle between top and bottom planes of the frustum. Aspect is its aspect ratio.

func Rotate3d

func Rotate3d(yaw, pitch, roll float64) (p Geom3d)

Rotate3d generates a 3d rotation matrix based on Euler angles.

func Scale3d

func Scale3d(x, y, z float64) (p Geom3d)

func Translate3d

func Translate3d(x, y, z float64) Geom3d

func (Geom3d) Apply

func (g Geom3d) Apply(vec [4]float64) (o [4]float64)

func (Geom3d) Mul

func (g Geom3d) Mul(b Geom3d) (c Geom3d)

func (Geom3d) Rotate

func (g Geom3d) Rotate(pitch, yaw, roll float64) Geom3d

func (Geom3d) Scale

func (g Geom3d) Scale(x, y, z float64) Geom3d

func (Geom3d) Translate

func (g Geom3d) Translate(x, y, z float64) Geom3d

func (Geom3d) Transpose

func (g Geom3d) Transpose() (b Geom3d)

type Point

type Point struct {
	X, Y float64
}

func PromotePt

func PromotePt(p image.Point) Point

PromotePt converts an integral image.Point to Point.

func Pt

func Pt(x, y float64) Point

func (Point) Abs

func (p Point) Abs() Point

func (Point) Add

func (p Point) Add(q Point) Point

Add returns the vector p+q.

func (Point) Ceil

func (p Point) Ceil() Point

Ceil returns the least integer vector greater than or equal to x.

func (Point) Cross

func (p Point) Cross(q Point) Point3d

Cross returns the vector p×q.

func (Point) Degrade

func (p Point) Degrade() image.Point

Degrade returns the nearest integer vector as image.Point.

func (Point) Dot

func (p Point) Dot(q Point) float64

Dot returns the vector p•q.

func (Point) Floor

func (p Point) Floor() Point

Floor returns the greatest integer vector less than or equal to p.

func (Point) In

func (p Point) In(r Rectangle) bool

In reports whether p is in r.

func (Point) Length

func (p Point) Length() float64

func (Point) Mix

func (p Point) Mix(b, t Point) Point

Mix linearly interpolates between points p and b by the parameter t.

func (Point) Mul

func (p Point) Mul(k float64) Point

Mul returns the vector p*k. Use 1/k for division.

func (Point) Pmax

func (p Point) Pmax(q Point) Point

Pmax returns the result of per-element maximum of vectors p and q.

func (Point) Pmin

func (p Point) Pmin(q Point) Point

Pmin returns the result of per-element minimum of vectors p and q.

func (Point) Pmul

func (p Point) Pmul(q Point) Point

Pmul returns the result of per-element multiplication of vectors p and q.

func (Point) String

func (p Point) String() string

func (Point) Sub

func (p Point) Sub(q Point) Point

Sub returns the vector p-q.

func (Point) To3

func (p Point) To3() Point3d

To3 promotes vector to three dimensions.

func (Point) Triple

func (p Point) Triple(q, d Point) float64

Triple returns the vector p•(q×d).

type Point3d

type Point3d struct {
	X, Y, Z float64
}

Point3d is a X, Y and Z coordinate triple.

func Pt3

func Pt3(x, y, z float64) Point3d

func (Point3d) Add

func (p Point3d) Add(q Point3d) Point3d

Add returns the vector p+q.

func (Point3d) Cross

func (p Point3d) Cross(q Point3d) Point3d

Cross returns the vector p×q.

func (Point3d) Dot

func (p Point3d) Dot(q Point3d) float64

Dot returns the vector p⋅d.

func (Point3d) In

func (p Point3d) In(r Rectangle) bool

In reports whether p is in r.

func (Point3d) Mul

func (p Point3d) Mul(k float64) Point3d

Mul returns the vector p*k. Use 1/k for division.

func (Point3d) String

func (p Point3d) String() string

func (Point3d) Sub

func (p Point3d) Sub(q Point3d) Point3d

Sub returns the vector p-q.

type Rectangle

type Rectangle struct {
	Min, Max Point
}

func PromoteRect

func PromoteRect(p image.Rectangle) Rectangle

func Rect

func Rect(x0, y0, x1, y1 float64) Rectangle

func (Rectangle) Add

func (r Rectangle) Add(p Point) Rectangle

Add returns the rectangle r translated by p.

func (Rectangle) Canon

func (r Rectangle) Canon() Rectangle

Canon returns the canonical version of r. The returned rectangle has minimum and maximum coordinates swapped if necessary so that it is well-formed.

func (Rectangle) Center

func (r Rectangle) Center() Point

Center returns the geometric center of r.

func (Rectangle) Degrade

func (r Rectangle) Degrade() image.Rectangle

Degrade returns the nearest image.Rectangle.

func (Rectangle) Distance

func (r Rectangle) Distance(at Point) float64

Distance evaluates signed distance function of the rectangle at the given point. If signed distance is negative, then the point is inside the rectangle. If it is zero, then it is on its boundary.

func (Rectangle) Dx

func (r Rectangle) Dx() float64

Dx returns r's width.

func (Rectangle) Dy

func (r Rectangle) Dy() float64

Dy returns r's height.

func (Rectangle) Empty

func (r Rectangle) Empty() bool

Empty reports whether the rectangle contains no points.

func (Rectangle) Eq

func (r Rectangle) Eq(s Rectangle) bool

Eq reports whether r and s contain the same set of points. All empty rectangles are considered equal.

func (Rectangle) In

func (r Rectangle) In(s Rectangle) bool

In reports whether every point in r is in s.

func (Rectangle) Inset

func (r Rectangle) Inset(n float64) Rectangle

Inset returns the rectangle r inset by n, which may be negative. If either of r's dimensions is less than 2*n then an empty rectangle near the center of r will be returned.

func (Rectangle) Intersect

func (r Rectangle) Intersect(s Rectangle) Rectangle

Intersect returns the largest rectangle contained by both r and s. If the two rectangles do not overlap then the zero rectangle will be returned.

func (Rectangle) Overlaps

func (r Rectangle) Overlaps(s Rectangle) bool

Overlaps reports whether r and s have a non-empty intersection.

func (Rectangle) Size

func (r Rectangle) Size() Point

Size returns r's width and height.

func (Rectangle) Sub

func (r Rectangle) Sub(p Point) Rectangle

Sub returns the rectangle r translated by -p.

func (Rectangle) Union

func (r Rectangle) Union(s Rectangle) Rectangle

Union returns the smallest rectangle that contains both r and s.

Jump to

Keyboard shortcuts

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