de.ba_ravensburg.gdv.model
Class Triangle

java.lang.Object
  extended by de.ba_ravensburg.gdv.model.Triangle

public class Triangle
extends Object

Instances of this class represent three dimensional triangles. The triangles are determined by three points in the coordinate space and their color.

Author:
Ansgar Wiechers

Field Summary
(package private) static Color DEFAULT_COLOR
          The default color of a triangle.
static int HORIZONTAL
          Constant representing horizontal turns.
static int VERTICAL
          Constant representing vertical turns.
 
Constructor Summary
Triangle(double xA, double yA, double zA, double xB, double yB, double zB, double xC, double yC, double zC)
          Constructs a new triangle by three given points.
Triangle(double xA, double yA, double zA, double xB, double yB, double zB, double xC, double yC, double zC, Color theColor)
          Constructs a new triangle by three given points and given color.
 
Method Summary
 double getAngleOfA(int direction)
          Get the spherical coordinate angle of point A.
 double getAngleOfB(int direction)
          Get the spherical coordinate angle of point B.
 double getAngleOfC(int direction)
          Get the spherical coordinate angle of point C.
 Color getColor()
          Get the current color of the triangle.
 double getDistance()
          Get the weighted distance of the triangle from the camera.
 double[] getPointA()
          Get point A of the triangle.
 double[] getPointB()
          Get point B of the triangle.
 double[] getPointC()
          Get point C of the triangle.
(package private)  void move(double step, int direction)
          Move the triangle by given amount step into direction.
 void setColor(Color theColor)
          Set new color of the triangle.
 void setPointA(double x, double y, double z)
          Set point A of the triangle.
 void setPointB(double x, double y, double z)
          Set point B of the triangle.
 void setPointC(double x, double y, double z)
          Set point C of the triangle.
(package private)  void turn(double angle, int plane)
          Turn the triangle by given angle in given plane around the camera position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_COLOR

static final Color DEFAULT_COLOR
The default color of a triangle.


HORIZONTAL

public static final int HORIZONTAL
Constant representing horizontal turns.

See Also:
Constant Field Values

VERTICAL

public static final int VERTICAL
Constant representing vertical turns.

See Also:
Constant Field Values
Constructor Detail

Triangle

public Triangle(double xA,
                double yA,
                double zA,
                double xB,
                double yB,
                double zB,
                double xC,
                double yC,
                double zC)
         throws IllegalArgumentException
Constructs a new triangle by three given points. The color is set to the default color.

Parameters:
xA - x-coordinate of point A.
yA - y-coordinate of point A.
zA - z-coordinate of point A.
xB - x-coordinate of point B.
yB - y-coordinate of point B.
zB - z-coordinate of point B.
xC - x-coordinate of point C.
yC - y-coordinate of point C.
zC - z-coordinate of point C.
Throws:
IllegalArgumentException - if at least two of the three points are equal.

Triangle

public Triangle(double xA,
                double yA,
                double zA,
                double xB,
                double yB,
                double zB,
                double xC,
                double yC,
                double zC,
                Color theColor)
         throws IllegalArgumentException
Constructs a new triangle by three given points and given color.

Parameters:
xA - x-coordinate of point A.
yA - y-coordinate of point A.
zA - z-coordinate of point A.
xB - x-coordinate of point B.
yB - y-coordinate of point B.
zB - z-coordinate of point B.
xC - x-coordinate of point C.
yC - y-coordinate of point C.
zC - z-coordinate of point C.
theColor - a color.
Throws:
IllegalArgumentException - if at least two of the three points are equal.
Method Detail

getAngleOfA

public double getAngleOfA(int direction)
                   throws IllegalArgumentException
Get the spherical coordinate angle of point A. Whether the VERTICAL or HORIZONTAL angle should be obtained is specified by the parameter direction.

Pre: direction is either HORIZONTAL or VERTICAL.
Post: the spherical coordinate angle (HORIZONTAL or VERTICAL) is returned.

Parameters:
direction - the direction of the angle.
Returns:
the spherical angle of point A in the given direction.
Throws:
IllegalArgumentException - if direction is neither HORIZONTAL nor VERTICAL.

getAngleOfB

public double getAngleOfB(int direction)
                   throws IllegalArgumentException
Get the spherical coordinate angle of point B. Whether the VERTICAL or HORIZONTAL angle should be obtained is specified by the parameter direction.

Pre: direction is either HORIZONTAL or VERTICAL.
Post: the spherical coordinate angle (HORIZONTAL or VERTICAL) is returned.

Parameters:
direction - the direction of the angle.
Returns:
the spherical angle of point B in the given direction.
Throws:
IllegalArgumentException - if direction is neither HORIZONTAL nor VERTICAL.

getAngleOfC

public double getAngleOfC(int direction)
                   throws IllegalArgumentException
Get the spherical coordinate angle of point C. Whether the VERTICAL or HORIZONTAL angle should be obtained is specified by the parameter direction.

Pre: direction is either HORIZONTAL or VERTICAL.
Post: the spherical coordinate angle (HORIZONTAL or VERTICAL) is returned.

Parameters:
direction - the direction of the angle.
Returns:
the spherical angle of point C in the given direction.
Throws:
IllegalArgumentException - if direction is neither HORIZONTAL nor VERTICAL.

getColor

public Color getColor()
Get the current color of the triangle.

Pre: true
Post: true

Returns:
current color of the triangle.

getDistance

public double getDistance()
Get the weighted distance of the triangle from the camera.

Returns:
weighted distance of the triangle from the camera.

getPointA

public double[] getPointA()
Get point A of the triangle.

Pre: true
Post: true

Returns:
point A.

getPointB

public double[] getPointB()
Get point B of the triangle.

Pre: true
Post: true

Returns:
point B.

getPointC

public double[] getPointC()
Get point C of the triangle.

Pre: true
Post: true

Returns:
point C.

move

void move(double step,
          int direction)
    throws IllegalArgumentException
Move the triangle by given amount step into direction.

Pre: true
Post: the triangle is moved step units into direction direction.

Parameters:
step - how far to move the triangle.
direction - axis along which the triangle should be moved.
Throws:
IllegalArgumentException - if direction is neither of X, Y or Z.

setColor

public void setColor(Color theColor)
Set new color of the triangle.

Pre: true
Post: true

Parameters:
theColor - new color to set.

setPointA

public void setPointA(double x,
                      double y,
                      double z)
Set point A of the triangle.

Pre: true
Post: pointA is (x;y;z)

Parameters:
x - x-coordinate of point A.
y - y-coordinate of point A.
z - z-coordinate of point A.

setPointB

public void setPointB(double x,
                      double y,
                      double z)
Set point B of the triangle.

Pre: true
Post: pointB is (x;y;z)

Parameters:
x - x-coordinate of point B.
y - y-coordinate of point B.
z - z-coordinate of point B.

setPointC

public void setPointC(double x,
                      double y,
                      double z)
Set point C of the triangle.

Pre: true
Post: pointC is (x;y;z)

Parameters:
x - x-coordinate of point C.
y - y-coordinate of point C.
z - z-coordinate of point C.

turn

void turn(double angle,
          int plane)
    throws IllegalArgumentException
Turn the triangle by given angle in given plane around the camera position.

Pre: true
Post: the triangle is turned by angle degree.

Parameters:
angle - an angle.
plane - plane in which the triangle should be turned.
Throws:
IllegalArgumentException - if plane is neither UPDOWN nor LEFTRIGHT.


Copyright © 2004 Max Schloss and Ansgar Wiechers. All Rights Reserved.