001/*
002
003*/
004
005package renderer.models;
006import  renderer.scene.*;
007
008import java.awt.Color;
009
010/**
011   Create a positive x, y, and z axis in 3-dimensional space.
012*/
013public class Axes3D extends Model
014{
015   /**
016      Create a positive x, y, and z axis
017      with one unit length for each axis.
018      The default color is black.
019   */
020   public Axes3D( )
021   {
022      this(1.0, 1.0, 1.0);
023   }
024
025
026   /**
027      Create a positive x, y, and z axis
028      with the given length for each axis.
029      The default color is black.
030
031      @param xMax  length of the x-axis
032      @param yMax  length of the y-axis
033      @param zMax  length of the z-axis
034   */
035   public Axes3D(double xMax, double yMax, double zMax)
036   {
037      this(xMax, yMax, zMax, Color.black);
038   }
039
040
041   /**
042      Create a positive x, y, and z axis
043      with the given length for each axis.
044      Use the given color for all three axes.
045
046      @param xMax  length of the x-axis
047      @param yMax  length of the y-axis
048      @param zMax  length of the z-axis
049      @param c     color for all three axes
050   */
051   public Axes3D(double xMax, double yMax, double zMax, Color c)
052   {
053      this(xMax, yMax, zMax, c, c, c);
054   }
055
056
057   /**
058      Create a positive x, y, and z axis
059      with the given length for each axis.
060      Use the given colors for each axis.
061
062      @param xMax  length of the x-axis
063      @param yMax  length of the y-axis
064      @param zMax  length of the z-axis
065      @param cX    color for the x-axis
066      @param cY    color for the y-axis
067      @param cZ    color for the z-axis
068   */
069   public Axes3D(double xMax, double yMax, double zMax,
070                 Color cX,    Color cY,    Color cZ)
071   {
072      this(xMax, 0.0, yMax, 0.0, zMax, 0.0, cX, cY, cZ);
073   }
074
075
076   /**
077      Create an x, y, and z axis with the
078      given endpoints for each axis.
079      The default color is black.
080
081      @param xMax  right endpoint of the x-axis
082      @param xMin  left endpoint of the x-axis
083      @param yMax  top endpoint of the y-axis
084      @param yMin  bottom endpoint of the y-axis
085      @param zMax  front endpoint of the z-axis
086      @param zMin  back endpoint of the z-axis
087   */
088   public Axes3D(double xMax, double xMin,
089                 double yMax, double yMin,
090                 double zMax, double zMin)
091   {
092      this(xMax, xMin, yMax, yMin, zMax, zMin, Color.black);
093   }
094
095
096   /**
097      Create an x, y, and z axis with the
098      given endpoints for each axis.
099      Use the given Color c.
100
101      @param xMax  right endpoint of the x-axis
102      @param xMin  left endpoint of the x-axis
103      @param yMax  top endpoint of the y-axis
104      @param yMin  bottom endpoint of the y-axis
105      @param zMax  front endpoint of the z-axis
106      @param zMin  back endpoint of the z-axis
107      @param c     color for all three axes
108   */
109   public Axes3D(double xMax, double xMin,
110                 double yMax, double yMin,
111                 double zMax, double zMin,
112                 Color c)
113   {
114      this(xMax, xMin, yMax, yMin, zMax, zMin, c, c, c);
115   }
116
117
118   /**
119      Create an x, y, and z axis with the
120      given endpoints for each axis.
121      Use the given colors for each axis.
122
123      @param xMax  right endpoint of the x-axis
124      @param xMin  left endpoint of the x-axis
125      @param yMax  top endpoint of the y-axis
126      @param yMin  bottom endpoint of the y-axis
127      @param zMax  front endpoint of the z-axis
128      @param zMin  back endpoint of the z-axis
129      @param cX    color for the x-axis
130      @param cY    color for the y-axis
131      @param cZ    color for the z-axis
132   */
133   public Axes3D(double xMax, double xMin,
134                 double yMax, double yMin,
135                 double zMax, double zMin,
136                 Color cX, Color cY, Color cZ)
137   {
138      super();
139
140      Vertex x0 = new Vertex(xMin, 0,    0);
141      Vertex x1 = new Vertex(xMax, 0,    0);
142      Vertex y0 = new Vertex( 0,  yMin,  0);
143      Vertex y1 = new Vertex( 0,  yMax,  0);
144      Vertex z0 = new Vertex( 0,   0,   zMin);
145      Vertex z1 = new Vertex( 0,   0,   zMax);
146
147      x0.setColor( cX );
148      x1.setColor( cX );
149      y0.setColor( cY );
150      y1.setColor( cY );
151      z0.setColor( cZ );
152      z1.setColor( cZ );
153
154      addLineSegment(x0, x1);
155      addLineSegment(y0, y1);
156      addLineSegment(z0, z1);
157   }
158}//Axes3D