geom

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 1 Imported by: 5

Documentation

Index

Constants

View Source
const (
	Pi     = 3.14159
	Pi2    = Pi * 2
	HalfPi = Pi / 2
)

Variables

This section is empty.

Functions

func Clamp

func Clamp(value float64, min float64, max float64) float64

Clamp - converted C# method MathHelper.ClampInt Restricts a value to be within a specified range.

func ClampInt

func ClampInt(value int, min int, max int) int

func Degrees

func Degrees(radians float64) float64

func Distance

func Distance(x1, y1, x2, y2 float64) float64

Distance returns the distance between two points

func Distance2

func Distance2(x1, y1, x2, y2 float64) float64

Distance2 returns the d^2 of the distance between two points

func GetAdjacentHypotenuseTriangleLeg

func GetAdjacentHypotenuseTriangleLeg(angle, hypotenuseLength float64) float64

GetAdjacentHypotenuseTriangleLeg gets the leg length adjacent the hypotenuse for angle in a right triangle

func GetOppositeTriangleBase added in v1.11.0

func GetOppositeTriangleBase(angle, oppositeLength float64) float64

GetOppositeTriangleBase gets the base length opposite the non-hypotenuse leg in a right triangle

func GetOppositeTriangleLeg

func GetOppositeTriangleLeg(angle, baseLength float64) float64

GetOppositeTriangleLeg gets the leg length opposite the non-hypotenuse base in a right triangle

func LineIntersection

func LineIntersection(l1, l2 Line) (float64, float64, bool)

LineIntersection calculates the intersection of two lines.

func MaxInt

func MaxInt(x, y int) int

func NearlyEqual

func NearlyEqual(a, b, epsilon float64) bool

func Radians

func Radians(degrees float64) float64

Types

type Circle

type Circle struct {
	X, Y   float64
	Radius float64
}

func (*Circle) CircleCollision

func (c *Circle) CircleCollision(c2 *Circle) (float64, bool)

CircleCollision checks for collision against another circle and returns distance between their center points

type Line

type Line struct {
	X1, Y1, X2, Y2 float64
}

Line implementation for Geometry applications

func LineFromAngle

func LineFromAngle(x, y, angle, length float64) Line

LineFromAngle creates a line from a starting point at a given angle and length

func Rect

func Rect(x, y, w, h float64) []Line

Rect implementation for Geometry applications

func (*Line) Angle

func (l *Line) Angle() float64

Angle gets the angle of the line

func (*Line) Distance added in v1.2.1

func (l *Line) Distance() float64

Distance gets the distance between the two endpoints of the line

type Vector2

type Vector2 struct {
	X, Y float64
}

2-Dimensional point

func LineCircleIntersection

func LineCircleIntersection(li Line, ci Circle, isSegment bool) []Vector2

LineCircleIntersection gets the intersection points (if any) of a circle, and either an infinite line or a line segment.

func (*Vector2) Add

func (v *Vector2) Add(v2 *Vector2) *Vector2

func (*Vector2) Copy

func (v *Vector2) Copy() *Vector2

func (*Vector2) Equals

func (v *Vector2) Equals(v2 *Vector2) bool

func (*Vector2) NearlyEquals

func (v *Vector2) NearlyEquals(v2 *Vector2, epsilon float64) bool

func (*Vector2) Sub

func (v *Vector2) Sub(v2 *Vector2) *Vector2

Jump to

Keyboard shortcuts

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