quickhull

package
v0.2.0-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Axis

type Axis int

Axis enumerates the 3 axes of ℝ³.

const (
	XAxis Axis = iota
	YAxis
	ZAxis
)

The three axes of ℝ³.

type ConvexHull

type ConvexHull struct {
	Vertices []Vector
	Indices  []int
	// contains filtered or unexported fields
}

func (ConvexHull) Triangles

func (hull ConvexHull) Triangles() [][3]Vector

type Face

type Face struct {
	HalfEdge int // Index of a bounding HalfEdge
}

Face of a half edge. See: https://www.openmesh.org/media/Documentations/OpenMesh-6.3-Documentation/a00010.html

type HalfEdge

type HalfEdge struct {
	EndVertex int // Index of end vertex
	Opp       int // Index of opposite HalfEdge
	Face      int // Index of Face it belongs to
	Next      int // Index of next HalfEdge
}

HalfEdge is a half edge. See: https://www.openmesh.org/media/Documentations/OpenMesh-6.3-Documentation/a00010.html

type HalfEdgeMesh

type HalfEdgeMesh struct {
	Vertices  []Vector
	Faces     []Face
	HalfEdges []HalfEdge
}

HalfEdgeMesh is a mesh consisting of half edges. See: https://www.openmesh.org/media/Documentations/OpenMesh-6.3-Documentation/a00010.html

type QuickHull

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

QuickHull can be used to calculate the convex hull of a point cloud. See: https://en.wikipedia.org/wiki/Quickhull

func (*QuickHull) ConvexHull

func (qh *QuickHull) ConvexHull(pointCloud []Vector, ccw bool, useOriginalIndices bool, epsilon float64) ConvexHull

ConvexHull calculates the convex hull of the given point cloud using the Quickhull algorithm. If epsilon is <= 0 a default value will be used.

func (*QuickHull) ConvexHullAsMesh

func (qh *QuickHull) ConvexHullAsMesh(pointCloud []Vector, epsilon float64) HalfEdgeMesh

ConvexHull calculates the convex hull of the given point cloud using the Quickhull algorithm and returns it as a HalfEdgeMesh. If epsilon is <= 0 a default value will be used.

type Vector

type Vector struct {
	X, Y, Z float64
	Data    interface{}
}

Vector represents a point in ℝ³.

func (Vector) Abs

func (v Vector) Abs() Vector

Abs returns the vector with nonnegative components.

func (Vector) Add

func (v Vector) Add(ov Vector) Vector

Add returns the standard vector sum of v and ov.

func (Vector) ApproxEqual

func (v Vector) ApproxEqual(ov Vector) bool

ApproxEqual reports whether v and ov are equal within a small epsilon.

func (Vector) Cmp

func (v Vector) Cmp(ov Vector) int

Cmp compares v and ov lexicographically and returns:

-1 if v <  ov
 0 if v == ov
+1 if v >  ov

This method is based on C++'s std::lexicographical_compare. Two entities are compared element by element with the given operator. The first mismatch defines which is less (or greater) than the other. If both have equivalent values they are lexicographically equal.

func (Vector) Cross

func (v Vector) Cross(ov Vector) Vector

Cross returns the standard cross product of v and ov.

func (Vector) Distance

func (v Vector) Distance(ov Vector) float64

Distance returns the Euclidean distance between v and ov.

func (Vector) Dot

func (v Vector) Dot(ov Vector) float64

Dot returns the standard dot product of v and ov.

func (Vector) IsUnit

func (v Vector) IsUnit() bool

IsUnit returns whether this vector is of approximately unit length.

func (Vector) LargestComponent

func (v Vector) LargestComponent() Axis

LargestComponent returns the axis that represents the largest component in this vector.

func (Vector) Mul

func (v Vector) Mul(m float64) Vector

Mul returns the standard scalar product of v and m.

func (Vector) Norm

func (v Vector) Norm() float64

Norm returns the vector's norm.

func (Vector) Norm2

func (v Vector) Norm2() float64

Norm2 returns the square of the norm.

func (Vector) Normalize

func (v Vector) Normalize() Vector

Normalize returns a unit vector in the same direction as v.

func (Vector) Ortho

func (v Vector) Ortho() Vector

Ortho returns a unit vector that is orthogonal to v. Ortho(-v) = -Ortho(v) for all v.

func (Vector) SmallestComponent

func (v Vector) SmallestComponent() Axis

SmallestComponent returns the axis that represents the smallest component in this vector.

func (Vector) String

func (v Vector) String() string

func (Vector) Sub

func (v Vector) Sub(ov Vector) Vector

Sub returns the standard vector difference of v and ov.

Jump to

Keyboard shortcuts

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