-
Notifications
You must be signed in to change notification settings - Fork 27
ParametricGeometry
thothbot edited this page Mar 4, 2016
·
9 revisions
Class ParametricGeometry
is very very useful to generate parametric surfaces by defining custom function.
Constructor takes three arguments:
- a function object that converts the domain coordinate into a range coordinate;
- the level-of-detail for the U coordinate;
- and the level-of-detail for the V coordinate.
ParametricGeometry geometry = new ParametricGeometry(
new ParametricGeometry.ParametricFunction()
{
@Override
// Converts the domain coordinate into a range coordinate
public Vector3 run(double u, double v)
{
/* code */
}
},
slices, // The level-of-detail for the U coordinate
stacks // The level-of-detail for the V coordinate
);
Lets implement ParametricFunction
interface and write function to create a sphere:
@Override
public Vector3 run(double u, double v)
{
u *= Math.PI;
v *= 2 * Math.PI;
double x = Math.sin(u) * Math.cos(v);
double y = Math.sin(u) * Math.sin(v);
double z = Math.cos(u);
return new Vector3(x, y, z);
}
This is family of the following classes, which are inherited from the ParametricGeometry
KleinParametricGeometry geometry = new KleinParametricGeometry(10, 20);
MobiusParametricGeometry geometry = new MobiusParametricGeometry(10, 20);
Mobius3dParametricGeometry geometry = new Mobius3dParametricGeometry(10, 20);