Skip to content

ssqpy.model.terrain

terrain

Submodule containing the Terrain class, used to define the 3D terrain
that the system model acts in. By default, this is the predefined
FlatTerrain class.

TerrainPoint

TerrainPoint()

A point on the terrain surface: its height, surface frame and height derivatives.

height property writable

height

Height of the terrain.

normal property writable

normal

Unit normal of the terrain surface.

t1 property writable

t1

First unit tangent of the terrain surface, along x.

t2 property writable

t2

Second unit tangent of the terrain surface, the normal crossed with t1.

dhdx property writable

dhdx

Slope of the height along x.

dhdy property writable

dhdy

Slope of the height along y.

d2hdx2 property writable

d2hdx2

Second derivative of the height along x.

d2hdxdy property writable

d2hdxdy

Mixed second derivative of the height along x and y.

d2hdy2 property writable

d2hdy2

Second derivative of the height along y.

from_height staticmethod

from_height(height, dhdx, dhdy, d2hdx2=0.0, d2hdxdy=0.0, d2hdy2=0.0)

Builds a point from the height and its derivatives, using the frame convention required by contact constraints: normal = (-dhdx, -dhdy, 1) normalized, t1 = (1, 0, dhdx) normalized, t2 = normal x t1.

Terrain

Terrain()

Base class for terrains. Subclasses implement at, and optionally distance.

at

at(x, y)

Returns the terrain point at the horizontal position (x, y).

distance

distance(x, y, z)

Returns the distance of a point above the terrain, by default its height above the terrain at its horizontal position.

FlatTerrain

FlatTerrain(base_height=0.0)

Bases: Terrain

Flat terrain at a constant height.

SlopeTerrain

SlopeTerrain(slope_x, slope_y=0.0, base_height=0.0)

Bases: Terrain

Slope terrain
Height is \(h = h_0 + s_x x + s_y y\), where \(s_x\) and \(s_y\) are the slopes
along the x and y axes (rise over run)

StepTerrain

StepTerrain(x_start, step_height, step_length=1.0, num_steps=1, base_height=0.0)

Bases: Terrain

Piecewise flat terrain with a flight of steps along the x axis

Height is base_height for \(x < x_{start}\), then rises by step_height at
x_start and every step_length after that, for num_steps steps in total

The terrain stays at the top step height afterwards; with the default of a
single step, step_length has no effect

HeightmapTerrain

HeightmapTerrain(heights, resolution, x0=0.0, y0=0.0)

Bases: Terrain

Smooth terrain interpolated from a uniform grid of heights
heights(i, j) is the height at \((x_0 + i r, y_0 + j r)\), where \(r\) is the
grid resolution

Heights are interpolated with a bicubic Catmull-Rom spline, which passes
through every grid height and has continuous height and slope

The height second derivatives are piecewise continuous

Outside the grid, the terrain extends flat from its closest edge value

set_heights

set_heights(heights, x0=0.0, y0=0.0)

Replaces the grid of heights and its origin, keeping the resolution. The grid may change size. Models using this terrain see the new heights from their next evaluation, so this must not be called while a solver is using such a model.