visibility

package
v1.122.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MPL-2.0 Imports: 7 Imported by: 0

README

Warning!

The visibility code doesn't function as expected in all cases. It does work for most cases, but I recommend against using it in production code at the moment.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Segment

type Segment[T constraints.Float] struct {
	Start geom.Point[T]
	End   geom.Point[T]
}

Segment holds the start and end points of a line.

func (Segment[T]) Bounds

func (s Segment[T]) Bounds() geom.Rect[T]

Bounds returns the bounding rectangle of this Segment. This includes a slight bit of expansion to compensate for floating-point imprecision.

type Visibility

type Visibility[T constraints.Float] struct {
	// contains filtered or unexported fields
}

Visibility holds state for computing a visibility polygon.

func New

func New[T constraints.Float](bounds geom.Rect[T], obstructions []Segment[T], hasNoIntersections bool) *Visibility[T]

New creates a Visibility object. If the obstructions do not intersect each other, pass in true for hasNoIntersections to eliminate the costly pass to break the segments up into smaller parts.

func (*Visibility[T]) SetViewPoint

func (v *Visibility[T]) SetViewPoint(viewPt geom.Point[T]) poly.Polygon[T]

SetViewPoint sets a view point and generates a polygon with the unobstructed visible area.

Jump to

Keyboard shortcuts

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