VRML drinking glass constructor

The virtual reality modeling language drinking glass constructor software generates a VRML 1.0 representation of a rotation-symmetric drinking glass. It is implemented in C++ (no templates or namespaces used1).

The VRML drinking glass constructor code provides a set of classes and interfaces (pure abstract classes):

GlassProfile (interface)
GlassProfile requires three methods: length(), radius() and profile(double z). length() and radius() return the glass' extensions; profile() is a method that returns the glass radius calculated from the glass' z coordinate.
EpGlassProfile (class, implements GlassProfile)
EpGlassProfile implements the GlassProfile methods as functions depending on seven parameters (footradius, stemradius, stemlength, cupradius, lowercuplength, openingradius and uppercuplength). It uses an exponential function to describe the glass stem radius, an ellipsoid for the lower part of the cup and a paraboloid for the upper part.
IsoGlassProfile (class, extends EpGlassProfile)
IsoGlassProfile implements an EpGlassProfile with the ISO 3591-1977 glass measurements.
CirclePoints (class)
CirclePoints supplies mainly the method getpoints(buf, scale) that calculates the vertices of a circle's regular polygon representation. static hint(n) returns a hint on the up-rounded optimal number of vertices for faster getpoints() calculations2.

The main code implements vrmlglass(ostream&, GlassProfile*) which writes a VRML 1.0 representation of the GlassProfile to ostream (standard output). It generates a Coordinate3 entity with a number of trapezii depending on the chosen resolution. The glass will be seamless since the circle points are not doubly defined.

Note: The program is free software; you can redistribute it and/or modify it. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

source: glass.tar.gz
binaries: glass-i386-win32.exe

VRML samples: ISO glass and Bordeaux glass

More info on the ISO 3591-1977 glass.
Screen shots from a VRML viewer: #1, #2.

ISO 3591-1977 glass ISO 3591-1977 glass

1 Quick measurements have shown that using template based <iostream> output operations roughly doubles the performance of the drinking glass constructor on a typical win32 based system (using dynamic libc).

2 In the CirclePoints model, setting the number of vertices to a multiple of eight enables getpoints() to transform a calculated point to seven symmetrical points and use additional eight pre-calculated points. The algorithm uses four lines of symmetry in this case. However, the less symmetrical cases are also handled.

Keywords: VRML glass, VRML drinking glass, virtual reality modeling language, VRML, VRML 1.0, world/vrml, x-world/x-vrml, circle points mathematics, circle mathematics, source code, C++


Eric Laroche / Thu May 21 1998