protected Point2 getTextureCoordinates(GeometryIntersection x) {
Point3 p = x.getPosition();
switch (x.getTag()) {
case TAPERED_CYLINDER_SURFACE_BODY:
double angle = Math.PI + Math.atan2(p.z(), p.x());
return new Point2(angle / ((capped ? 4.0 : 2.0) * Math.PI),
(p.y() - height1) / (height2 - height1));
case TAPERED_CYLINDER_SURFACE_END_1:
return new Point2(0.5 + (p.x() + radius1) / (4.0 * radius1),
(p.z() + radius1) / (4.0 * radius1));
case TAPERED_CYLINDER_SURFACE_END_2:
return new Point2(0.5 + (p.x() + radius2) / (4.0 * radius2),
(p.z() + radius2) / (4.0 * radius2));
default:
throw new IllegalArgumentException("Invalid surface ID");
}