edu.mines.jtk.sgl
Class OrbitView

java.lang.Object
  extended by edu.mines.jtk.sgl.View
      extended by edu.mines.jtk.sgl.OrbitView

public class OrbitView
extends View

A view of a world, as if in orbit around that world. By default, the view camera is aimed towards the world, from a point outside the world's sphere. The camera's up axis is always aligned with lines of constant longitude. An orbit view is designed to draw on a single view canvas.

All views maintain a world-to-view transform. In an orbit view, that world-to-view transform is comprised of a world-to-unit-sphere transform and a unit-sphere-to-view transform.

The world-to-unit-sphere transform centers and normalizes the world. A world drawn by an orbit view has a world sphere that, by default, is the bounding sphere of the world when first viewed. The world-to-unit- sphere transform first translates the world sphere's center to the origin, and then scales the world sphere to have unit radius. The purpose of this first transform is to make other orbit view parameters independent of world coordinates. To modify the world-to-unit-sphere transform, set the world sphere.

The second unit-sphere-to-view transform applies a translate, scale, and rotate to the unit sphere, and then applies a final translate down the z-axis to push the transformed sphere into the view frustum. The orbit view applies the first translate, scale, and rotate in that order, so that the scale and rotate occurs about the center of the view.

The rotate part of the unit-sphere-to-view transform is comprised of two rotations, because an orbit view camera has both azimuth and elevation angles. Imagine a line from the center of the unit sphere to the camera. The point where that line intersects the sphere has a latitude and longitude. The azimuth angle is the longitude, positive for degrees East, negative for degrees West. The elevation angle is the latitude, positive for degrees North, negative for degrees South.

An orbit view supports both perspective and orthographic projections. For perspective projections, the field of view is computed by assuming that the distance from the eye to the default screen is approximately equal to the size of that screen.

Version:
2005.05.29
Author:
Dave Hale, Colorado School of Mines

Nested Class Summary
static class OrbitView.Projection
          Perspective or orthographic projection.
 
Constructor Summary
OrbitView()
          Constructs an orbit view of no world.
OrbitView(World world)
          Constructs an orbit view of the specified world.
 
Method Summary
protected  void draw(ViewCanvas canvas)
          Draws this view on the specified canvas.
 double getAzimuth()
          Gets the azimuth for this view.
 double getElevation()
          Gets the elevation for this view.
 OrbitView.Projection getProjection()
          Gets the projection for this view.
 double getScale()
          Gets the scale factor for this view.
 Vector3 getTranslate()
          Gets the translate vector for this view.
 Matrix44 getUnitSphereToView()
          Gets the unit-sphere-to-view transform for this view.
 BoundingSphere getWorldSphere()
          Gets the world sphere used to parameterize this view.
 Matrix44 getWorldToUnitSphere()
          Gets the world-to-unit-sphere transform for this view.
 void reset()
          Resets this view to its state when constructed.
 void setAzimuth(double azimuth)
          Sets the azimuth for this view.
 void setAzimuthAndElevation(double azimuth, double elevation)
          Sets the azimuth and elevation for this view.
 void setElevation(double elevation)
          Sets the elevation for this view.
 void setProjection(OrbitView.Projection projection)
          Sets the projection for this view.
 void setScale(double scale)
          Sets the scale factor for this view.
 void setTranslate(Vector3 translate)
          Sets the translate vector for this view.
 void setWorldSphere(BoundingSphere worldSphere)
          Sets the world sphere used to parameterize this view.
protected  void updateTransforms(ViewCanvas canvas)
          Updates transforms for a canvas on which this view draws.
 
Methods inherited from class edu.mines.jtk.sgl.View
countCanvases, getAxesOrientation, getAxesScale, getCanvases, getWorld, getWorldToView, repaint, setAxesOrientation, setAxesScale, setAxesScale, setWorld, setWorldToView, updateTransforms
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrbitView

public OrbitView()
Constructs an orbit view of no world.


OrbitView

public OrbitView(World world)
Constructs an orbit view of the specified world.

Parameters:
world - the world.
Method Detail

reset

public void reset()
Resets this view to its state when constructed.


setWorldSphere

public void setWorldSphere(BoundingSphere worldSphere)
Sets the world sphere used to parameterize this view. If null (the default), this view uses the bounding sphere of the the world when first viewed.

Parameters:
worldSphere - the world sphere; null, if none.

getWorldSphere

public BoundingSphere getWorldSphere()
Gets the world sphere used to parameterize this view.

Returns:
the world sphere; null, if none.

setProjection

public void setProjection(OrbitView.Projection projection)
Sets the projection for this view.

Parameters:
projection - the projection.

getProjection

public OrbitView.Projection getProjection()
Gets the projection for this view.

Returns:
the projection.

setAzimuth

public void setAzimuth(double azimuth)
Sets the azimuth for this view.

Parameters:
azimuth - the azimuth.

getAzimuth

public double getAzimuth()
Gets the azimuth for this view.

Returns:
the azimuth.

setElevation

public void setElevation(double elevation)
Sets the elevation for this view.

Parameters:
elevation - the elevation.

getElevation

public double getElevation()
Gets the elevation for this view.

Returns:
the elevation.

setAzimuthAndElevation

public void setAzimuthAndElevation(double azimuth,
                                   double elevation)
Sets the azimuth and elevation for this view.

Parameters:
azimuth - the azimuth.
elevation - the elevation.

setScale

public void setScale(double scale)
Sets the scale factor for this view.

Parameters:
scale - the scale factor.

getScale

public double getScale()
Gets the scale factor for this view.

Returns:
the scale factor.

setTranslate

public void setTranslate(Vector3 translate)
Sets the translate vector for this view.

Parameters:
translate - the translate vector.

getTranslate

public Vector3 getTranslate()
Gets the translate vector for this view.

Returns:
the translate vector.

getWorldToUnitSphere

public Matrix44 getWorldToUnitSphere()
Gets the world-to-unit-sphere transform for this view.

Returns:
the world-to-unit-sphere transform.

getUnitSphereToView

public Matrix44 getUnitSphereToView()
Gets the unit-sphere-to-view transform for this view.

Returns:
the unit-sphere-to-view transform.

updateTransforms

protected void updateTransforms(ViewCanvas canvas)
Updates transforms for a canvas on which this view draws.

Specified by:
updateTransforms in class View
Parameters:
canvas - the view canvas.

draw

protected void draw(ViewCanvas canvas)
Draws this view on the specified canvas.

Specified by:
draw in class View
Parameters:
canvas - the canvas.