Subclassing the Lathe Shape
Figure 17-2 shows that LatheShape3D
can be subclassed. The aim is to override its xCoord()
and zCoord()
methods, which control the shape of the path made by the lathe curve when it's rotated. These methods appear in LatheShape3D
as shown here:
protected double xCoord(double radius, double angle) { return radius * Math.cos(angle); } protected double zCoord(double radius, double angle) { return radius * Math.sin(angle); }
radius
is the x-value of the point being rotated around the y-axis, and angle
is the angle of rotation currently being applied. xCoord()
and zCoord()
return the new x-and z-values after the rotation has been applied.
An Elliptical Shape
An ellipse resembles a circle stretched in one direction. Another (more formal) way of characterizing the ellipse is that its points all have the same sum of distances from two fixed points (called the foci).
The line that passes through the foci is called the major axis, and is the longest line through the ellipse. The minor axis is the line that passes through the center of the ellipse, perpendicular to the major axis. The semi-major axis is half the length of the major axis: it runs from the center of the ellipse to its edge. There's also a semi-minor axis(half of the minor axis). See Figure 17-19 for illustrations of all of these concepts.
Figure 17-19. Elements of an ellipse
Figure 17-20 shows an ellipse ...
Get Killer Game Programming in Java now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.