ellipse

package
v0.0.0-...-9c88ebf Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConvexHullPoints = 12

ConvexHullPoints sets the number of points Ellipse.ConvexHull returns.

Functions

This section is empty.

Types

type Circle

type Circle struct {
	Ellipse
}

Circle fulfills Shape.

func CircumscribeCircle

func CircumscribeCircle(t triangle.Triangle) Circle

CircumscribeCircle creates a circle where all three verticies lie on the perimeter.

func NewCircle

func NewCircle(center d2.Pt, radius float64) Circle

NewCircle returns a circle defined by a center and radius

func (Circle) Radius

func (c Circle) Radius() float64

Radius returns the radius of the circle

type Ellipse

type Ellipse struct {
	// contains filtered or unexported fields
}

Ellipse fulfills Shape

func New

func New(f1, f2 d2.Pt, r float64) Ellipse

New returns an Ellipse with foci f1 and f2 and a minor radius of r. The perimeter point that corresponds to an angle of 0 will be 1/4 rotation going from f1 to f2, which will lie along the minor axis. So an ellipse with foci (0,0) and (0,2) with a minor radius of 1 will have angle 0 at point (1,1).

func (Ellipse) Arc

func (e Ellipse) Arc() *ellipsearc.EllipseArc

Arc returns the EllipseArc defined by the perimeter

func (Ellipse) Area

func (e Ellipse) Area() float64

Area returns the area of the Ellipse

func (Ellipse) BoundingBox

func (e Ellipse) BoundingBox() (min d2.Pt, max d2.Pt)

BoundingBox fulfills shape.BoundingBoxer. It returns the corners of a Box that will exactly contain the Ellipse. It is a wrapper around EllipseArc.BoundingBox.

func (Ellipse) Centroid

func (e Ellipse) Centroid() d2.Pt

Centroid returns the center of the ellipse

func (Ellipse) Contains

func (e Ellipse) Contains(pt d2.Pt) bool

Contains returns true if the point f is contained in the ellipse

func (Ellipse) ConvexHull

func (e Ellipse) ConvexHull() []d2.Pt

ConvexHull fulfills shape.ConvexHuller. It returns a polygon with the number of points set by ConvexHullPoints. The sides of the polygon will intersect the ellipse at a single tangent point.

func (Ellipse) LineIntersections

func (e Ellipse) LineIntersections(l line.Line, buf []float64) []float64

LineIntersections fulfills line.LineIntersector.

func (Ellipse) Perimeter

func (e Ellipse) Perimeter() float64

Perimeter returns the length of the perimeter of the ellipse. This value may have a slight error that will grow as the ellipse is elongated.

func (Ellipse) PerimeterSeries

func (e Ellipse) PerimeterSeries(terms int) float64

PerimeterSeries approximates the perimeter using a series

func (Ellipse) Pt1

func (e Ellipse) Pt1(t0 float64) d2.Pt

Pt1 fulfils d2.Pt1 taking one parametric point and returning a point on the perimeter.

func (Ellipse) Pt2

func (e Ellipse) Pt2(t0, t1 float64) d2.Pt

Pt2 fulfils d2.Pt2 taking two parametric points and returning a point in the ellipse. It does so by mapping the ellipse onto a unit square with points on the perimeter every 1/4 rotation corresponding to a corner of the square.

func (Ellipse) Pt2c1

func (e Ellipse) Pt2c1(t0 float64) d2.Pt1

Pt2c1 returns a curve that lies inside of the ellipse. All curves in the range 0.0 to 1.0 will fill the entire ellipse.

func (Ellipse) PtApprox

func (e Ellipse) PtApprox(n int) []d2.Pt

PtApprox returns a polygon approximation of the ellipse. All points are outside the polygon and the lines between them intersect the ellipse at a single tangent point.

func (Ellipse) SignedArea

func (e Ellipse) SignedArea() float64

SignedArea returns the area of the ellipse, though the value may be negative depending on polarity.

type FillCurve

type FillCurve struct {
	*d2.T
	*ellipsearc.EllipseArc
}

FillCurve a curve that lies inside of the ellipse. It is returned by Ellipse.Pt2c1.

func (FillCurve) Pt1

func (fc FillCurve) Pt1(t0 float64) d2.Pt

Pt1 fulfills d2.Pt1. Given a parametric value it returns a Pt on the curve.

Jump to

Keyboard shortcuts

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