3D Surfaces
Hexagonal Prism
A complete hexagonal prism with six sides and filled top and bottom faces.
The prism is several parametric3d faces. Six quadrilaterals form the vertical sides, and two more close the top and bottom. Each call is one planar patch with its own u and v bounds.
The number 1.7320508 is √3, used so the hexagon's geometry is regular. The faces share edges. Together they are one 3D scene, and the viewer frames the whole solid.
Equation
parametric3d(
2-u,
1.7320508*u,
v,
0,
1,
-1,
1
)
parametric3d(
1-2*u,
1.7320508,
v,
0,
1,
-1,
1
)
parametric3d(
-1-u,
1.7320508-1.7320508*u,
v,
0,
1,
-1,
1
)
parametric3d(
-1+2*u,
-1.7320508,
v,
0,
1,
-1,
1
)
parametric3d(
1+u,
-1.7320508+1.7320508*u,
v,
0,
1,
-1,
1
)
parametric3d(
-2+u,
-1.7320508*u,
v,
0,
1,
-1,
1
)
parametric3d(
v*(2-u),
v*(1.7320508*u),
1,
0,
1,
0,
1
)
parametric3d(
v*(1-2*u),
v*(1.7320508),
1,
0,
1,
0,
1
)
parametric3d(
v*(-1-u),
v*(1.7320508-1.7320508*u),
1,
0,
1,
0,
1
)
parametric3d(
v*(-2+u),
v*(-1.7320508*u),
1,
0,
1,
0,
1
)
parametric3d(
v*(1+u),
v*(-1.7320508+1.7320508*u),
1,
0,
1,
0,
1
)
parametric3d(
v*(-1+2*u),
v*(-1.7320508),
1,
0,
1,
0,
1
)
parametric3d(
v*(2-u),
v*(1.7320508*u),
-1,
0,
1,
0,
1
)
parametric3d(
v*(1-2*u),
v*(1.7320508),
-1,
0,
1,
0,
1
)
parametric3d(
v*(-1-u),
v*(1.7320508-1.7320508*u),
-1,
0,
1,
0,
1
)
parametric3d(
v*(-2+u),
v*(-1.7320508*u),
-1,
0,
1,
0,
1
)
parametric3d(
v*(-1+2*u),
v*(-1.7320508),
-1,
0,
1,
0,
1
)
parametric3d(
v*(1+u),
v*(-1.7320508+1.7320508*u),
-1,
0,
1,
0,
1
)
How the 3D scene is built
A 3D example is drawn in the existing surface viewer, not on the flat JSXGraph board. An equation z = f(x, y) becomes a height field. A quadric such as a sphere or hyperboloid uses its own sampler. A parametric3d or curve3d command supplies the coordinates directly.
The camera starts framed on the surface. Axes and the grid stay in the scene. Implicit surfaces are extracted with marching cubes from F(x, y, z) = 0. If you edit the equation and generate again, the same viewer replaces the mesh instead of opening a second renderer.
Reading the input
parametric3d(— This is a command. The name selects the routine, and the items inside the parentheses are its arguments.2-u,— This is a header or a data row. Values in the same column share a meaning.1.7320508*u,— This is a header or a data row. Values in the same column share a meaning.v,— This is a header or a data row. Values in the same column share a meaning.0,— This is a header or a data row. Values in the same column share a meaning.1,— This is a header or a data row. Values in the same column share a meaning.-1,— This is a header or a data row. Values in the same column share a meaning.1— This line is part of the example input and is sent to DGS unchanged.154 more lines— The remaining lines use the same kind of instruction. Read them by the same rule as the lines above.
Try a change
- Change a constant on the right-hand side, or the amplitude of a wave, and generate. The 3D frame updates to the new surface.
- If this is z = f(x, y), try z = -f(x, y). The shape flips through the xy-plane.
Generate Graph sends the expression to the graph engine. A 3D result is drawn in the surface viewer: a mesh, a space curve, or a shaded region, depending on the command. The 2D board is cleared first.