elm-triangular-mesh

Generic indexed triangular mesh data structure for Elm

MPL-2.0 License

Stars
8
Committers
1

Bot releases are visible (Hide)

elm-triangular-mesh - 1.1.0 Latest Release

Published by ianmackenzie about 4 years ago

This release brings some new functions for conveniently creating meshes of various common forms without having to use the general TriangularMesh.indexed constructor. The simplest function is grid:

TriangularMesh.grid : Int -> Int -> (Float -> Float -> vertex) -> TriangularMesh vertex

This lets you easily create meshes in the form of rectangular grids, by passing the number of steps to take in the U (horizontal) and V (vertical) directions, and a function that will get called to create vertices at different U and V values (which each range from 0 to 1). For example, TriangularMesh.grid 3 2 f will produce a mesh like

Rectangular grid

There are also tube, ring and ball functions (with the same function signature as grid) for creating meshes that are topologically equivalent to a cylinder, torus and sphere respectively (where the mesh 'wraps around' in certain directions).

In addition, each of the above functions comes in an indexed version, for example:

TriangularMesh.indexedGrid : Int -> Int -> (Int -> Int -> vertex) -> TriangularMesh vertex

The indexed versions behave exactly the same, but instead of passing floating-point U/V values to the callback function, they pass integer U/V indices:

Rectangular grid

Finally, a TriangularMesh.radial function has been added that behaves just like TriangularMesh.fan, but joins the last vertex back to the first to form a closed shape (useful for creating cone-like shapes):

TriangularMesh.radial : vertex -> List vertex -> TriangularMesh vertex
elm-triangular-mesh - 1.0.4

Published by ianmackenzie almost 5 years ago

Update README and add simple usage example

elm-triangular-mesh - 1.0.3

Published by ianmackenzie almost 5 years ago

Add title to README to match style used by other packages

elm-triangular-mesh - 1.0.1

Published by ianmackenzie over 6 years ago

Update image link in documentation.

elm-triangular-mesh - Initial release (ported from opensolid/mesh)

Published by ianmackenzie over 6 years ago

This is largely a direct transfer from opensolid/mesh, but involves a few breaking changes:

  • The module name has changed from OpenSolid.Mesh to TriangularMesh.
  • with has been replaced by indexed
  • faces has been renamed to faceVertices
  • edges has been renamed to edgeVertices

In addition, the triangles, fan and strip constructors have been added to aid in generating meshes of different shapes.