Class User

java.lang.Object
  extended by User

public class User
extends java.lang.Object

Represents the state of the moving user.


Constructor Summary
User(User base)
          Constructs a user identical to the given user.
User(World world)
          Constructs a user in the given world, at coordinates (0,0) facing east (1,0).
 
Method Summary
 void addUserListener(UserListener l)
          Adds a listener to the user's movements.
 double getTheta()
          Returns the angle of this user's current direction, measured in radians.
 double getViewAngle()
          Returns the angle that the user should be able to see vertically.
 Ray getViewRay(double sx)
          Returns a ray emanating from the user's location through the window at fraction sx from center.
 World getWorld()
          Returns the world in which this user is moving.
 double getX()
          Returns the x-coordinate of this user's current position.
 double getY()
          Returns the y-coordinate of this user's current position.
 void removeUserListener(UserListener l)
          Removes a listener to the user's movements.
 void turnAndStep(double th, double dist)
          Turns the user and steps the user forward simulaneously.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

User

public User(World world)
Constructs a user in the given world, at coordinates (0,0) facing east (1,0).


User

public User(User base)
Constructs a user identical to the given user. Subsequent movements by either user do not affect the other.

Method Detail

getWorld

public World getWorld()
Returns the world in which this user is moving.


getX

public double getX()
Returns the x-coordinate of this user's current position.


getY

public double getY()
Returns the y-coordinate of this user's current position.


getTheta

public double getTheta()
Returns the angle of this user's current direction, measured in radians. A 0 return value represents east and Math.PI/2 represents north.


getViewAngle

public double getViewAngle()
Returns the angle that the user should be able to see vertically.


addUserListener

public void addUserListener(UserListener l)
Adds a listener to the user's movements.


removeUserListener

public void removeUserListener(UserListener l)
Removes a listener to the user's movements.


getViewRay

public Ray getViewRay(double sx)
Returns a ray emanating from the user's location through the window at fraction sx from center. The sx parameter should be 0.0 for center, 0.5 for being as far to the right as half the window's height, and -0.5 for being as far to the left as half the window's height.

Parameters:
sx - the distance from the window's center desired, measured in terms of the screen's height.
Returns:
a ray starting at the user's eye and going through the desired location on the window.

turnAndStep

public void turnAndStep(double th,
                        double dist)
Turns the user and steps the user forward simulaneously.

Parameters:
th - the angle, in radians, to turn.
dist - the distance to go forward.