Documentation ¶
Index ¶
- Constants
- Variables
- type AABB
- func (a AABB) Buffer(r float64) AABB
- func (a AABB) IntersectsAABB(b AABB) bool
- func (a AABB) IntersectsRay(r Ray) bool
- func (a AABB) IntersectsSphere(s Sphere) bool
- func (a AABB) IntersectsTriangle(t Triangle) bool
- func (a AABB) IntersectsVector3(v Vector3) bool
- func (a AABB) Max() Vector3
- func (a AABB) Min() Vector3
- func (a AABB) Octant(octant int) AABB
- type HEFace
- type HEHalfEdge
- type HEMesh
- func (m *HEMesh) ExportOBJ(w io.Writer) error
- func (m *HEMesh) ExportOBJFile(path string) error
- func (m *HEMesh) ExtractFaces(ids []int) (*HEMesh, error)
- func (m *HEMesh) ExtractPatchNames(names []string) (*HEMesh, error)
- func (m *HEMesh) ExtractPatches(ids []int) (*HEMesh, error)
- func (m *HEMesh) GetBounds() AABB
- func (m *HEMesh) GetComponents() [][]int
- func (m *HEMesh) GetFace(id int) HEFace
- func (m *HEMesh) GetFaceHalfEdges(id int) []int
- func (m *HEMesh) GetFaceNeighbors(id int) []int
- func (m *HEMesh) GetFaceNormal(id int) Vector3
- func (m *HEMesh) GetFaceVertices(id int) []int
- func (m *HEMesh) GetHalfEdge(id int) HEHalfEdge
- func (m *HEMesh) GetNumberOfFaces() int
- func (m *HEMesh) GetNumberOfHalfEdges() int
- func (m *HEMesh) GetNumberOfPatches() int
- func (m *HEMesh) GetNumberOfVertices() int
- func (m *HEMesh) GetPatch(id int) HEPatch
- func (m *HEMesh) GetPatchFaces(id int) []int
- func (m *HEMesh) GetPatchNames() []string
- func (m *HEMesh) GetVertex(id int) HEVertex
- func (m *HEMesh) GetVertexCurvature(id int) (float64, error)
- func (m *HEMesh) GetVertexFaces(id int) []int
- func (m *HEMesh) GetVertexNeighbors(id int) []int
- func (m *HEMesh) IsClosed() bool
- func (m *HEMesh) IsConsistent() bool
- func (m *HEMesh) IsVertexOnBoundary(id int) bool
- func (m *HEMesh) Merge(other *HEMesh)
- func (m *HEMesh) Orient()
- func (m *HEMesh) ZipEdges() error
- type HEPatch
- type HEVertex
- type IntersectsAABB
- type IntersectsRay
- type IntersectsSphere
- type IntersectsTriangle
- type IntersectsVector3
- type OBJReader
- type OBJWriter
- type Octree
- type PolygonSoup
- func (m *PolygonSoup) GetFace(id int) []int
- func (m *PolygonSoup) GetFacePatch(id int) int
- func (m *PolygonSoup) GetNumberOfFaces() int
- func (m *PolygonSoup) GetNumberOfPatches() int
- func (m *PolygonSoup) GetNumberOfVertices() int
- func (m *PolygonSoup) GetPatch(id int) string
- func (m *PolygonSoup) GetVertex(id int) Vector3
- func (m *PolygonSoup) InsertFace(vertices []int) int
- func (m *PolygonSoup) InsertFaceWithPatch(vertices []int, patch int) int
- func (m *PolygonSoup) InsertPatch(name string) int
- func (m *PolygonSoup) InsertVertex(vertex Vector3) int
- type Ray
- type Sphere
- type Triangle
- type Vector3
- func (v Vector3) Add(u Vector3) Vector3
- func (v Vector3) AddScalar(s float64) Vector3
- func (v Vector3) AngleTo(u Vector3) float64
- func (v Vector3) Cross(u Vector3) Vector3
- func (v Vector3) Div(u Vector3) Vector3
- func (v Vector3) DivScalar(s float64) Vector3
- func (v Vector3) Dot(u Vector3) float64
- func (v Vector3) IntersectsAABB(a AABB) bool
- func (v Vector3) IntersectsSphere(s Sphere) bool
- func (v Vector3) Inv() Vector3
- func (v Vector3) Mag() float64
- func (v Vector3) Mul(u Vector3) Vector3
- func (v Vector3) MulScalar(s float64) Vector3
- func (v Vector3) Sub(u Vector3) Vector3
- func (v Vector3) SubScalar(s float64) Vector3
- func (v Vector3) Unit() Vector3
- func (v Vector3) X() float64
- func (v Vector3) Y() float64
- func (v Vector3) Z() float64
Constants ¶
const ( OctreeMaxDepth int = 21 OctreeMaxItemsPerNode int = 100 )
const (
GeometricTolerance float64 = 1e-8
)
Variables ¶
var ( ErrNonManifoldMesh = errors.New("non-manifold mesh") ErrOpenMesh = errors.New("mesh must be closed") )
var ( ErrInvalidVertex = errors.New("invalid vertex") ErrInvalidFace = errors.New("invalid face") )
Functions ¶
This section is empty.
Types ¶
type AABB ¶
Three dimensional Cartesian axis-aligned bounding box
func (AABB) IntersectsAABB ¶
Check for an intersection with an AABB
func (AABB) IntersectsRay ¶
Check for an intersection with a Ray
func (AABB) IntersectsSphere ¶
Check for an intersection with a Sphere
func (AABB) IntersectsTriangle ¶
Check for an intersection with a Triangle
func (AABB) IntersectsVector3 ¶
Check for an intersection with a Vector3
type HEHalfEdge ¶
Half edge mesh half edge
func (HEHalfEdge) IsBoundary ¶
func (e HEHalfEdge) IsBoundary() bool
Get if the half edge is a boundary (no twin)
type HEMesh ¶
type HEMesh struct {
// contains filtered or unexported fields
}
func NewHEMeshFromOBJ ¶
Construct a half edge mesh from an OBJ file reader
func NewHEMeshFromOBJFile ¶
Construct a half edge mesh from an OBJ file
func NewHEMeshFromPolygonSoup ¶
func NewHEMeshFromPolygonSoup(soup *PolygonSoup) (*HEMesh, error)
Construct a half edge mesh from a PolygonSoup
func (*HEMesh) ExportOBJFile ¶
Export the mesh to an OBJ file
func (*HEMesh) ExtractFaces ¶
Extract a subset of the mesh by face IDs
func (*HEMesh) ExtractPatchNames ¶
Extract a subset of the mesh by patch names
func (*HEMesh) ExtractPatches ¶
Extract a subset of the mesh by patch IDs
func (*HEMesh) GetComponents ¶
Get the distinct components (connected faces). Each component is defined by the indices of the faces.
func (*HEMesh) GetFaceHalfEdges ¶
Get the half edges of the face by ID
func (*HEMesh) GetFaceNeighbors ¶
Get the neighboring faces for a face by ID
func (*HEMesh) GetFaceNormal ¶
Get the unit normal vector of the face by ID
func (*HEMesh) GetFaceVertices ¶
Get the vertices defining the face by ID
func (*HEMesh) GetHalfEdge ¶
func (m *HEMesh) GetHalfEdge(id int) HEHalfEdge
Get the half edge by ID
func (*HEMesh) GetNumberOfHalfEdges ¶
Get the number of half edges
func (*HEMesh) GetNumberOfPatches ¶
Get the number of patches
func (*HEMesh) GetNumberOfVertices ¶
Get the number of vertices
func (*HEMesh) GetPatchFaces ¶
Get the faces assigned to the patch by ID
func (*HEMesh) GetPatchNames ¶
Get the list of patch names
func (*HEMesh) GetVertexCurvature ¶
Get the Gaussian curvature at the vertex by ID. This assumes the mesh is composed of strictly triangular elements and is oriented.
func (*HEMesh) GetVertexFaces ¶
Get the faces using the vertex by ID
func (*HEMesh) GetVertexNeighbors ¶
Get the neighboring vertices for a vertex by ID
func (*HEMesh) IsConsistent ¶
Check if the half edge mesh has consistently oriented faces
func (*HEMesh) IsVertexOnBoundary ¶
Get if the vertex is on a boundary. This assumes the mesh is consistently oriented. For inconsistent meshes, this may yield incorrect results.
func (*HEMesh) Merge ¶
Naively copy another half edge mesh into the current. This does not merge any duplicate vertices or faces.
type IntersectsAABB ¶
Interface for an AABB intersection test
type IntersectsRay ¶
Interface for a Ray intersection test
type IntersectsSphere ¶
Interface for a Sphere intersection test
type IntersectsTriangle ¶
Interface for a Triangle intersection test
type IntersectsVector3 ¶
Interface for a Vector3 intersection test
type OBJReader ¶
type OBJReader struct {
// contains filtered or unexported fields
}
func NewOBJReader ¶
func NewOBJReader() *OBJReader
type OBJWriter ¶
type OBJWriter struct {
// contains filtered or unexported fields
}
Write an OBJ file to an io.Writer interface
func NewOBJWriter ¶
func NewOBJWriter() *OBJWriter
func (*OBJWriter) SetFaceGroups ¶
Set the groups of each face to write. This must be the same length as the faces. Any faces that are not assigned to a group must specify -1.
func (*OBJWriter) SetVertices ¶
Set the vertices to write
type Octree ¶
type Octree struct {
// contains filtered or unexported fields
}
Linear octree implementation
func (*Octree) GetNumberOfItems ¶
Get the number of indexed items
func (*Octree) Insert ¶
func (o *Octree) Insert(item IntersectsAABB) (int, bool)
Insert an item into the octree
func (*Octree) Query ¶
func (o *Octree) Query(query IntersectsAABB) []int
Query the octree for intersecting items
func (*Octree) QueryMany ¶
func (o *Octree) QueryMany(queries []IntersectsAABB) [][]int
Query the octree for many intersecting items in parallel using the available number of processors.
type PolygonSoup ¶
type PolygonSoup struct {
// contains filtered or unexported fields
}
func NewPolygonSoup ¶
func NewPolygonSoup() *PolygonSoup
func (*PolygonSoup) GetFace ¶
func (m *PolygonSoup) GetFace(id int) []int
Get a face's ordered set of vertices by face ID
func (*PolygonSoup) GetFacePatch ¶
func (m *PolygonSoup) GetFacePatch(id int) int
Get a face's patch by face ID
func (*PolygonSoup) GetNumberOfFaces ¶
func (m *PolygonSoup) GetNumberOfFaces() int
Get the number of faces
func (*PolygonSoup) GetNumberOfPatches ¶
func (m *PolygonSoup) GetNumberOfPatches() int
Get the number of patches
func (*PolygonSoup) GetNumberOfVertices ¶
func (m *PolygonSoup) GetNumberOfVertices() int
Get the number of vertices
func (*PolygonSoup) InsertFace ¶
func (m *PolygonSoup) InsertFace(vertices []int) int
Insert a face. By default, the patch is empty.
func (*PolygonSoup) InsertFaceWithPatch ¶
func (m *PolygonSoup) InsertFaceWithPatch(vertices []int, patch int) int
Insert a face with a patch
func (*PolygonSoup) InsertVertex ¶
func (m *PolygonSoup) InsertVertex(vertex Vector3) int
Insert a vertex
type Ray ¶
Three dimension Cartesian ray
func (Ray) IntersectsAABB ¶
Check for an intersection with an AABB
func (Ray) IntersectsTriangle ¶
Check for an intersection with a Triangle
type Sphere ¶
Three-dimensional Cartesian sphere
func (Sphere) IntersectsAABB ¶
Check for an intersection with an AABB
func (Sphere) IntersectsVector3 ¶
Check for an intersection with a Vector
type Triangle ¶
type Triangle [3]Vector3
Three dimensional Cartesian triangle
func (Triangle) IntersectsAABB ¶
Check for an intersection with an AABB
func (Triangle) IntersectsRay ¶
Check for an intersection with a Ray
type Vector3 ¶
type Vector3 [3]float64
Three-dimensional Cartesian vector
func (Vector3) IntersectsAABB ¶
Check for an intersection with an AABB
func (Vector3) IntersectsSphere ¶
Check for an intersection with a Sphere