Skip to content
Triangulation

Triangulation

Mojo struct 🡭

Triangulation

@memory_only
struct Triangulation

Triangles over a point set, as flat index triples.

xs/ys are the input points in their original order, so a caller can index its own z column with the same index. triangles holds three vertex indices per triangle, so triangle t is triangles[3*t], triangles[3*t + 1], triangles[3*t + 2].

Public since #397: a caller who owns the triangle order can index a per-triangle value column against it, which is what tripcolor(facecolors=...) needs.

Fields

  • x (List[Float64])
  • y (List[Float64])
  • triangles (List[Int])

Implemented traits

AnyType, Copyable, Deinitable, Movable

Methods

__init__

fn def __init__(out self)

Args:

  • self (Self)

Returns:

Self

fn def __init__(out self, x: List[Float64], y: List[Float64], triangles: List[Int])

Build from a caller’s own triangle list rather than by triangulating (#397).

The point of a public type: a caller who supplied the triangles knows their order, and can therefore index a per-triangle value column against them. A triangulation this package computed has an order that is an artifact of Bowyer-Watson’s insertion sequence, which nobody outside can predict.

Args:

  • x (List[Float64]): Point x coordinates.
  • y (List[Float64]): Point y coordinates, one per x.
  • triangles (List[Int]): Three vertex indices per triangle, flat.
  • self (Self)

Returns:

Self

Raises:

Error: Mismatched point columns, a triangle count that is not a multiple of three, or an index outside the points.

count

fn def count(self) -> Int

How many triangles.

Args:

  • self (Self)

Returns:

Int: len(tri) // 3.