Documentation ¶
Overview ¶
Package geom provides geometry primitives.
Index ¶
- func PointSegmentDistance[T xmath.Numeric](s1, s2, p Point[T]) T
- func PointSegmentDistanceSquared[T xmath.Numeric](s1, s2, p Point[T]) T
- type Insets
- func ConvertInsets[T, F xmath.Numeric](i Insets[F]) Insets[T]
- func NewHorizontalInsets[T xmath.Numeric](amount T) Insets[T]
- func NewInsets[T xmath.Numeric](top, left, bottom, right T) Insets[T]
- func NewSymmetricInsets[T xmath.Numeric](h, v T) Insets[T]
- func NewUniformInsets[T xmath.Numeric](amount T) Insets[T]
- func NewVerticalInsets[T xmath.Numeric](amount T) Insets[T]
- func (i Insets[T]) Add(in Insets[T]) Insets[T]
- func (i Insets[T]) Div(value T) Insets[T]
- func (i Insets[T]) Height() T
- func (i Insets[T]) Mul(value T) Insets[T]
- func (i Insets[T]) Size() Size[T]
- func (i Insets[T]) String() string
- func (i Insets[T]) Sub(in Insets[T]) Insets[T]
- func (i Insets[T]) Width() T
- type Matrix
- func NewIdentityMatrix[T constraints.Float]() Matrix[T]
- func NewRotationByDegreesMatrix[T constraints.Float](degrees T) Matrix[T]
- func NewRotationMatrix[T constraints.Float](radians T) Matrix[T]
- func NewScaleMatrix[T constraints.Float](sx, sy T) Matrix[T]
- func NewTranslationMatrix[T constraints.Float](tx, ty T) Matrix[T]
- func (m Matrix[T]) Multiply(other Matrix[T]) Matrix[T]
- func (m Matrix[T]) Rotate(radians T) Matrix[T]
- func (m Matrix[T]) RotateByDegrees(degrees T) Matrix[T]
- func (m Matrix[T]) Scale(sx, sy T) Matrix[T]
- func (m Matrix[T]) String() string
- func (m Matrix[T]) TransformPoint(p Point[T]) Point[T]
- func (m Matrix[T]) Translate(tx, ty T) Matrix[T]
- type Point
- func (p Point[T]) Add(pt Point[T]) Point[T]
- func (p Point[T]) Ceil() Point[T]
- func (p Point[T]) Cross(pt Point[T]) T
- func (p Point[T]) Div(value T) Point[T]
- func (p Point[T]) Dot(pt Point[T]) T
- func (p Point[T]) EqualWithin(pt Point[T], tolerance T) bool
- func (p Point[T]) Floor() Point[T]
- func (p Point[T]) In(r Rect[T]) bool
- func (p Point[T]) Mul(value T) Point[T]
- func (p Point[T]) Neg() Point[T]
- func (p Point[T]) String() string
- func (p Point[T]) Sub(pt Point[T]) Point[T]
- type Rect
- func (r Rect[T]) Align() Rect[T]
- func (r Rect[T]) Bottom() T
- func (r Rect[T]) BottomLeft() Point[T]
- func (r Rect[T]) BottomRight() Point[T]
- func (r Rect[T]) Center() Point[T]
- func (r Rect[T]) CenterX() T
- func (r Rect[T]) CenterY() T
- func (r Rect[T]) Contains(in Rect[T]) bool
- func (r Rect[T]) Empty() bool
- func (r Rect[T]) Expand(pt Point[T]) Rect[T]
- func (r Rect[T]) Inset(insets Insets[T]) Rect[T]
- func (r Rect[T]) Intersect(other Rect[T]) Rect[T]
- func (r Rect[T]) Intersects(other Rect[T]) bool
- func (r Rect[T]) IntersectsLine(start, end Point[T]) bool
- func (r Rect[T]) Right() T
- func (r Rect[T]) String() string
- func (r Rect[T]) TopLeft() Point[T]
- func (r Rect[T]) TopRight() Point[T]
- func (r Rect[T]) Union(other Rect[T]) Rect[T]
- type Size
- func (s Size[T]) Add(size Size[T]) Size[T]
- func (s Size[T]) Ceil() Size[T]
- func (s Size[T]) ConstrainForHint(hint Size[T]) Size[T]
- func (s Size[T]) Div(value T) Size[T]
- func (s Size[T]) Floor() Size[T]
- func (s Size[T]) Max(other Size[T]) Size[T]
- func (s Size[T]) Min(other Size[T]) Size[T]
- func (s Size[T]) Mul(value T) Size[T]
- func (s Size[T]) String() string
- func (s Size[T]) Sub(size Size[T]) Size[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PointSegmentDistance ¶ added in v1.13.0
PointSegmentDistance returns the distance from a point to a line segment. The distance measured is the distance between the specified point and the closest point between the specified end points. If the specified point intersects the line segment in between the end points, this function returns 0.
func PointSegmentDistanceSquared ¶ added in v1.13.0
PointSegmentDistanceSquared returns the square of the distance from a point to a line segment. The distance measured is the distance between the specified point and the closest point between the specified end points. If the specified point intersects the line segment in between the end points, this function returns 0.
Types ¶
type Insets ¶
type Insets[T xmath.Numeric] struct { Top T `json:"top"` Left T `json:"left"` Bottom T `json:"bottom"` Right T `json:"right"` }
Insets defines margins on each side of a rectangle.
func ConvertInsets ¶ added in v1.100.0
ConvertInsets converts a Insets of type F into one of type T.
func NewHorizontalInsets ¶
NewHorizontalInsets returns an Insets whose left and right edges have the specified value.
func NewSymmetricInsets ¶ added in v1.100.0
NewSymmetricInsets returns an Insets whose edges match their opposite edge.
func NewUniformInsets ¶
NewUniformInsets returns an Insets whose edges all have the same value.
func NewVerticalInsets ¶
NewVerticalInsets returns an Insets whose top and bottom edges have the specified value.
func (Insets[T]) Add ¶
Add returns a new Insets which is the result of adding this Insets with the provided Insets.
func (Insets[T]) Div ¶ added in v1.100.0
Div returns a new Insets which is the result of dividing the values of this Insets by the value.
func (Insets[T]) Height ¶ added in v1.69.0
func (i Insets[T]) Height() T
Height returns the sum of the top and bottom insets.
func (Insets[T]) Mul ¶ added in v1.100.0
Mul returns a new Insets which is the result of multiplying the values of this Insets by the value.
type Matrix ¶ added in v1.100.0
type Matrix[T constraints.Float] struct { ScaleX T `json:"scale_x"` SkewX T `json:"skew_x"` TransX T `json:"trans_x"` SkewY T `json:"skew_y"` ScaleY T `json:"scale_y"` TransY T `json:"trans_y"` }
Matrix provides a 2D matrix.
func NewIdentityMatrix ¶ added in v1.100.0
func NewIdentityMatrix[T constraints.Float]() Matrix[T]
NewIdentityMatrix creates a new identity transformation Matrix.
func NewRotationByDegreesMatrix ¶ added in v1.100.0
func NewRotationByDegreesMatrix[T constraints.Float](degrees T) Matrix[T]
NewRotationByDegreesMatrix creates a new Matrix that rotates by 'degrees'. Positive values are clockwise.
func NewRotationMatrix ¶ added in v1.100.0
func NewRotationMatrix[T constraints.Float](radians T) Matrix[T]
NewRotationMatrix creates a new Matrix that rotates by 'radians'. Positive values are clockwise.
func NewScaleMatrix ¶ added in v1.100.0
func NewScaleMatrix[T constraints.Float](sx, sy T) Matrix[T]
NewScaleMatrix creates a new Matrix that scales by 'sx' and 'sy'.
func NewTranslationMatrix ¶ added in v1.100.0
func NewTranslationMatrix[T constraints.Float](tx, ty T) Matrix[T]
NewTranslationMatrix creates a new Matrix that translates by 'tx' and 'ty'.
func (Matrix[T]) Multiply ¶ added in v1.100.0
Multiply returns this Matrix multiplied by the other Matrix.
func (Matrix[T]) Rotate ¶ added in v1.100.0
Rotate returns a new Matrix which is a copy of this Matrix rotated by 'radians'. Positive values are clockwise.
func (Matrix[T]) RotateByDegrees ¶ added in v1.100.0
RotateByDegrees returns a new Matrix which is a copy of this Matrix rotated by 'degrees'. Positive values are clockwise.
func (Matrix[T]) Scale ¶ added in v1.100.0
Scale returns a new Matrix which is a copy of this Matrix scaled by 'sx' and 'sy'.
func (Matrix[T]) TransformPoint ¶ added in v1.100.0
TransformPoint returns the result of transforming the given Point by this Matrix.
type Point ¶
Point defines a location.
func ConvertPoint ¶ added in v1.100.0
ConvertPoint converts a Point of type F into one of type T.
func LineIntersection ¶ added in v1.13.0
LineIntersection determines the intersection of two lines, if any. A return of no points indicates no intersection. One point indicates intersection at a single point. Two points indicates an overlapping line segment.
func (Point[T]) Add ¶
Add returns a new Point which is the result of adding this Point with the provided Point.
func (Point[T]) Ceil ¶ added in v1.100.0
Ceil returns a new Point which is aligned to integer coordinates by using Ceil() on them.
func (Point[T]) Div ¶ added in v1.100.0
Div returns a new Point which is the result of dividing the coordinates of this point by the value.
func (Point[T]) EqualWithin ¶ added in v1.100.0
EqualWithin returns true if the two points are within the given tolerance of each other.
func (Point[T]) Floor ¶ added in v1.100.0
Floor returns a new Point which is aligned to integer coordinates by using Floor on them.
func (Point[T]) Mul ¶ added in v1.100.0
Mul returns a new Point which is the result of multiplying the coordinates of this point by the value.
func (Point[T]) Neg ¶ added in v1.100.0
Neg returns a new Point that holds the negated coordinates of this Point.
type Rect ¶
Rect defines a rectangle.
func ConvertRect ¶ added in v1.100.0
ConvertRect converts a Rect of type F into one of type T.
func (Rect[T]) Align ¶
Align returns a new Rect aligned with integer coordinates that would encompass the original rectangle.
func (Rect[T]) Bottom ¶ added in v1.13.0
func (r Rect[T]) Bottom() T
Bottom returns the bottom edge, or Y + Height.
func (Rect[T]) BottomLeft ¶ added in v1.28.0
BottomLeft returns the bottom-left point of the Rect.
func (Rect[T]) BottomRight ¶ added in v1.28.0
BottomRight returns the bottom-right point of the Rect.
func (Rect[T]) CenterX ¶
func (r Rect[T]) CenterX() T
CenterX returns the center x-coordinate of the Rect.
func (Rect[T]) CenterY ¶
func (r Rect[T]) CenterY() T
CenterY returns the center y-coordinate of the Rect.
func (Rect[T]) Contains ¶ added in v1.100.0
Contains returns true if this Rect fully contains the passed in Rect.
func (Rect[T]) Empty ¶ added in v1.100.0
Empty returns true if either the width or height is zero or less.
func (Rect[T]) Expand ¶ added in v1.100.0
Expand returns a new Rect that expands this Rect to encompass the provided Point. If the Rect has a negative width or height, then the Rect's upper-left corner will be set to the Point and its width and height will be set to 0.
func (Rect[T]) Intersect ¶
Intersect returns the result of intersecting this Rect with another Rect.
func (Rect[T]) Intersects ¶ added in v1.6.0
Intersects returns true if this Rect and the other Rect intersect.
func (Rect[T]) IntersectsLine ¶ added in v1.28.0
IntersectsLine returns true if this rect and the line described by start and end intersect.
func (Rect[T]) Right ¶ added in v1.13.0
func (r Rect[T]) Right() T
Right returns the right edge, or X + Width.
type Size ¶
Size defines a width and height.
func ConvertSize ¶ added in v1.100.0
ConvertSize converts a Size of type F into one of type T.
func (Size[T]) Add ¶
Add returns a new Size which is the result of adding this Size with the provided Size.
func (Size[T]) ConstrainForHint ¶
ConstrainForHint returns a size no larger than the hint value. Hint values less than one are ignored.
func (Size[T]) Div ¶ added in v1.100.0
Div returns a new Size which is the result of dividing this Size by the value.
func (Size[T]) Floor ¶ added in v1.100.0
Floor returns a new Size with its width and height floored.