genmarchingcubes

package
v0.0.0-...-ce97658 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

README

genmarchingcubes

This package is an implementation of the marching cubes algorithm, which takes a voxel field and generates a surface mesh.

Right now it is almost a straight fork of

... but will be modified more heavily in future versions.

alt text

alt text

alt text

References

Documentation

Overview

Package genmarchingcubes implements the marching cubes algorithm.

Algorithm: * https://en.wikipedia.org/wiki/Marching_cubes

This implementation is based on: * https://github.com/soypat/sdf/blob/main/render/marchingcubes.go * https://github.com/fogleman/mc/blob/master/mc.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportToOBJ

func ExportToOBJ(filename string, tri []Triangle) error

func Interpolate

func Interpolate(p1, p2 vectors.Vec3, v1, v2, x float64) vectors.Vec3

Interpolate returns the point that is close enough to the threshold value or interpolates between the two points if the threshold is between the two points. Inspired by: https://github.com/soypat/sdf/blob/main/render/marchingcubes.go

Types

type Triangle

type Triangle struct {
	V1, V2, V3 vectors.Vec3
}

func MarchingCubesGrid

func MarchingCubesGrid(w, h, d int, data []float64, value float64) []Triangle

MarchingCubesGrid traverses the data grid with the given width, height, and depth, and evaluates each cube and returns the relevant triangles to represent the grid.

func Polygonize

func Polygonize(p [8]vectors.Vec3, v [8]float64, x float64) []Triangle

Polygonize returns the triangles that represent the given cube represented by the given vectors and values.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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