Author: Laurence D. Finston

This copyright notice applies to the text and source code of this web site, and the graphics that appear on it. The software described in this text has its own copyright notice and license, which can be found in the distribution itself.

Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 The Free Software Foundation, Inc.

Permission is granted to copy, distribute, and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of this license is included in the file COPYING.TXT

Last updated: April 29, 2006

Top |

Non-Drawable Types |

Drawable Types |

Declaring Variables |

Vector Types |

Contact |

Back to top

Back to Language contents

Back to main Language page

Back to main page

In order to use 3DLDF in a sensible way, one must declare variables. These variables have various types. The following is an alphabetical list of the types of objects that can be declared in 3DLDF as of 2005.11.14. Types are added fairly frequently, so it may not be up-to-date.

bool_point bool_point_vector boolean boolean_vector circle circle_slice circle_slice_vector circle_vector color color_vector cone cone_vector cuboid cuboid_vector cylinder cylinder_vector dash_pattern dash_pattern_vector ellipse ellipse_slice ellipse_slice_vector ellipse_vector ellipsoid ellipsoid_vector focus focus_vector glyph glyph_vector helix helix_vector hyperbola hyperbola_vector macro macro_vector numeric numeric_vector nurb nurb_vector origami_figure origami_figure_vector parabola parabola_vector path path_vector pen pen_vector picture picture_vector plane plane_vector point point_vector polygon polygon_vector polyhedron polyhedron_slice polyhedron_slice_vector polyhedron_vector rectangle rectangle_vector reg_polygon reg_polygon_vector sphere sphere_vector string string_vector transform transform_vector triangle triangle_vector

These types can be categorized in a couple of different ways.
Some of them are drawable while others are
non-drawable. For example, **point** is drawable while
**boolean** is not.

Another difference is that some are ordinary types, while others
are vector types. Every ordinary type has a corresponding
vector type. For example, **path** and **path_vector** are
corresponding types.

These are the non-drawable types (leaving out the corresponding vector types):

boolean color dash_pattern focus macro numeric pen picture plane string transform

These are the drawable types (leaving out the corresponding vector types):

bool_point circle circle_slice cone cuboid cylinder ellipse ellipse_slice ellipsoid glyph helix hyperbola nurb origami_figure parabola path point polygon polyhedron polyhedron_slice rectangle reg_polygon sphere triangle

`bool_point`

is really a combination of a non-drawable and
a drawable type.

Some of these types are not yet fully functional. This is a list of them:

circle_slice cone cylinder ellipse_slice glyph helix hyperbola nurb origami_figure polyhedron_slice

The

types `_slice`

`circle_slice`

,
`ellipse_slice`

, and `polyhedron_slice`

, are
intended to represent the geometric figures formed by the intersections of
other geometric figures.

That leaves the following list of drawable types which can currently be used:

bool_point circle cuboid ellipse ellipsoid parabola path point polygon polyhedron rectangle reg_polygon sphere triangle

All non-vector types are declared using the same syntax.
The simplest form of declaration consists of a type name,
the name of the variable you want to declare, and a semi-colon:

`point p;`

Multiple variables can be declared in a single declaration. The names
should be separated by commata:

`point p, q, r, s;`

In addition, arrays of variables can be declared. To do
this, a generic subscript must be used in the variable
name. A generic subscript is an empty pair of square brackets:

`path a[];`

Now, the name `a`

followed by a numerical subscript
refers to a `path`

. For example, following the declaration above,
`a0`

, `a[1]`

, and `a[1.5]`

all refer to different
`paths`

. When the subscript is just a number, the square brackets can
be left out, so `a0`

and `a[0]`

refer to the same `path`

,
as do `a1.5`

and `a[1.5]`

. However, the numerical subscript can also be an
expression (to be explained elsewhere). For example, 3/2 = 1.5, so
`a[3/2]`

refers to the same path as `a[1.5]`

. In the case of
`a[3/2]`

, the square brackets must be used, or 3DLDF will think

you're trying to divide a path `a3`

by 2, which is an invalid operation.

A variable can have multiple subscripts:

`path n[]op[];`

Now `n0op1`

and `n2.5op[7/8]`

refer to `paths`

.

Ordinary and array declarations can be mixed, e.g.,

`path A, B[], C[]D[], E;`

As mentioned above, each of the ordinary object types defined in 3DLDF has a corresponding
vector type. Objects of these types are declared in the same way as objects of
other types, **except** that they shouldn't be declared as arrays.
Declaring them with a single generic subscript at the end of the name
is equivalent to declaring them with no subscript at all. Any other
use of one or more generic subscripts is invalid:

`point_vector pv; % The recommended style `

`point_vector qv[]; % Equivalent to using no generic subscript,
but not the recommended style`

`point_vector r[]v; % INVALID`

`point_vector sv[][]; % INVALID`

The declaration `point_vector pv`

, in addition to creating an object
of type `point_vector`

called `pv`

, implicitly declares an
array of `points`

with the same name plus a generic subscript.
In other words, it is as though `point pv[]`

had also been declared.

The main reason for this is to make it possible to access all of the elements of an array in a single command. METAFONT has no vector types, so one must loop over the elements of an array. In order to do this, one must know what subscripts to use.

PREVIOUS CHAPTER: | Introduction to the Grammar |

NEXT CHAPTER: | Assignments |

Back to contents

Back to top

Back to Language contents

Back to main Language page

Back to main page