The VRML drinking glass constructor code provides a set of classes and interfaces (pure abstract classes):
GlassProfile
(interface)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
)IsoGlassProfile
(class, extends
EpGlassProfile
)EpGlassProfile
with the
ISO 3591-1977 glass measurements.
CirclePoints
(class)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.
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++