/* * 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); } }
/* * 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); } }
/* * 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); } }
/* * 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); }