geometry

package
v1.0.32 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AngleDirections = angleDirections{
	Err:              fmt.Errorf("invalid AngleDirection"),
	Invalid:          AngleDirection("invalid"),
	Clockwise:        AngleDirection("clockwise"),
	CounterClockwise: AngleDirection("counter-clockwise"),
}
View Source
var AngleTypes = angleTypes{
	Err:     fmt.Errorf("invalid AngleType"),
	Invalid: AngleType("invalid"),
	Degrees: AngleType("degrees"),
	Radians: AngleType("radians"),
}

Functions

func DegreeToRadian

func DegreeToRadian[T geometryNumber](angle T) T

func RadianToDegree

func RadianToDegree[T geometryNumber](angle T) T

Types

type Angle

type Angle[T geometryNumber] struct {
	Magnitude T
	Type      AngleType
	Direction AngleDirection
}

func (Angle[T]) ToDegree

func (t Angle[T]) ToDegree() Angle[T]

func (Angle[T]) ToRadian

func (t Angle[T]) ToRadian() Angle[T]

type AngleDirection

type AngleDirection string

func (AngleDirection) MarshalJSON

func (t AngleDirection) MarshalJSON() ([]byte, error)

func (AngleDirection) MarshalXML added in v1.0.31

func (t AngleDirection) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (AngleDirection) MarshalYAML

func (t AngleDirection) MarshalYAML() (interface{}, error)

func (*AngleDirection) Scan

func (t *AngleDirection) Scan(value interface{}) error

func (AngleDirection) String

func (t AngleDirection) String() string

func (*AngleDirection) UnmarshalJSON

func (t *AngleDirection) UnmarshalJSON(data []byte) error

func (*AngleDirection) UnmarshalXML added in v1.0.31

func (t *AngleDirection) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

func (*AngleDirection) UnmarshalYAML

func (t *AngleDirection) UnmarshalYAML(unmarshal func(interface{}) error) error

func (AngleDirection) Value

func (t AngleDirection) Value() (driver.Value, error)

type AngleType

type AngleType string

func (AngleType) MarshalJSON

func (t AngleType) MarshalJSON() ([]byte, error)

func (AngleType) MarshalXML added in v1.0.31

func (t AngleType) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (AngleType) MarshalYAML

func (t AngleType) MarshalYAML() (interface{}, error)

func (*AngleType) Scan

func (t *AngleType) Scan(value interface{}) error

func (AngleType) String

func (t AngleType) String() string

func (*AngleType) UnmarshalJSON

func (t *AngleType) UnmarshalJSON(data []byte) error

func (*AngleType) UnmarshalXML added in v1.0.31

func (t *AngleType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

func (*AngleType) UnmarshalYAML

func (t *AngleType) UnmarshalYAML(unmarshal func(interface{}) error) error

func (AngleType) Value

func (t AngleType) Value() (driver.Value, error)

type CartesianCoordinate

type CartesianCoordinate[T geometryNumber] struct {
	X T
	Y T
}

func PolarToCartesian

func PolarToCartesian[T geometryNumber](coordinate PolarCoordinate[T]) CartesianCoordinate[T]

type Circle

type Circle[T geometryNumber] struct {
	Center CartesianCoordinate[T]
	Radius T
}

func NewCircle

func NewCircle[T geometryNumber](center CartesianCoordinate[T], radius T) Circle[T]

func NewCircleXY

func NewCircleXY[T geometryNumber](x, y, radius T) Circle[T]

func (Circle[T]) Diameter

func (t Circle[T]) Diameter() T

func (Circle[T]) PointOnCircumference

func (t Circle[T]) PointOnCircumference(angle Angle[T]) CartesianCoordinate[T]

func (Circle[T]) PointOnDiameter

func (t Circle[T]) PointOnDiameter(percent T) CartesianCoordinate[T]

func (Circle[T]) XCoordinate

func (t Circle[T]) XCoordinate(y T) CartesianCoordinate[T]

(x – h)^2 + (y – k)^2 = r^2

(x – h)^2 = r^2 - (y – k)^2 x - h = √(r^2 - (y – k)^2) x = h + √(r^2 - (y – k)^2)

func (Circle[T]) YCoordinate

func (t Circle[T]) YCoordinate(x T) CartesianCoordinate[T]

(x – h)^2 + (y – k)^2 = r^2

(y – k)^2 = r^2 - (x – h)^2
y – k = √(r^2 - (x – h)^2)
y = k + √(r^2 - (x – h)^2)

type Dimension2d

type Dimension2d[T types.Numbers] struct {
	Height T
	Width  T
}

func NewDimension2d

func NewDimension2d[T types.Numbers](height, width T) Dimension2d[T]

type LineSegment

type LineSegment[T geometryNumber] struct {
	Start CartesianCoordinate[T]
	End   CartesianCoordinate[T]
}

func NewLineSegmentCoords

func NewLineSegmentCoords[T geometryNumber](start, end CartesianCoordinate[T]) LineSegment[T]

func NewLineSegmentXY

func NewLineSegmentXY[T geometryNumber](x1, y1, x2, y2 T) LineSegment[T]

func (LineSegment[T]) Length

func (t LineSegment[T]) Length() T

func (LineSegment[T]) Midpoint

func (t LineSegment[T]) Midpoint() CartesianCoordinate[T]

func (LineSegment[T]) PointAtPercent

func (t LineSegment[T]) PointAtPercent(percentage T) CartesianCoordinate[T]

func (LineSegment[T]) Slope

func (t LineSegment[T]) Slope() T

func (LineSegment[T]) SlopeIntercept

func (t LineSegment[T]) SlopeIntercept() SlopeInterceptLine[T]

func (LineSegment[T]) Standard

func (t LineSegment[T]) Standard() StandardLine[T]

type PolarCoordinate

type PolarCoordinate[T geometryNumber] struct {
	Radius T
	Angle  Angle[T]
}

func CartesianToPolar

func CartesianToPolar[T geometryNumber](coordinate CartesianCoordinate[T]) PolarCoordinate[T]

type Rectangle

type Rectangle[T geometryNumber] struct {
	TopLeft    CartesianCoordinate[T]
	Dimensions Dimension2d[T]
}

func NewRectangle

func NewRectangle[T geometryNumber](topLeft CartesianCoordinate[T], dimensions Dimension2d[T]) Rectangle[T]

func NewRectangleXYHW

func NewRectangleXYHW[T geometryNumber](x, y, height, width T) Rectangle[T]

func (Rectangle[T]) Area

func (t Rectangle[T]) Area() T

func (Rectangle[T]) BottomLeft

func (t Rectangle[T]) BottomLeft() CartesianCoordinate[T]

func (Rectangle[T]) BottomMidpoint

func (t Rectangle[T]) BottomMidpoint() CartesianCoordinate[T]

func (Rectangle[T]) BottomRight

func (t Rectangle[T]) BottomRight() CartesianCoordinate[T]

func (Rectangle[T]) Center

func (t Rectangle[T]) Center() CartesianCoordinate[T]

func (Rectangle[T]) LeftMidpoint

func (t Rectangle[T]) LeftMidpoint() CartesianCoordinate[T]

func (Rectangle[T]) Perimeter

func (t Rectangle[T]) Perimeter() T

func (Rectangle[T]) PointOnPeremiter

func (t Rectangle[T]) PointOnPeremiter(angle Angle[T]) CartesianCoordinate[T]

func (Rectangle[T]) RightMidpoint

func (t Rectangle[T]) RightMidpoint() CartesianCoordinate[T]

func (Rectangle[T]) TopMidpoint

func (t Rectangle[T]) TopMidpoint() CartesianCoordinate[T]

func (Rectangle[T]) TopRight

func (t Rectangle[T]) TopRight() CartesianCoordinate[T]

type SlopeInterceptLine

type SlopeInterceptLine[T geometryNumber] struct {
	M T
	B T
}

func (SlopeInterceptLine[T]) Segment

func (t SlopeInterceptLine[T]) Segment(x1, x2 T) LineSegment[T]

func (SlopeInterceptLine[T]) Y

func (t SlopeInterceptLine[T]) Y(x T) T

type StandardLine

type StandardLine[T geometryNumber] struct {
	A T
	B T
	C T
}

Jump to

Keyboard shortcuts

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