Turtle Geometry
Public API
PlantGeomTurtle.F
— TypeF(dist)
Moves a turtle forward a given distance.
PlantGeomTurtle.OR
— TypeOR(head::Vec, up::Vec, arm::Vec)
Node that orients a turtle to a new direction by re-defining the local reference system.
PlantGeomTurtle.RA
— TypeRA(angle)
Node that rotates a turtle around arm axis. Angle must be in hexadecimal degrees and the rotation is clockwise.
PlantGeomTurtle.RH
— TypeRH(angle)
Node that rotates a turtle around head axis. Angle must be in hexadecimal degrees and the rotation is clockwise.
PlantGeomTurtle.RU
— TypeRU(angle)
Node that rotates a turtle around up axis. Angle must be in hexadecimal degrees and the rotation is clockwise.
PlantGeomTurtle.RV
— TypeRV(strength)
Rotates the turtle towards the Z axis. See documentation for rv!
for details.
PlantGeomTurtle.SET
— TypeSET(to, head, up, arm)
Node that sets the position and orientation of a turtle.
PlantGeomTurtle.T
— TypeT(to::Vec)
Node that translates a turtle to the new position to
(a Vec
object).
PlantGeomTurtle.Turtle
— MethodTurtle(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.
PlantGeomTurtle.Mesh!
— MethodMesh!(turtle, m::Mesh; scale = Vec(1.0, 1.0, 1.0), move = false, transform = true,
deepcopy = true, kwargs...)
Feed a pre-existing mesh to a turtle (with optional transformation).
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
orfalse
).transform
: Whether to to transform the mesh according to the turtle's position and orientation the scaling vector provided by the user.deepcopy
: Whether to make a deep copy of the mesh before feeding it to the turtle.kwargs
: Properties to be set per triangle in the mesh.
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
.
There are two expected use cases for this function:
When the user defines a reference mesh that is used to generate multiple instances of the same mesh with different scales at transformations. An example would be an ad-hoc mesh that represents the shape of a leaf. In this case, the user wants to set
transform = true
anddeepcopy = true
.When the user generates a mesh using a primitive function that takes the turtle as argument, performs some operations on that mesh (e.g., calculating area, coordinates of the center, etc) and then feed that mesh into the turtle. In this case, the user wants to set
transform = false
(because the transformation was alread applied) and probably alsodeepcopy = false
because the deepcopy is an unnecessary cost.
Return
Returns nothing
but modifies the turtle
as a side effect.
Examples
julia> import PlantGeomPrimitives as PG
julia> e = PG.Ellipse();
julia> turtle = Turtle();
julia> Mesh!(turtle, e, scale = PG.Vec(2.0, 2.0, 2.0));
PlantGeomTurtle.arm
— Methodarm(turtle)
Extract the direction vector (a Vec
object) of the arm of the turtle.
PlantGeomTurtle.f!
— Methodf!(turtle, dist)
Move turtle forward a given distance.
Examples
julia> turtle = Turtle();
julia> f!(turtle, 2.0);
PlantGeomTurtle.feed!
— Methodfeed!(turtle::Turtle, collection::AbstractArray)
feed!(turtle::Turtle, collection::Tuple)
Feed a turtle an array or tuple of objects (collection
) with existing feed!()
methods.
PlantGeomTurtle.feed!
— Methodfeed!(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.
PlantGeomTurtle.feed!
— Methodfeed!(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.
PlantGeomTurtle.feed!
— Methodfeed!(turtle::Turtle; mesh::Mesh; kwargs...)
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.
PlantGeomTurtle.head
— Methodhead(turtle)
Extract the direction vector (a Vec
object) of the head of the turtle.
PlantGeomTurtle.or!
— Methodor!(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
.
Examples
julia> turtle = Turtle();
julia> using PlantGeomPrimitives
julia> or!(turtle, head = Y(), up = Z(), arm = X());
PlantGeomTurtle.pos
— Methodpos(turtle)
Extract the current position of the turtle (a Vec
object).
PlantGeomTurtle.ra!
— Methodra!(turtle, angle)
Rotates a turtle around arm axis. Angle must be in hexadecimal degrees and the rotation is clockwise.
Examples
julia> turtle = Turtle();
julia> ra!(turtle, 45.0);
PlantGeomTurtle.rh!
— Methodrh!(turtle, angle)
Rotate turtle around head axis. Angle must be in hexadecimal degrees and the rotation is clockwise.
Examples
julia> turtle = Turtle();
julia> rh!(turtle, 45.0);
PlantGeomTurtle.ru!
— Methodru!(turtle, angle)
Rotates a turtle around up axis. Angle must be in hexadecimal degrees and the rotation is clockwise.
Examples
julia> turtle = Turtle();
julia> ru!(turtle, 45.0);
PlantGeomTurtle.rv!
— Methodrv!(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.
Examples
julia> turtle = Turtle();
julia> ra!(turtle, 45.0);
julia> rv!(turtle, 0.5);
PlantGeomTurtle.set!
— Methodset!(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.
Examples
julia> turtle = Turtle();
julia> using PlantGeomPrimitives
julia> set!(turtle, to = O(), head = Y(), up = Z(), arm = X());
PlantGeomTurtle.t!
— Methodt!(turtle; to = O())
Translate a turtle to the new position to
(a Vec
object).
Examples
julia> turtle = Turtle();
julia> using PlantGeomPrimitives
julia> t!(turtle, to = Y(1.0));
PlantGeomTurtle.up
— Methodup(turtle)
Extract the direction vector (a Vec
object) of the back of the turtle.
Private
Private functions, types or constants from PlantGeomTurtle
. These are not exported, so you need to prefix the function name with PlantGeomTurtle.
to access them. Also bear in mind that these are not part of the public API, so they may change without notice.
PlantGeomPrimitives.Mesh
— MethodMesh(turtle)
Extract the mesh stored in a turtle (a Mesh
object).
PlantGeomPrimitives.Mesh
— MethodMesh(graph, Float64)
Create a mesh 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)
.
PlantGeomPrimitives.Mesh
— MethodMesh(turtle, m::Mesh; scale = Vec(1.0, 1.0, 1.0), move = false)
Scale a pre-existing mesh by using the turtle's state.
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
orfalse
).
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
.
Return
Returns a triangular mesh (object of type Mesh
).
Examples
julia> import PlantGeomPrimitives as PG
julia> e = PG.Ellipse();
julia> turtle = Turtle();
julia> ne = Mesh!(turtle, e, scale = PG.Vec(2.0, 2.0, 2.0));
PlantGeomPrimitives.Mesh
— MethodMesh(graphs, Float64; parallel = false, message = nothing)
Create a mesh for rendering from an array of Graph
objects (graphs
). The graphs may be processed serially (default) or in parallel using multithreading (parallel = true
). 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 Mesh(graphs, Float32)
.
PlantGeomPrimitives.Ellipse!
— MethodEllipse!(turtle; length = 1.0, width = 1.0, n = 20, move = false, kwargs...)
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
orfalse
).kwargs
: Properties to be set per triangle in the mesh.
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
.
Return
Returns nothing
but modifies the turtle
as a side effect.
Examples
julia> turtle = Turtle();
julia> Ellipse!(turtle; length = 1.0, width = 0.5, n = 40);
PlantGeomPrimitives.Ellipse
— MethodEllipse(turtle; length = 1.0, width = 1.0, n = 20, move = false)
Generate an ellipse in front of a turtle and return it.
Arguments
turtle
: The turtle which state is used to create the ellipse.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
orfalse
).
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
.
Return
Returns a triangular mesh (object of type Mesh
).
Examples
julia> turtle = Turtle();
julia> e = Ellipse(turtle; length = 1.0, width = 0.5, n = 40);
PlantGeomPrimitives.HollowCone!
— MethodHollowCone!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 20, move = false, kwargs...)
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
orfalse
).kwargs
: Properties to be set per triangle in the mesh.
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
.
Return
Returns nothing
but modifies the turtle
as a side effect.
Examples
julia> turtle = Turtle();
julia> HollowCone!(turtle; length = 1.0, width = 1.0, height = 1.0);
PlantGeomPrimitives.HollowCone
— MethodHollowCone(turtle; length = 1.0, width = 1.0, height = 1.0, n = 20, move = false)
Generate a hollow cone in front of the turtle and return it.
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
orfalse
).
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
.
Return
Returns a triangular mesh (object of type Mesh
).
Examples
julia> turtle = Turtle();
julia> HollowCone!(turtle; length = 1.0, width = 1.0, height = 1.0);
PlantGeomPrimitives.HollowCube!
— MethodHollowCube!(turtle; length = 1.0, width = 1.0, height = 1.0, move = false, kwargs...)
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
orfalse
).kwargs
: Properties to be set per triangle in the mesh.
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
.
Return
Returns nothing
but modifies the turtle
as a side effect.
Examples
julia> turtle = Turtle();
julia> HollowCube!(turtle; length = 1.0, width = 1.0, height = 2.0);
PlantGeomPrimitives.HollowCube
— MethodHollowCube(turtle; length = 1.0, width = 1.0, height = 1.0, move = false)
Generate a hollow cube in front of the turtle and return it.
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
orfalse
).
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
.
Return
Returns a triangular mesh (object of type Mesh
).
Examples
julia> turtle = Turtle();
julia> c = HollowCube(turtle; length = 1.0, width = 1.0, height = 2.0);
PlantGeomPrimitives.HollowCylinder!
— MethodHollowCylinder!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 40, move = false, kwargs...)
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
orfalse
).kwargs
: Properties to be set per triangle in the mesh.
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
.
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.
Examples
julia> turtle = Turtle();
julia> HollowCylinder!(turtle; length = 1.0, width = 1.0, height = 2.0, n = 40);
PlantGeomPrimitives.HollowCylinder
— MethodHollowCylinder(turtle; length = 1.0, width = 1.0, height = 1.0, n = 40, move = false)
Generate a hollow cylinder in front of the turtle and return it.
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
orfalse
).
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
.
Return
Returns a triangular mesh (object of type Mesh
).
Examples
julia> turtle = Turtle();
julia> c = HollowCylinder(turtle; length = 1.0, width = 1.0, height = 2.0, n = 40);
PlantGeomPrimitives.HollowFrustum!
— MethodHollowFrustum!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 40, move = false, kwargs...)
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
orfalse
).kwargs
: Properties to be set per triangle in the mesh.
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
.
Return
Returns nothing
but modifies the turtle
as a side effect.
Examples
julia> turtle = Turtle();
julia> HollowFrustum!(turtle; length = 1.0, width = 1.0, height = 2.0, n = 40);
PlantGeomPrimitives.HollowFrustum
— MethodHollowFrustum(turtle; length = 1.0, width = 1.0, height = 1.0, n = 40, move = false)
Generate a hollow frustum in front of the turtle and return it.
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
orfalse
).
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
.
Return
Returns a triangular mesh (object of type Mesh
).
Examples
julia> turtle = Turtle();
julia> f = HollowFrustum(turtle; length = 1.0, width = 1.0, height = 2.0, n = 40);
PlantGeomPrimitives.Rectangle!
— MethodRectangle!(turtle; length = 1.0, width = 1.0, move = false, kwargs...)
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
orfalse
).kwargs
: Properties to be set per triangle in the mesh.
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
.
Return
Returns nothing
but modifies the turtle
as a side effect.
Examples
julia> turtle = Turtle();
julia> Rectangle!(turtle; length = 1.0, width = 0.5);
PlantGeomPrimitives.Rectangle
— MethodRectangle(turtle; length = 1.0, width = 1.0, move = false)
Generate a rectangle in front of the turtle and and return it.
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
orfalse
).
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
.
Return
Returns a triangular mesh (object of type Mesh
).
Examples
julia> turtle = Turtle();
julia> r = Rectangle(turtle; length = 2.0, width = 1.0);
PlantGeomPrimitives.SolidCone!
— MethodSolidCone!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 40, move = false, kwargs...)
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
orfalse
).kwargs
: Properties to be set per triangle in the mesh.
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
.
Return
Returns nothing
but modifies the turtle
as a side effect.
Examples
julia> turtle = Turtle();
julia> SolidCone!(turtle; length = 1.0, width = 1.0, height = 2.0, n = 40);
PlantGeomPrimitives.SolidCone
— MethodSolidCone(turtle; length = 1.0, width = 1.0, height = 1.0, n = 40, move = false)
Generate a solid frustum in front of the turtle and return it.
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
orfalse
).
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
.
Return
Returns a triangular mesh (object of type Mesh
).
Examples
julia> turtle = Turtle();
julia> c = SolidCone(turtle; length = 1.0, width = 1.0, height = 2.0, n = 40);
PlantGeomPrimitives.SolidCube!
— MethodSolidCube!(turtle; length = 1.0, width = 1.0, height = 1.0, move = false, kwargs...)
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
orfalse
).kwargs
: Properties to be set per triangle in the mesh.
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
.
Return
Returns nothing
but modifies the turtle
as a side effect.
Examples
julia> turtle = Turtle();
julia> SolidCube!(turtle; length = 1.0, width = 1.0, height = 2.0);
PlantGeomPrimitives.SolidCube
— MethodSolidCube(turtle; length = 1.0, width = 1.0, height = 1.0, move = false)
Generate a solid cube in front of the turtle and return it.
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
orfalse
).
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
.
Return
Returns a triangular mesh (object of type Mesh
).
Examples
julia> turtle = Turtle();
julia> c = SolidCube(turtle; length = 1.0, width = 1.0, height = 2.0);
PlantGeomPrimitives.SolidCylinder!
— MethodSolidCylinder!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 80, move = false, kwargs...)
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
orfalse
).kwargs
: Properties to be set per triangle in the mesh.
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
.
Return
Returns nothing
but modifies the turtle
as a side effect.
Examples
julia> turtle = Turtle();
julia> SolidCylinder!(turtle; length = 1.0, width = 1.0, height = 2.0, n = 80);
PlantGeomPrimitives.SolidCylinder
— MethodSolidCylinder(turtle; length = 1.0, width = 1.0, height = 1.0, n = 80, move = false)
Generate a solid cylinder in front of the turtle and return it.
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
orfalse
).
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
.
Return
Returns a triangular mesh (object of type Mesh
).
Examples
julia> turtle = Turtle();
julia> c = SolidCylinder(turtle; length = 1.0, width = 1.0, height = 2.0, n = 80);
PlantGeomPrimitives.SolidFrustum!
— MethodSolidFrustum!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 80, move = false, kwargs...)
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
orfalse
).kwargs
: Properties to be set per triangle in the mesh.
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
.
Return
Returns nothing
but modifies the turtle
as a side effect.
Examples
julia> turtle = Turtle();
julia> SolidFrustum!(turtle; length = 1.0, width = 1.0, height = 2.0, n = 80);
PlantGeomPrimitives.SolidFrustum
— MethodSolidFrustum(turtle; length = 1.0, width = 1.0, height = 1.0, n = 80, move = false)
Generate a solid frustum in front of the turtle and return it.
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
orfalse
).
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
.
Return
Returns a triangular mesh (object of type Mesh
).
Examples
julia> turtle = Turtle();
julia> f = SolidFrustum(turtle; length = 1.0, width = 1.0, height = 2.0, n = 80);
PlantGeomPrimitives.Trapezoid!
— MethodTrapezoid!(turtle; length = 1.0, width = 1.0, ratio = 1.0, move = false, kwargs...)
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
orfalse
).kwargs
: Properties to be set per triangle in the mesh.
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
.
Return
Returns nothing
but modifies the turtle
as a side effect.
Examples
julia> turtle = Turtle();
julia> Trapezoid!(turtle; length = 1.0, width = 1.0, ratio = 0.5);
PlantGeomPrimitives.Trapezoid
— MethodTrapezoid(turtle; length = 1.0, width = 1.0, ratio = 1.0, move = false)
Generate a trapezoid in front of the turtle and return it.
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
orfalse
).
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
.
Return
Returns a triangular mesh (object of type Mesh
).
Examples
julia> turtle = Turtle();
julia> t = Trapezoid(turtle; length = 1.0, width = 1.0, ratio = 0.5);
PlantGeomPrimitives.Triangle!
— MethodTriangle!(turtle; length = 1.0, width = 1.0, move = false, kwargs...)
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
orfalse
).kwargs
: Properties to be set per triangle in the mesh.
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
.
Return
Returns nothing
but modifies the turtle
as a side effect.
Examples
julia> turtle = Turtle();
julia> Triangle!(turtle; length = 2.0, width = 1.0);
PlantGeomPrimitives.Triangle
— MethodTriangle(turtle; length = 1.0, width = 1.0, move = false)
Generate a triangle in front of the turtle and and return it.
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
orfalse
).
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
.
Return
Returns a triangular mesh (object of type Mesh
).
Examples
julia> turtle = Turtle();
julia> t = Triangle(turtle; length = 2.0, width = 1.0);