# Module Geometry

## Scenes

# ** VPL.Geom.Scene** —

*Type*.

`Scene(graph, Float64)`

Create a 3D scene from a `Graph`

object (`g`

). By default, double floating precision will be used (`Float64`

) but it is possible to generate a version with a different precision by specifying the corresponding type as in `Scene(g, Float32)`

. The Scene object contains a mesh of triangles as well as colors and materials associated to each primitive.

`Scene(scenes)`

Merge multiple `Scene`

objects into one.

# ** VPL.add!** —

*Function*.

`add!(scene; mesh, color = nothing, material = nothing)`

Manually add a 3D mesh to an existing `Scene`

object (`scene`

) with optional colors and materials

# ** VPL.Geom.colors** —

*Method*.

`colors(scene::Scene)`

Extract the vector of `Colorant`

objects stored inside a scene (used for rendering)

# ** VPL.Geom.mesh** —

*Method*.

`mesh(scene::Scene)`

Extract the triangular mesh stored inside a scene (used for ray tracing & rendering)

# ** VPL.Geom.materials** —

*Method*.

`materials(scene::Scene)`

Extract the vector of `Material`

objects stored inside a scene (used for ray tracing)

## Turtle geometry

# ** VPL.Geom.Turtle** —

*Method*.

`Turtle(Float64, message)`

Create a meshing turtle that can convert a `Graph`

into a 3D mesh using turtle operators, geometry primitives and methods of `feed!()`

. By default, the meshing turtle will generate geometry primitives with double floating precision (`Float64`

) but it is possible to generate a version with lower precision as in `Turtle(Float32)`

. The argument `message`

is any user-defined object.

# ** VPL.Geom.head** —

*Method*.

`head(turtle)`

Extract the direction vector (a `Vec`

object) of the head of the turtle.

# ** VPL.Geom.up** —

*Method*.

`up(turtle)`

Extract the direction vector (a `Vec`

object) of the back of the turtle.

# ** VPL.Geom.arm** —

*Method*.

`arm(turtle)`

Extract the direction vector (a `Vec`

object) of the arm of the turtle.

# ** VPL.Geom.pos** —

*Method*.

`pos(turtle)`

Extract the current position of the turtle (a `Vec`

object).

# ** VPL.Geom.geoms** —

*Method*.

`geoms(turtle)`

Extract the 3D mesh generated by the turtle (a `Mesh`

object).

# ** VPL.Geom.colors** —

*Method*.

`colors(turtle)`

Extract the color objects associated to each geometry primitive that was fed to the turtle.

# ** VPL.Geom.faces** —

*Method*.

`geoms(turtle)`

Extract the faces of the 3D mesh generated by the turtle.

# ** VPL.Geom.materials** —

*Method*.

`materials(turtle)`

Extract the material objects associated to each geometry primitive that was fed to the turtle.

# ** VPL.Geom.feed!** —

*Function*.

`feed!(turtle::Turtle; mesh::Mesh, color::Colorant = nothing, mat::Material = nothing)`

General purpose method to feed a mesh to a turtle together with color and material. Note that all primitives provided by VPL are implemented as meshes, but this is a generic method for meshes that are constructed directly by the user or imported from external software.

`feed!(turtle::Turtle, node::Node, vars = nothing)`

Default method for `feed!()`

that does not do anything. This allows the user to include nodes in a graph without an associated geometry.

`feed!(turtle::Turtle, g::Graph)`

Process a `Graph`

object with a turtle and generate the corresponding 3D mesh from executing the different `feed!()`

methods associated to the nodes in the graph.

```
feed!(turtle::Turtle, collection::AbstractArray)
feed!(turtle::Turtle, collection::Tuple)
```

Feed a turtle an array or tuple of objects (`collection`

) with existing `feed!()`

methods.

# ** VPL.Geom.T** —

*Type*.

`T(to::Vec)`

Node that translates a turtle to the new position `to`

(a `Vec`

object).

# ** VPL.Geom.t!** —

*Method*.

`t!(turtle; to = O())`

Translate a turtle to the new position `to`

(a `Vec`

object).

# ** VPL.Geom.OR** —

*Type*.

`OR(head::Vec, up::Vec, arm::Vec)`

Node that orients a turtle to a new direction by re-defining the local reference system.

# ** VPL.Geom.or!** —

*Method*.

`or!(turtle; head = Z(), up = X(), arm = Y())`

Orient a turtle to a new direction by re-defining the local reference system. The arguments `head`

, `up`

and `arm`

should be of type `Vec`

.

# ** VPL.Geom.SET** —

*Type*.

`SET(to, head, up, arm)`

Node that sets the position and orientation of a turtle.

# ** VPL.Geom.set!** —

*Method*.

`set!(turtle; to = O(), head = Z(), up = X(), arm = Y())`

Set position and orientation of a turtle. The arguments `to`

, `head`

, `up`

and `arm`

should be of type `Vec`

and be passed as keyword arguments.

# ** VPL.Geom.RU** —

*Type*.

`RU(angle)`

Node that rotates a turtle around up axis. Angle must be in hexadecimal degrees and the rotation is clockwise.

# ** VPL.Geom.ru!** —

*Method*.

`ru!(turtle, angle)`

Rotates a turtle around up axis. Angle must be in hexadecimal degrees and the rotation is clockwise.

# ** VPL.Geom.RA** —

*Type*.

`RA(angle)`

Node that rotates a turtle around arm axis. Angle must be in hexadecimal degrees and the rotation is clockwise.

# ** VPL.Geom.ra!** —

*Method*.

`ra!(turtle, angle)`

Rotates a turtle around arm axis. Angle must be in hexadecimal degrees and the rotation is clockwise.

# ** VPL.Geom.RH** —

*Type*.

`RH(angle)`

Node that rotates a turtle around head axis. Angle must be in hexadecimal degrees and the rotation is clockwise.

# ** VPL.Geom.rh!** —

*Method*.

`rh!(turtle, angle)`

Rotate turtle around head axis. Angle must be in hexadecimal degrees and the rotation is clockwise.

# ** VPL.Geom.F** —

*Type*.

`F(dist)`

Moves a turtle forward a given distance.

# ** VPL.Geom.f!** —

*Method*.

`f!(turtle, dist)`

Move turtle forward a given distance.

# ** VPL.Geom.RV** —

*Type*.

`RV(strength)`

Rotates the turtle towards the Z axis. See documentation for `rv!`

for details.

# ** VPL.Geom.rv!** —

*Method*.

`rv!(turtle, strength)`

Rotates the turtle towards the Z axis. The angle of rotation is proportional to the cosine of the zenith angle of the turtle (i.e., angle between its head and the vertical axis) with the absolute value of `strength`

being the proportion between the two. `strength`

should vary between -1 and 1. If `strength`

is negative, the turtle rotates downwards (i.e., towards negative values of Z axis), otherwise upwards.

## 3D vectors

# ** VPL.Geom.Vec** —

*Type*.

`Vec(x, y, z)`

3D vector or point with coordinates x, y and z.

# ** VPL.Geom.O** —

*Method*.

`O()`

Returns the origin of the 3D coordinate system as a `Vec`

object. By default, the coordinates will be in double floating precision (`Float64`

) but it is possible to generate a version with lower floating precision as in `O(Float32)`

.

# ** VPL.Geom.X** —

*Method*.

`X()`

Returns an unit vector in the direction of the X axis as a `Vec`

object. By default, the coordinates will be in double floating precision (`Float64`

) but it is possible to generate a version with lower floating precision as in `X(Float32)`

.

# ** VPL.Geom.Y** —

*Method*.

`Y()`

Returns an unit vector in the direction of the Y axis as a `Vec`

object. By default, the coordinates will be in double floating precision (`Float64`

) but it is possible to generate a version with lower floating precision as in `Y(Float32)`

.

# ** VPL.Geom.Z** —

*Method*.

`Z()`

Returns an unit vector in the direction of the Z axis as a `Vec`

object. By default, the coordinates will be in double floating precision (`Float64`

) but it is possible to generate a version with lower floating precision as in `Z(Float32)`

.

# ** VPL.Geom.X** —

*Method*.

`X(s)`

Returns scaled vector in the direction of the X axis with length `s`

as a `Vec`

object using the same floating point precision as `s`

.

# ** VPL.Geom.Y** —

*Method*.

`Y(s)`

Returns scaled vector in the direction of the Y axis with length `s`

as a `Vec`

object using the same floating point precision as `s`

.

# ** VPL.Geom.Z** —

*Method*.

`Z(s)`

Returns scaled vector in the direction of the Z axis with length `s`

as a `Vec`

object using the same floating point precision as `s`

.

## Geometry primitives

### Triangle

# ** VPL.Geom.Triangle** —

*Method*.

`Triangle(;length = 1.0, width = 1.0`

Create a triangle with dimensions given by `length`

and `width`

, standard location and orientation.

# ** VPL.Geom.Triangle!** —

*Method*.

```
Triangle!(turtle; length = 1.0, width = 1.0, move = false,
= nothing, color = nothing) material
```

Generate a triangle in front of the turtle and feed it to a turtle.

**Arguments**

`turtle`

: The turtle that we feed the triangle to.`length`

: Length of the triangle.`width`

: Width of the triangle.`move`

: Whether to move the turtle forward or not (`true`

or`false`

).`material`

: The material object for the ray tracer (optional).`color`

: The color of the ellipse for rendering (optional).

**Details**

A triangle mesh will be generated representing the triangle. The triangle will be generated in front of the turtle, on the plane defined by the arm and head axes of the turtle. The argument `length`

refers to the axis of the triangle aligned with the head axis of the turtle, whereas `width`

refers to the orthogonal axis.

When `move = true`

, the turtle will be moved forward by a distance equal to `length`

.

The material object must inherit from `Material`

(see ray tracing documentation for detail) and the color can be any type that inherits from `Colorant`

(from ColorTypes.jl).

**Return**

Returns `nothing`

but modifies the `turtle`

as a side effect.

### Rectangle

# ** VPL.Geom.Rectangle** —

*Method*.

`Rectangle(;length = 1.0, width = 1.0)`

Create a rectangle with dimensions given by `length`

and width, standard location and orientation.

# ** VPL.Geom.Rectangle!** —

*Method*.

```
Rectangle!(turtle; length = 1.0, width = 1.0, move = false,
= nothing, color = nothing) material
```

Generate a rectangle in front of the turtle and feed it to a turtle.

**Arguments**

`turtle`

: The turtle that we feed the rectangle to.`length`

: Length of the rectangle.`width`

: Width of the rectangle.`move`

: Whether to move the turtle forward or not (`true`

or`false`

).`material`

: The material object for the ray tracer (optional).`color`

: The color of the ellipse for rendering (optional).

**Details**

A triangle mesh will be generated representing the rectangle. The rectangle will be generated in front of the turtle, on the plane defined by the arm and head axes of the turtle. The argument `length`

refers to the axis of the rectangle aligned with the head axis of the turtle, whereas `width`

refers to the orthogonal axis.

When `move = true`

, the turtle will be moved forward by a distance equal to `length`

.

The material object must inherit from `Material`

(see ray tracing documentation for detail) and the color can be any type that inherits from `Colorant`

(from ColorTypes.jl).

**Return**

Returns `nothing`

but modifies the `turtle`

as a side effect.

### Trapezoid

# ** VPL.Geom.Trapezoid** —

*Method*.

`Trapezoid(;length = 1.0, width = 1.0, ratio = 1.0)`

Create a trapezoid with dimensions given by `length`

and the larger `width`

and the `ratio`

between the smaller and larger widths. The trapezoid is generted at the standard location and orientation.

# ** VPL.Geom.Trapezoid!** —

*Method*.

```
Trapezoid!(turtle; length = 1.0, width = 1.0, ratio = 1.0, move = false,
= nothing, color = nothing) material
```

Generate a trapezoid in front of the turtle and feed it to a turtle.

**Arguments**

`turtle`

: The turtle that we feed the trapezoid to.`length`

: Length of the trapezoid.`width`

: Width of the base of the trapezoid.`ratio`

: Ratio between the width of the top and base of the trapezoid.`move`

: Whether to move the turtle forward or not (`true`

or`false`

).`material`

: The material object for the ray tracer (optional).`color`

: The color of the ellipse for rendering (optional).

**Details**

A triangle mesh will be generated representing the trapezoid. The trapezoid will be generated in front of the turtle, on the plane defined by the arm and head axes of the turtle. The argument `length`

refers to the axis of the trapezoid aligned with the head axis of the turtle, whereas `width`

refers to the orthogonal axis.

When `move = true`

, the turtle will be moved forward by a distance equal to `length`

.

The material object must inherit from `Material`

(see ray tracing documentation for detail) and the color can be any type that inherits from `Colorant`

(from ColorTypes.jl).

**Return**

Returns `nothing`

but modifies the `turtle`

as a side effect.

### Ellipse

# ** VPL.Geom.Ellipse** —

*Method*.

`Ellipse(;length = 1.0, width = 1.0, n = 20)`

Create an ellipse with dimensions given by `length`

and `width`

, discretized into `n`

triangles (must be even) and standard location and orientation.

# ** VPL.Geom.Ellipse!** —

*Method*.

```
Ellipse!(turtle; length = 1.0, width = 1.0, n = 20, move = false,
= nothing, color = nothing) material
```

Generate an ellipse in front of a turtle and feed it to a turtle.

**Arguments**

`turtle`

: The turtle that we feed the ellipse to.`length`

: Length of the ellipse.`width`

: Width of the ellipse.`n`

: Number of triangles of the mesh approximating the ellipse (an integer).`move`

: Whether to move the turtle forward or not (`true`

or`false`

).`material`

: The material object for the ray tracer (optional).`color`

: The color of the ellipse for rendering (optional).

**Details**

A triangle mesh will be generated with `n`

triangles that approximates an ellipse. The ellipse will be generated in front of the turtle, on the plane defined by the arm and head axes of the turtle. The argument `length`

refers to the axis of the ellipse aligned with the head axis of the turtle, whereas `width`

refers to the orthogonal axis.

When `move = true`

, the turtle will be moved forward by a distance equal to `length`

.

`Material`

(see ray tracing documentation for detail) and the color can be any type that inherits from `Colorant`

(from ColorTypes.jl).

**Return**

Returns `nothing`

but modifies the `turtle`

as a side effect.

### Hollow cylinder

# ** VPL.Geom.HollowCylinder** —

*Method*.

`HollowCylinder(;length = 1.0, width = 1.0, height = 1.0, n = 40)`

Create a hollow cylinder with dimensions given by `length`

, `width`

and `height`

, discretized into `n`

triangles (must be even) and standard location and orientation.

# ** VPL.Geom.HollowCylinder!** —

*Method*.

```
HollowCylinder!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 40, move = false,
= nothing, color = nothing) material
```

Generate a hollow cylinder in front of the turtle and feed it to a turtle.

**Arguments**

`turtle`

: The turtle that we feed the hollow cylinder to.`length`

: Length of the ellipse at the base of the hollow cylinder.`width`

: Width of the ellipse at the base of the hollow cylinder.`height`

: Height of the hollow cylinder.`n`

: Number of triangles in the mesh (must be even).`move`

: Whether to move the turtle forward or not (`true`

or`false`

).`material`

: The material object for the ray tracer (optional).`color`

: The color of the ellipse for rendering (optional).

**Details**

A mesh will be generated with n triangles that approximate the hollow cylinder. The cylinder will be generated in front of the turtle, with the base on the plane defined by the arm and up axes of the turtle, centered at the head axis. The `length`

argument refers to the up axis, whereas `width`

refers to the arm axis and `height`

is associated to the head axis.

When `move = true`

, the turtle will be moved forward by a distance equal to `height`

.

`Material`

(see ray tracing documentation for detail) and the color can be any type that inherits from `Colorant`

(from ColorTypes.jl).

**Return**

Returns `nothing`

but modifies the `turtle`

as a side effect.

# ** VPL.Geom.SolidCylinder** —

*Method*.

`SolidCylinder(;length = 1.0, width = 1.0, height = 1.0, n = 80)`

Create a solid cylinder with dimensions given by `length`

, `width`

and `height`

, discretized into `n`

triangles (must be even) and standard location and orientation.

# ** VPL.Geom.SolidCylinder!** —

*Method*.

```
SolidCylinder!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 80, move = false,
= nothing, color = nothing) material
```

Generate a solid cylinder in front of the turtle and feed it to a turtle.

**Arguments**

`turtle`

: The turtle that we feed the solid cylinder to.`length`

: Length of the ellipse at the base of the solid cylinder.`width`

: Width of the ellipse at the base of the solid cylinder.`height`

: Height of the solid cylinder.`n`

: Number of triangles in the mesh (must be even).`move`

: Whether to move the turtle forward or not (`true`

or`false`

).`material`

: The material object for the ray tracer (optional).`color`

: The color of the ellipse for rendering (optional).

**Details**

A mesh will be generated with n triangles that approximate the solid cylinder. The cylinder will be generated in front of the turtle, with the base on the plane defined by the arm and up axes of the turtle, centered at the head axis. The `length`

argument refers to the up axis, whereas `width`

refers to the arm axis and `height`

is associated to the head axis.

When `move = true`

, the turtle will be moved forward by a distance equal to `height`

.

`Material`

(see ray tracing documentation for detail) and the color can be any type that inherits from `Colorant`

(from ColorTypes.jl).

**Return**

Returns `nothing`

but modifies the `turtle`

as a side effect.

### Hollow cone

# ** VPL.Geom.HollowCone** —

*Method*.

`HollowCone(;length = 1.0, width = 1.0, height = 1.0, n = 20)`

Create a hollow cone with dimensions given by `length`

, `width`

and `height`

, discretized into `n`

triangles (must be even) and standard location and orientation.

# ** VPL.Geom.HollowCone!** —

*Method*.

```
HollowCone!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 20, move = false,
= nothing, color = nothing) material
```

Generate a hollow cone in front of the turtle and feed it to a turtle.

**Arguments**

`turtle`

: The turtle that we feed the hollow cone to.`length`

: Length of the ellipse at the base of the hollow cone.`width`

: Width of the ellipse at the base of the hollow cone.`height`

: Height of the hollow cone.`n`

: Number of triangles in the mesh.`move`

: Whether to move the turtle forward or not (`true`

or`false`

).`material`

: The material object for the ray tracer (optional).`color`

: The color of the ellipse for rendering (optional).

**Details**

A mesh will be generated with n triangles that approximate the hollow cone. The cone will be generated in front of the turtle, with the base on the plane defined by the arm and up axes of the turtle, centered at the head axis. The `length`

argument refers to the up axis, whereas `width`

refers to the arm axis and `height`

is associated to the head axis.

When `move = true`

, the turtle will be moved forward by a distance equal to `height`

.

`Material`

(see ray tracing documentation for detail) and the color can be any type that inherits from `Colorant`

(from ColorTypes.jl).

**Return**

Returns `nothing`

but modifies the `turtle`

as a side effect.

# ** VPL.Geom.SolidCone** —

*Method*.

`SolidCone(;length = 1.0, width = 1.0, height = 1.0, n = 40)`

Create a solid cone with dimensions given by `length`

, `width`

and `height`

, discretized into `n`

triangles (must be even) and standard location and orientation.

# ** VPL.Geom.SolidCone!** —

*Method*.

```
SolidCone!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 40, move = false,
= nothing, color = nothing) material
```

Generate a solid frustum in front of the turtle and feed it to a turtle.

**Arguments**

`turtle`

: The turtle that we feed the solid cone to.`length`

: Length of the ellipse at the base of the solid cone.`width`

: Width of the ellipse at the base of the solid cone.`height`

: Height of the solid cone.`n`

: Number of triangles in the mesh (must be even).`move`

: Whether to move the turtle forward or not (`true`

or`false`

).`material`

: The material object for the ray tracer (optional).`color`

: The color of the ellipse for rendering (optional).

**Details**

A mesh will be generated with n triangles that approximate the solid cone. The cone will be generated in front of the turtle, with the base on the plane defined by the arm and up axes of the turtle, centered at the head axis. The `length`

argument refers to the up axis, whereas `width`

refers to the arm axis and `height`

is associated to the head axis.

When `move = true`

, the turtle will be moved forward by a distance equal to `height`

.

`Material`

(see ray tracing documentation for detail) and the color can be any type that inherits from `Colorant`

(from ColorTypes.jl).

**Return**

Returns `nothing`

but modifies the `turtle`

as a side effect.

### Cube

# ** VPL.Geom.SolidCube** —

*Method*.

`SolidCube(;length = 1.0, width = 1.0, height = 1.0)`

Create a solid cube with dimensions given by `length`

, `width`

and `height`

, standard location and orientation.

# ** VPL.Geom.SolidCube!** —

*Method*.

```
SolidCube!(turtle; length = 1.0, width = 1.0, height = 1.0, move = false,
= nothing, color = nothing) material
```

Generate a solid cube in front of the turtle and feed it to a turtle.

**Arguments**

`turtle`

: The turtle that we feed the solid cube to.`length`

: Length of the rectangle at the base of the solid cube.`width`

: Width of the rectangle at the base of the solid cube.`height`

: Height of the solid cube.`move`

: Whether to move the turtle forward or not (`true`

or`false`

).`material`

: The material object for the ray tracer (optional).`color`

: The color of the ellipse for rendering (optional).

**Details**

A mesh will be generated of a solid cube. The cube will be generated in front of the turtle, with the base on the plane defined by the arm and up axes of the turtle, centered at the head axis. The `length`

argument refers to the up axis, whereas `width`

refers to the arm axis and `height`

is associated to the head axis.

When `move = true`

, the turtle will be moved forward by a distance equal to `height`

.

`Material`

(see ray tracing documentation for detail) and the color can be any type that inherits from `Colorant`

(from ColorTypes.jl).

**Return**

Returns `nothing`

but modifies the `turtle`

as a side effect.

# ** VPL.Geom.HollowCube** —

*Method*.

`HollowCube(;length = 1.0, width = 1.0, height = 1.0)`

Create a hollow cube with dimensions given by `length`

, `width`

and `height, standard location and orientation.

# ** VPL.Geom.HollowCube!** —

*Method*.

```
HollowCube!(turtle; length = 1.0, width = 1.0, height = 1.0, move = false,
= nothing, color = nothing) material
```

Generate a hollow cube in front of the turtle and feed it to a turtle.

**Arguments**

`turtle`

: The turtle that we feed the hollow cube to.`length`

: Length of the rectangle at the base of the hollow cube.`width`

: Width of the rectangle at the base of the hollow cube.`height`

: Height of the hollow cube.`move`

: Whether to move the turtle forward or not (`true`

or`false`

).`material`

: The material object for the ray tracer (optional).`color`

: The color of the ellipse for rendering (optional).

**Details**

A mesh will be generated of a hollow cube. The cube will be generated in front of the turtle, with the base on the plane defined by the arm and up axes of the turtle, centered at the head axis. The `length`

argument refers to the up axis, whereas `width`

refers to the arm axis and `height`

is associated to the head axis.

When `move = true`

, the turtle will be moved forward by a distance equal to `height`

.

`Material`

(see ray tracing documentation for detail) and the color can be any type that inherits from `Colorant`

(from ColorTypes.jl).

**Return**

Returns `nothing`

but modifies the `turtle`

as a side effect.

### Solid frustum

# ** VPL.Geom.SolidFrustum** —

*Method*.

`SolidFrustum(;length = 1.0, width = 1.0, height = 1.0, n = 40)`

Create a solid frustum with dimensions given by `length`

, `width`

and `height`

, discretized into `n`

triangles and standard location and orientation.

# ** VPL.Geom.SolidFrustum!** —

*Method*.

```
SolidFrustum!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 80, move = false,
= nothing, color = nothing) material
```

Generate a solid frustum in front of the turtle and feed it to a turtle.

**Arguments**

`turtle`

: The turtle that we feed the solid frustum to.`length`

: Length of the ellipse at the base of the solid frustum.`width`

: Width of the ellipse at the base of the solid frustum.`height`

: Height of the solid frustum.`n`

: Number of triangles in the mesh (must be even).`move`

: Whether to move the turtle forward or not (`true`

or`false`

).`material`

: The material object for the ray tracer (optional).`color`

: The color of the ellipse for rendering (optional).

**Details**

A mesh will be generated with n triangles that approximate the solid frustum. The frustum will be generated in front of the turtle, with the base on the plane defined by the arm and up axes of the turtle, centered at the head axis. The `length`

argument refers to the up axis, whereas `width`

refers to the arm axis and `height`

is associated to the head axis.

When `move = true`

, the turtle will be moved forward by a distance equal to `height`

.

`Material`

(see ray tracing documentation for detail) and the color can be any type that inherits from `Colorant`

(from ColorTypes.jl).

**Return**

Returns `nothing`

but modifies the `turtle`

as a side effect.

# ** VPL.Geom.HollowFrustum** —

*Method*.

`HollowFrustum(;length = 1.0, width = 1.0, height = 1.0, n = 40)`

Create a hollow frustum with dimensions given by `length`

, `width`

and `height`

, discretized into `n`

triangles (must be even) and standard location and orientation.

# ** VPL.Geom.HollowFrustum!** —

*Method*.

```
HollowFrustum!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 40, move = false,
= nothing, color = nothing) material
```

Generate a hollow frustum in front of the turtle and feed it to a turtle.

**Arguments**

`turtle`

: The turtle that we feed the hollow frustum to.`length`

: Length of the ellipse at the base of the hollow frustum.`width`

: Width of the ellipse at the base of the hollow frustum.`height`

: Height of the hollow frustum.`n`

: Number of triangles in the mesh (must be even).`move`

: Whether to move the turtle forward or not (`true`

or`false`

).`material`

: The material object for the ray tracer (optional).`color`

: The color of the ellipse for rendering (optional).

**Details**

A mesh will be generated with n triangles that approximate the hollow frustum. The frustum will be generated in front of the turtle, with the base on the plane defined by the arm and up axes of the turtle, centered at the head axis. The `length`

argument refers to the up axis, whereas `width`

refers to the arm axis and `height`

is associated to the head axis.

When `move = true`

, the turtle will be moved forward by a distance equal to `height`

.

`Material`

(see ray tracing documentation for detail) and the color can be any type that inherits from `Colorant`

(from ColorTypes.jl).

**Return**

Returns `nothing`

but modifies the `turtle`

as a side effect.

### Bounding box

# ** VPL.Geom.BBox** —

*Method*.

`BBox(m::Mesh)`

Build a tight axis-aligned bounding box around a `Mesh`

object.

# ** VPL.Geom.BBox** —

*Method*.

`BBox(pmin::Vec, pmax::Vec)`

Build an axis-aligned bounding box given the vector of minimum (`pmin`

) and maximum (`pmax`

) coordinates.

### Generic mesh

# ** VPL.Geom.Mesh!** —

*Method*.

```
Mesh!(turtle, m::Mesh; scale = Vec(1.0, 1.0, 1.0), move = false,
= nothing, color = nothing) material
```

Feed a pre-existing mesh to a turtle after scaling.

**Arguments**

`turtle`

: The turtle that we feed the mesh to.`m`

: The pre-existing unscaled mesh in standard position and orientation.`scale`

: Vector with scaling factors for the x, y and z axes.`move`

: Whether to move the turtle forward or not (`true`

or`false`

).`material`

: The material object for the ray tracer (optional).`color`

: The color of the ellipse for rendering (optional).

**Details**

A pre-existing mesh will be scaled (acccording to `scale`

), rotate so that it is oriented in the same direction as the turtle and translated so that the mesh is generated in front of the turtle. A deep copy of the original mesh is made prior to any transformation.

When `move = true`

, the turtle will be moved forward by a distance equal to `height`

.

`Material`

(see ray tracing documentation for detail) and the color can be any type that inherits from `Colorant`

(from ColorTypes.jl).

**Return**

Returns `nothing`

but modifies the `turtle`

as a side effect.

## Rotations, scaling and translations

# ** VPL.Geom.scale!** —

*Method*.

`scale!(m::Mesh, Vec)`

Scale a mesh `m`

along the three axes provided by `vec`

# ** VPL.Geom.rotatex!** —

*Method*.

`rotatex!(m::Mesh, θ)`

Rotate a mesh `m`

around the x axis by `θ`

rad.

# ** VPL.Geom.rotatey!** —

*Method*.

`rotatey!(m::Mesh, θ)`

Rotate a mesh `m`

around the y axis by `θ`

rad.

# ** VPL.Geom.rotatez!** —

*Method*.

`rotatez!(m::Mesh, θ)`

Rotate a mesh `m`

around the z axis by `θ`

rad.

# ** VPL.Geom.rotate!** —

*Method*.

`rotate!(m::Mesh; x::Vec, y::Vec, z::Vec)`

Rotate a mesh `m`

to a new coordinate system given by `x`

, `y`

and `z`

# ** VPL.Geom.translate!** —

*Method*.

`translate!(m::Mesh, v::Vec)`

Translate the mesh `m`

by vector `v`