Previous topic

civpy.survey.SurveyPoint.copy

Next topic

civpy.survey.TIN.barycentric_coords

This Page

civpy.survey.TIN

class civpy.survey.TIN(name, points=[], breaklines=[], max_edge=None, step=0.1, grid=10)[source]

A class for creating triangulated irregular networks (TIN) models for 3D surfaces. Includes methods for performing elevation and distance queries.

Parameters:
name : str

The name of the model.

points : array

An array of points of shape (N, 3).

breaklines : list

A list of arrays of points representing breakline polylines.

max_edge : float

The maximum edge length beyond which simplices will not be included in the triangulation. If None, no simplices will be removed.

step : float

The setup interval for generated points along breaklines.

grid : float

The grid spacing used for the created spatial hash.

Examples

The following example creates a TIN model in the shape of a pyramid then performs distances queries to its surface:

# tin_ex1.py
import numpy as np
from civpy.survey import TIN

# TIN points
p = np.array([
    (-0.5, -0.5,   0),
    ( 0.5, -0.5,   0),
    ( 0.5,  0.5,   0),
    (-0.5,  0.5,   0),
    (   0,    0, 0.5)
])

t = TIN('Distance Query', p)
ax = t.plot_surface_3d()

# Query points
q = np.array([
    (  0, 0,   1),
    (0.5, 0, 0.5),
    (  1, 0,   0)
])

ax.plot(q[:,0], q[:,1], q[:,2], 'r.')

for i, x in enumerate(q):
    _, r = t.query_distances(x, 5)
    r = np.column_stack([x, r[0]])
    ax.text(x[0], x[1], x[2], i)
    ax.plot(r[0], r[1], r[2], 'r-')

(Source code, png, hires.png, pdf)

../_images/tin_ex1.png

Methods

barycentric_coords(self, point, simplex) Returns the local barycentric coordinates for the input point.
breakpoints(self) Returns an array of breakpoints for the assigned breaklines.
elevation(self, point) Returns the elevation of the TIN surface at the input point.
find_simplices(self, points) Finds the simplices which contain the (x, y) point.
normal(self, simplex) Returns the normal vector for the specified simplex.
plot_contour_2d(self[, ax, cmap]) Plots a the rendered TIN surface in 3D
plot_surface_2d(self[, ax]) Plots a the triangulation in 2D.
plot_surface_3d(self[, ax, cmap]) Plots a the rendered TIN surface in 3D
query_distances(self, point, radius) Finds the closest distances to all simplices within the specified xy-plane radius.
query_simplices(self, point, radius) Returns the indices of all simplices that have a corner within the specified radius of the input point.