tri

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2017 License: BSD-3-Clause Imports: 5 Imported by: 0

README

Gosl. gm/tri. Mesh generation: triangles

GoDoc

More information is available in the documentation of this package.

The tri package has functions go generate meshes of triangular elements and Delaunay triangulations. The package is a light wrapper to the very efficient Triangle code by Jonathan Shewchuk and available at the Triangle website.

Triangle's licence details are in the triangle_README.txt file.

In addition of being very fast, Triangle can generate meshes with great quality; i.e. it is a quality-mesh triangulator.

Here, the Cartesian coordinates of points are stored in continuous 1D arrays (slices) such as:

X = { x0, x1, x2, ... Npoints }
Y = { y0, y1, y2, ... Npoints }

The topology is simply defined by two slices usually named V for vertices and C for cells (triangles):

V = { { x0, y0 }, { x1, y1 }, { x2, y2 } ... Nvertices }
C = { { id0, id1, id2 }, { id0, id1, id2 } ... Ncellls }

where V is the list of vertices (there are Nvertices vertices) and C is the list of triangles (there are Ncells triangles). The ids (e.g. id0, id1, id2) in C are the indices in V.

Draw mesh

For example, the set of triangles in the above figure are defined (and drawn) with:

// vertices (points)
V := [][]float64{
    {0, 0}, {1, 0},
    {1, 1}, {0, 1},
}

// cells (triangles)
C := [][]int{
    {0, 1, 2},
    {2, 3, 0},
}

Source code: ../../examples/tri_draw01.go

Delaunay triangulation

The Delaunay triangulation of a cloud of points in the tri package is easily computed with the Delaunay command that takes as input the Cartesian coordinates.

Source code: ../../examples/tri_delaunay01.go

Documentation

Overview

Package tri wraps Triangle to perform mesh generation a Delaunay triangulation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delaunay

func Delaunay(X, Y []float64, verbose bool) (V [][]float64, C [][]int)

Delaunay computes 2D Delaunay triangulation using Triangle

Input:
  X = { x0, x1, x2, ... Npoints }
  Y = { y0, y1, y2, ... Npoints }
Ouptut:
  V = { { x0, y0 }, { x1, y1 }, { x2, y2 } ... Nvertices }
  C = { { id0, id1, id2 }, { id0, id1, id2 } ... Ncellls }

func Draw

func Draw(V [][]float64, C [][]int, style *plt.A)

Draw draws mesh with given vertices in V (coordinates) and cells in C (connectivity)

Types

This section is empty.

Jump to

Keyboard shortcuts

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