Home

> 4D Blocks

> Version 6

Controls
Settings
Block Motion
Examples
> Scene Language
Kinds of Blocks
Goals
History
Versions

General Information
Constants
 > Geometry Commands
More Geometry Commands
Train Commands
Elevated Train Commands
Scenery Commands

## Geometry Commands

Standard Blocks

The simplest command is just the name of a type of block, which creates a new block of that type at its default location (which should typically have coordinates ranging from 0 to 1). For example ...

`block3`

Here's a partial list of predefined block types from the files "library" and "library2". For a complete list look in the files, they're easy to read.

`block3block4cap3cap4octa     -- octahedronhexadeca -- hexadecachoron, 4D analogue of octahedrondodeca   -- dodecahedroncubocta  -- cuboctahedron`

Geometric Operations

All of these leave the updated shape on the stack afterward.

translate

When you have more than one block, you'll want them to be in different places. Here's how you create a block3 that's moved one unit in the x direction (i.e. to the right).

`block3 [1 0 0] translate`

shapecolor

You can change the colors of blocks using the color constants listed in Constants or using the same kinds of colors as in HTML. The color operation can come before or after translation, doesn't matter.

`block3 red shapecolorblock3 #FF0000 shapecolor`

facecolor

You can change the colors of individual faces too. Faces are identified by numbers from 0 to N-1. You can figure out which faces are which by experimenting or by digging into the library file where they're defined.

`block3 5 red facecolor`

glass

You can turn a block into glass so that it's transparent. For the moment this also lets you fly through the block.

`block3 glass`

scale

You can stretch blocks by different amounts in different directions. Be sure to use one number per dimension, and to use 1 not 0 for directions with no stretching!

`block3 [2 1 1] scale`

The scaling is relative to the origin of the coordinate system, not the shape center, so you may need to apply some translation afterward.

rotate, altrot

shape dir1 dir2 theta rotate - Rotate the shape by theta degrees in the direction that takes dir1 toward dir2. The center of rotation is the shape's center but the direction of rotation is defined in terms of absolute coordinates, not the shape's internal axes. The direction constants "x+" to "w-" are discussed in Constants.

The alternate rotation command "altrot" allows you to rotate around an arbitrary point. The extra position argument comes after theta.

edge, face, shape, def

If you want to get into defining new block types, see the "library" file for examples. Here are a few hints about the format.

1. Each shape starts with a list of vertices. Like everything else here, these are numbered from 0 to N-1.
2. Next is a list of edges. "M N edge" creates an edge that connects vertices M and N.
3. Next is a list of faces. Faces have a list of edges ( not vertices! ) and also an outward normal vector. If you can't be bothered with the normal vectors at first, you can just put ? or null in place of that whole vector. In that case, the face will always be drawn no matter which side of the block you're on.

polygon, altpoly

[x y] r n polygon - This constructs a n-sided polygon of radius r around (x,y). The polygon is a two-dimensional shape, so you'll have to use one of the following three commands to add more dimensions. If you try to display it directly, who knows what will happen.

The alternate command "altpoly" does the same thing but with the faces shifted. This is mainly useful for getting axis-aligned edges on polygons where the number of sides is a multiple of 4.

genpoly

[[x1 y1] [x2 y2] ... [xn yn]] genpoly - This creates a general polygon with the given vertices.

prism

shape axis [min max] prism - This takes the given shape and adds a dimension to it to make a prism. The prism extends from min to max along the given axis. As a combined example, these commands create a hovering nine-sided prism.

`[1 1] 1 9 polygon y [1 3] prism`

cone

shape point axis [min tip] cone - This takes the given shape and adds a dimension to it to make a cone. The cone extends from min to tip along the given axis. The given point has the same dimensionality as the starting shape and tells where in that plane the tip of the cone should be. So, you can make symmetrical or asymmetrical cones.

frustum

shape point axis [min max tip] frustum - This takes a cone that extends from min to tip and cuts it off at max to make a frustum.

rect

[[min max] [min max] ... ] rect - This creates a rectangular shape with however many dimensions. You can get the same result by scaling and translating a standard block, but this is easier.

product

shape1 shape2 product - This multiplies two two-dimensional shapes together to give a four-dimensional shape. This is mostly useful for taking products of regular polygons, so instead of using this command you can probably just look at the end of Geometry Examples #3. Note: If you want to multiply by a one-dimensional shape, use the "prism" command!

polygon-antiprism, altpoly-antiprism

If you want to construct a polygonal prism, you can use a sequence of commands like the following.

`[x y] r n polygon axis [min max] prism`

If you want to construct a polygonal antiprism, the "polygon" and "antiprism" commands need to be combined into a single operation, but the argument list remains the same.

`[x y] r n axis [min max] polygon-antiprism`

etr

e n etr - The "edge to radius" command. If you're constructing a polygon (or antiprism) and you want to specify the edge length instead of the radius, you can use "etr" to convert. It replaces "e" with the proper radius. Typically you'll want to do something like this.

`[x y] e n etr polygon`

eth

r n ? [min e] eth - The "edge to height" command. If you're constructing an antiprism and you want to specify the edge length instead of the height, you can use "eth" to convert. It replaces "e" with "min" plus the proper height. Typically you'll want to do something like this.

`[x y] e n etr axis [min e] eth polygon-antiprism`