Beispiel #1
0
  /*======== public void generateSphere() ==========
      Inputs:   double cx
                double cy
  double r
  double step
      Returns:

      Generates all the points along the surface of a
      sphere with center (cx, cy) and radius r

      Adds these points to the matrix parameter

      jonalf
      ====================*/
  public void generateSphere(double cx, double cy, double r, double step) {
    double f, t;
    for (f = 0; f < 1; f += step) {
      for (t = 0; t < 1; t += step) {
        double x = r * Math.cos(Math.PI * 2 * t) + cx;
        double y = r * Math.sin(Math.PI * 2 * t) * Math.cos(Math.PI * f) + cy;
        double z = r * Math.sin(Math.PI * 2 * t) * Math.sin(Math.PI * f);
        addPoint(x, y, z);
      }
    }
  }
Beispiel #2
0
  /*======== public void generateTorus() ==========
      Inputs:   double cx
                double cy
  double r1
  double r2
  double step
      Returns:

      Generates all the points along the surface of a
      tarus with center (cx, cy) and radii r1 and r2

      Adds these points to the matrix parameter

      jonalf
      ====================*/
  public void generateTorus(double cx, double cy, double r1, double r2, double step) {
    double f, t;
    for (f = 0; f < 1; f += step) {
      for (t = 0; t < 1; t += step) {
        double x = Math.cos(Math.PI * 2 * f) * (r2 * Math.cos(Math.PI * 2 * t) + r1) + cx;
        double y = r2 * Math.sin(Math.PI * 2 * t) + cy;
        double z = -1 * Math.sin(Math.PI * 2 * f) * (r2 * Math.cos(Math.PI * 2 * t) + r1);
        addPoint(x, y, z);
      }
    }
  }
Beispiel #3
0
  /*======== public void addEdge() ==========
  Inputs:  int x0
  int y0
  int z0
  int x1
  int y1
  int z1
  Returns:
  adds the line connecting (x0, y0, z0) and (x1, y1, z1)
  to the calling object
  should use addPoint
  ====================*/
  public void addEdge(double x0, double y0, double z0, double x1, double y1, double z1) {

    addPoint(x0, y0, z0);
    addPoint(x1, y1, z1);
  }