示例#1
0
 /*
  *  Connects the letters by going along the Z axis
  */
 public static void ConnectLetters(Graphics g, Object letter) {
   Point3D topPoint = new Point3D(0, 0, 0);
   for (int i = 0; i < letter.vertices.length; i++) {
     Move3D(letter.vertices[i], letter.aT, CAMERA);
     topPoint.SetCoords(letter.vertices[i].x, letter.vertices[i].y, -1);
     Draw3D(g, topPoint, letter.aT, CAMERA);
   }
 }
示例#2
0
 /*
  *  Takes in an object and a height and connects all the points of the object
  *  from the floor to the specified height
  */
 public static void ConnectWalls(Graphics g, Object floorObject, double y) {
   Point3D topPoint = new Point3D(0, 0, 0);
   for (int i = 0; i < floorObject.vertices.length; i++) {
     Move3D(floorObject.vertices[i], floorObject.aT, CAMERA);
     topPoint.SetCoords(floorObject.vertices[i].x, y, floorObject.vertices[i].z);
     Draw3D(g, topPoint, floorObject.aT, CAMERA);
   }
 }
示例#3
0
  /*
   *  Draws and labels the axes
   */
  public static void DrawAxes(Graphics g) {
    String num = "";
    Point2D tmpPoint = new Point2D(0, 0);
    drawPoint drawer = new drawPoint(0, 0);
    // X axis
    Point3D PointToDraw = new Point3D(curWin.RightX, 0, 0);
    Move3D(PointToDraw, IDENTITY, CAMERA);

    PointToDraw.SetCoords(curWin.LeftX, 0, 0);
    Draw3D(g, PointToDraw, IDENTITY, CAMERA);

    for (double i = curWin.LeftX; i <= curWin.RightX; i += 0.5) {
      if (i == 0.0) continue;
      PointToDraw.SetCoords(i, 0, 0);

      num = "" + i;
      Move3D(PointToDraw, IDENTITY, CAMERA);
      drawer = ViewPortToFrameWindow(curPos);
      g.drawString(num, drawer.x, drawer.y);
    }

    // y-axis
    PointToDraw.SetCoords(0, curWin.TopY - 1, 0);
    Move3D(PointToDraw, IDENTITY, CAMERA);

    PointToDraw.SetCoords(0, curWin.BotY, 0);
    Draw3D(g, PointToDraw, IDENTITY, CAMERA);

    for (double i = curWin.BotY; i <= curWin.TopY - 1; i += 0.5) {
      if (i == 0.0) continue;
      PointToDraw.SetCoords(0.1, i, 0);

      num = "" + i;
      Move3D(PointToDraw, IDENTITY, CAMERA);
      drawer = ViewPortToFrameWindow(curPos);
      g.drawString(num, drawer.x, drawer.y);
    }

    // z-axis
    PointToDraw.SetCoords(0, 0, 4); // 4 is to keep it on the screen
    Move3D(PointToDraw, IDENTITY, CAMERA);

    PointToDraw.SetCoords(0, 0, -4); // keep it on the screen
    Draw3D(g, PointToDraw, IDENTITY, CAMERA);

    for (double i = -4.0; i <= 4.0; i += 0.5) {
      if (i == 0.0) continue;
      PointToDraw.SetCoords(0, 0.1, i);

      num = "" + i;
      Move3D(PointToDraw, IDENTITY, CAMERA);
      drawer = ViewPortToFrameWindow(curPos);
      g.drawString(num, drawer.x, drawer.y);
    }
  }
示例#4
0
  /*
   * Plots the given equation
   */
  public static void PlotGraph(Graphics g) {
    // start at the low point
    Point3D firstPoint = new Point3D(-1.25, -1.25, 0);
    Point3D secondPoint = new Point3D(-1.25, -1.25, 0);
    double inc = 0.05; // this looked the best
    g.setColor(Color.green);
    for (double y = -1.25; y <= 1.25; y += inc) {
      for (double x = -1.25; x <= 1.25; x += inc) {
        // draw the small square
        firstPoint.SetCoords(x, y, 0);
        secondPoint.SetCoords(x + inc, y + inc, 0);
        DrawSquare(g, firstPoint, secondPoint);
      }
    }

    g.setColor(Color.black);
    DrawAxes(g);
    Branding(g, "z = (x^2) + (y^2) - (x^3) - 8*x*(y^4)");
  }
示例#5
0
  /*
   *  draws a square for the graph
   */
  public static void DrawSquare(Graphics g, Point3D leftPoint, Point3D rightPoint) {
    Point3D PointToDraw =
        new Point3D(leftPoint.x, leftPoint.y, PlotFunction(leftPoint.x, leftPoint.y));
    Move3D(PointToDraw, IDENTITY, CAMERA);

    // leftX -> rightX
    PointToDraw.SetCoords(rightPoint.x, leftPoint.y, PlotFunction(rightPoint.x, leftPoint.y));
    Draw3D(g, PointToDraw, IDENTITY, CAMERA);

    // botY -> topY
    PointToDraw.SetCoords(rightPoint.x, rightPoint.y, PlotFunction(rightPoint.x, rightPoint.y));
    Draw3D(g, PointToDraw, IDENTITY, CAMERA);

    // rightX -> leftX
    PointToDraw.SetCoords(leftPoint.x, rightPoint.y, PlotFunction(leftPoint.x, rightPoint.y));
    Draw3D(g, PointToDraw, IDENTITY, CAMERA);

    // topY -> botY
    PointToDraw.SetCoords(leftPoint.x, leftPoint.y, PlotFunction(leftPoint.x, leftPoint.y));
    Draw3D(g, PointToDraw, IDENTITY, CAMERA);
  }