Terra 1.0
TerraVertex Class Reference

A point primitive. More...

#include <archestree.h>

Inheritance diagram for TerraVertex:
TerraPrimitive TerraNode TerraVertexNoise TerraVertexNoiseRydge

Public Member Functions

 TerraVertex (const Vector &, const double &, const double &=1.0)
 Create a flat point primitive.
 TerraVertex (const Vector &, const Vector &, const double &, const double &=1.0)
 Create an inclined disc primitive, defined by its normal.
 TerraVertex (const Vector &, const Vector2 &, const double &, const double &=1.0)
 Create an inclined disc primitive, defined by its slope.
virtual ScalarAlpha ElevationAlpha (const Vector2 &) const
virtual int Memory () const
 Compute the size of a node.
virtual TerraNode * Copy () const
virtual void Draw (QGraphicsScene &) const
 Renders the node into a QGraphicsScene.
Public Member Functions inherited from TerraPrimitive
 TerraPrimitive (const double &=1.0, const double &=1.0)
 Create a primitive.
 ~TerraPrimitive ()
 Recusively destroy the sub-trees.
int Traversal (const Vector2 &) const
 Compute the number of nodes that are traversed when evaluating the tree.
double Alpha (const double &) const
 Compute the falloff function.
Public Member Functions inherited from TerraNode
 TerraNode (const Box2 &=Box2::Infinity)
 Create a node.
virtual Box2 GetBox () const
 Returns the bouding box of a node.
virtual double Elevation (const Vector2 &) const
 Compute the elevation at a given position.
virtual double Alpha (const Vector2 &) const
 Compute the alpha mask at a given position.
virtual Vector2 Gradient (const Vector2 &) const
 Compute the gradient at a given position.
virtual Vector Normal (const Vector2 &) const
 Compute the normal at a given position.
virtual void writeJson (QJsonObject &)
 Compute the Json Document of the subtree.
ScalarField2 Sample (const Array2 &) const
 Create a discrete scalar field by sampling the elevation over a given domain.
ScalarField2 Alpha (const Array2 &) const
 Create a discrete scalar field by sampling the elevation over a given domain.
void Blend (HeightField &) const
 Blend a given node with an existing terrain over an input heightfield.
void Add (HeightField &) const
 Add a given node with an existing heightfield.

Protected Attributes

Vector c
 Center, includes elevation.
Vector2 slope
 Slope along x and y directions.
Protected Attributes inherited from TerraPrimitive
double alpha = 1.0
 Weight.
Protected Attributes inherited from TerraNode
Box2 box = Box2::Infinity
 Infinite bounding box.

Additional Inherited Members

Static Protected Attributes inherited from TerraNode
static const double epsilon = 1e-2
 Epsilon value for gradient computations.

Detailed Description

A point primitive.

Constructor & Destructor Documentation

◆ TerraVertex() [1/3]

TerraVertex::TerraVertex ( const Vector & c,
const double & r,
const double & a = 1.0 )
explicit

◆ TerraVertex() [2/3]

TerraVertex::TerraVertex ( const Vector & c,
const Vector & n,
const double & r,
const double & a = 1.0 )
explicit

Create an inclined disc primitive, defined by its normal.

The elevation is defined by the plane going through the center c, and orthogonal to the normal n:

\[ z(x,y) = c_z - \frac{n_x (x - c_x) + n_y (y - c_y)}{n_z} \]

which corresponds to the slope vector \( s = -(n_x, n_y) / n_z \) (see the constructor with a slope vector).

The normal does not need to be unit, as only the ratios \( n_x / n_z \) and \( n_y / n_z \) matter, and its orientation (upward or downward) is irrelevant as \( n \) and \( -n \) define the same plane. However, the plane should not be vertical, so that the z component of the normal should not be null.

Parameters
cCenter, the elevation is its z coordinate.
nNormal to the plane, not necessarily unit, with a non null z component.
rRadius.
aAlpha.

References c, and TerraVertex().

◆ TerraVertex() [3/3]

TerraVertex::TerraVertex ( const Vector & c,
const Vector2 & s,
const double & r,
const double & a = 1.0 )
explicit

Create an inclined disc primitive, defined by its slope.

The elevation is \( z(p) = c_z + s \cdot (p - c) \).

Parameters
cCenter, the elevation is its z coordinate.
sSlope vector, the partial derivatives of the elevation along the x and y axes.
rRadius.
aAlpha.

References TerraNode::box, Box2::Box2(), c, slope, and TerraPrimitive::TerraPrimitive().

Member Function Documentation

◆ Copy()

TerraNode * TerraVertex::Copy ( ) const
virtual

Reimplemented from TerraNode.

Reimplemented in TerraVertexNoise, and TerraVertexNoiseRydge.

References TerraPrimitive::alpha, c, slope, and TerraVertex().

◆ Draw()

void TerraVertex::Draw ( QGraphicsScene & scene) const
virtual

Renders the node into a QGraphicsScene.

Draws the box.

Parameters
sceneThe scene.

Reimplemented from TerraNode.

References c, and Circle2::Circle2().

◆ ElevationAlpha()

ScalarAlpha TerraVertex::ElevationAlpha ( const Vector2 & p) const
virtual

◆ Memory()

int TerraVertex::Memory ( ) const
virtual

Compute the size of a node.

Reimplemented from TerraNode.

Reimplemented in TerraVertexNoise, and TerraVertexNoiseRydge.

References TerraVertex().