line

package
v0.14.8 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package line implements a 1D line in N-dimensional ambient space.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Within added in v0.9.0

func Within(l L, m L) bool

func WithinEpsilon added in v0.10.0

func WithinEpsilon(l L, m L, e epsilon.E) bool

Types

type L

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

L defines a parametric line of the form

L := P + tD

func New

func New(p vector.V, d vector.V) *L

func (L) D

func (l L) D() vector.V

func (L) L

func (l L) L(t float64) vector.V

L calculates the vector value on the line which corresponds to the input parametric t-value.

func (L) P

func (l L) P() vector.V

func (L) Parallel added in v0.5.0

func (l L) Parallel(m L) bool

Parallel checks if two lines are parallel. A return value of false may indicate the lines intersect, are skew lines, or are anti-parallel.

We check for the parallel property by examining the ratio of the vector directions.

See https://stackoverflow.com/a/45181059/873865 for more details.

func (L) T

func (l L) T(v vector.V) float64

T calculates the projected t-value of v onto l by finding the point on L closest to v.

Intuitively, we want to find the magnitude of the projected leg onto L; that is, we care about

||v - P||

Therefore, we need a factor of ||D|| in the denominator.

Furthermore, we know that t grows linearly with ||D||, so we need to add another ||D|| factor in the denominator as a normalization factor.

Jump to

Keyboard shortcuts

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