Interface Surface

All Known Implementing Classes:
Cylinder, LatWall, LongWall

public interface Surface

Represents a single vertical surface in the world. Every surface in the world is essentially a right prism - that is, the product of extending a two-dimensional shape up and down the vertical dimension.


Method Summary
 void draw(java.awt.Graphics g, double dx, double dy, double sx, double sy)
          Draws an overhead view of this surface.
 Bounds getBounds()
          Returns a bounding box describing the range of x- and y-coordinates occupied by the surface.
 double getDistanceFrom(Ray ray)
          Returns the ``distance'' at which the surface is located along the given ray, or Double.POSITIVE_INFINITY if in fact the ray doesn't intersect the surface at all.
 Ray getNormal(double x, double y)
          Returns the ray normal to the surface at the given coordinates.
 TextureColumn getTextureColumn(double x, double y)
          Returns the column of texture that appears on this surface at the given point.
 

Method Detail

getNormal

Ray getNormal(double x,
              double y)
Returns the ray normal to the surface at the given coordinates. The parameter coordinates are assumed to represent a point on the surface. The returned ray should be based on the given coordinates, and its direction should be perpendicular to the tangent of the surface at this point. The returned direction can be either of the possible perpendicular unit directions (which are negations of each other).

Parameters:
x - the x-coordinate of the point in question.
y - the y-coordinate of the point in question.
Returns:
the ray normal to the surface at the requested point.

getDistanceFrom

double getDistanceFrom(Ray ray)
Returns the ``distance'' at which the surface is located along the given ray, or Double.POSITIVE_INFINITY if in fact the ray doesn't intersect the surface at all. The ray will start from some point (x,y) and have some direction (dx,dy). If the returned value d is finite, it should be a positive value for which (x + d * dx, y + d * dy) lies on this surface.

Parameters:
ray - the ray to look along in determining the distance.
Returns:
a positive number if the ray intersects with this surface, or Double.POSITIVE_INFINITY if it does not.

getTextureColumn

TextureColumn getTextureColumn(double x,
                               double y)
Returns the column of texture that appears on this surface at the given point. At the given coordinates is a vertical strip of this vertical surface, and the returned TextureColumn contains information about how to draw that vertical strip. The given coordinates are assumed to lie on this surface.

Parameters:
x - the x-coordinate of the point on the surface.
y - the y-coordinate of the point on the surface.
Returns:
a TextureColumn containing information about how to draw the vertical strip of the surface at this location.

getBounds

Bounds getBounds()
Returns a bounding box describing the range of x- and y-coordinates occupied by the surface.

Returns:
the bounding box

draw

void draw(java.awt.Graphics g,
          double dx,
          double dy,
          double sx,
          double sy)
Draws an overhead view of this surface. This will involve mapping the surface's actual coordinates to the drawing space's coordinates. The mapping is described by the sx and sy scaling factors and the dx and dy offsets. For example, an x-coordinate of x will map to the pixel at dx + sx * x.

Parameters:
g - the Graphics object with which to draw.
dx - the x-coordinate offset for drawing space.
dy - the y-coordinate offset for drawing space.
sx - the x-coordinate scaling factor for mapping from world space to drawing space.
sy - the y-coordinate scaling factor from mapping from world space to drawing space.