コード例 #1
0
  private void parseMeasure(String value, double measures[]) {
    for (int i = 0; i < 360; i++) {
      measures[i] = 100.0;
    }

    if (value.length() >= 5) {
      value = value.substring(5); // removes the "SCAN " keyword

      StringTokenizer tokenizer = new StringTokenizer(value, " ");

      double distance;
      int direction;
      while (tokenizer.hasMoreTokens()) {
        distance = Double.parseDouble(tokenizer.nextToken().substring(2));
        direction =
            (int)
                Math.round(Math.toDegrees(Double.parseDouble(tokenizer.nextToken().substring(2))));
        if (direction == 360) {
          direction = 0;
        }
        measures[direction] = distance;
        // Printing out all the degrees and what it encountered.
        System.out.println("direction = " + direction + " distance = " + distance);
      }
    }
  }
コード例 #2
0
  /* CALCULATE VALUES QUADRANTS: Calculate x-y values where direction is not
  parallel to eith x or y axis. */
  public static void calcValuesQuad(int x1, int y1, int x2, int y2) {
    double arrowAng = Math.toDegrees(Math.atan((double) haw / (double) al));
    double dist = Math.sqrt(al * al + aw);
    double lineAng =
        Math.toDegrees(Math.atan(((double) Math.abs(x1 - x2)) / ((double) Math.abs(y1 - y2))));

    // Adjust line angle for quadrant
    if (x1 > x2) {
      // South East
      if (y1 > y2) lineAng = 180.0 - lineAng;
    } else {
      // South West
      if (y1 > y2) lineAng = 180.0 + lineAng;
      // North West
      else lineAng = 360.0 - lineAng;
    }

    // Calculate coords
    xValues[0] = x2;
    yValues[0] = y2;
    calcCoords(1, x2, y2, dist, lineAng - arrowAng);
    calcCoords(2, x2, y2, dist, lineAng + arrowAng);
  }
コード例 #3
0
ファイル: Testesala.java プロジェクト: yuripourre/exemplwjgl
  // Convert from Radians to Degrees.
  private float AR_RadToDeg(float x) {

    return (float) Math.toDegrees(x);
  }