line

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: 4 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRange = Range{
	T0: &[2]float64{0, 1},
	T1: &[2]float64{0, 1},
}

DefaultRange checks that

View Source
var Small = cmpr.Tolerance(1e-12)

Small is the value that will be used to compare against 0.

Functions

This section is empty.

Types

type Intersector

type Intersector interface {
	LineIntersections(l Line, buf []float64) []float64
}

Intersector finds the points where the interface intersects a line. The returned values should be relative to the line passed in. The buffer both provides reuse to avoid generating garbage and allows for fine tuning. If the buffer has a length of 0, all the intersections will be appended. If the buffer has a non-zero length, that output will be limited. So if a buffer of length 1 is passed in, only the first intersection is returned. But there is no guarenteed order.

type Line

type Line struct {
	T0 d2.Pt
	D  d2.V
}

Line in 2D space invoked parametrically

func Bisect

func Bisect(a, b d2.Point) Line

Bisect returns a line that bisects points a and b. All points on the line are equadistant from both a and b. At t=0, the mid-point is returned. At t=1, the point is the same distance from t=0 as the two definition points.

func New

func New(start, end d2.Pt) Line

New line from start to end so that l.Pt1(0)==start and l.Pt1(1)==end.

func TangentLine

func TangentLine(c d2.Pt1V1, t0 float64) Line

TangentLine takes a Pt1V1 and a parametric t0 and returns a line on the curve at that point, tangent to that point.

func (Line) AssertEqual

func (l Line) AssertEqual(actual interface{}, t cmpr.Tolerance) error

AssertEqual fulfils geomtest.AssertEqualizer

func (Line) AtX

func (l Line) AtX(x float64) float64

AtX Returns the value of t at x. May return Inf.

func (Line) AtY

func (l Line) AtY(y float64) float64

AtY Returns the value of t at x. May return Inf.

func (Line) B

func (l Line) B() float64

B from the form y = mx + b, this will panic if l.D.X is zero

func (Line) Centroid

func (l Line) Centroid() d2.Pt

Centroid point on the line

func (Line) Closest

func (l Line) Closest(pt d2.Pt) d2.Pt

Closest returns the point on the line closest to pt

func (Line) ClosestT

func (l Line) ClosestT(pt d2.Pt) float64

ClosestT return the parametric T value closest to the given point.

func (Line) Cross

func (l Line) Cross(pt d2.Pt) float64

Cross product of the vector of the line with the vector from T0 to pt

func (Line) Intersection

func (l Line) Intersection(l2 Line) (float64, float64, bool)

Intersection returns the parametric values of the intersection point on the line passed in as an argument and a bool indicating if there was an intersection.

func (Line) L

func (Line) L(t, c int) d2.Limit

L fulfills d2.Limiter

func (Line) LineIntersections

func (l Line) LineIntersections(l2 Line, buf []float64) []float64

LineIntersections returns the points at which the lines intersect. It fulls the Intersections interface. If the lines are parallel, nil is returned. Otherwise a slice with a single value is returned indicating the parametric point along l2 at which the intersection occures.

func (Line) M

func (l Line) M() float64

M from the form y = mx + b, this will panic if l.D.X is zero

func (Line) PartialIntersection

func (l Line) PartialIntersection(l2 Line) (t, cross float64, v d2.V)

PartialIntersection finds the intersection of l and l2 relative to l2. It also returns the cross product and v which is the vector from l.T0 to l2.T0.

func (Line) Pt1

func (l Line) Pt1(t float64) d2.Pt

Pt1 returns a Pt on the line

func (Line) String

func (l Line) String() string

String fulfills Stringer

func (Line) T

func (l Line) T(t *d2.T) Line

T applies a transform to the line returning a new line.

func (Line) V1

func (l Line) V1(t float64) d2.V

V1 always returns l.D, the slope of the line

func (Line) VL

func (Line) VL(t, c int) d2.Limit

VL fulfills d2.VLimiter

type Range

type Range struct {
	T0 *[2]float64
	T1 *[2]float64
}

Range checks if an intersection happened and was within a range.

func (Range) Check

func (r Range) Check(t0, t1 float64, ok bool) (float64, float64, bool)

Check that ok is true. Check that t0 and t1 are in their respective range, if that range is not nil.

type Segments

type Segments []d2.Pt

Segments links together a series of points and fulfils Curve.

func (Segments) LineIntersections

func (ls Segments) LineIntersections(l Line, buf []float64) []float64

LineIntersections fulfills Intersections, returning the points that intersect the line.

func (Segments) Pt1

func (ls Segments) Pt1(t float64) d2.Pt

Pt1 returns a point on the line segments. All segments are weighted equally regardless of actual length.

Jump to

Keyboard shortcuts

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