/**
   * Determines the radial line segment at angles evenly subdivided by a preset number of stitches.
   *
   * @param ellipse Ellipse
   * @param lineList List<Line>
   */
  private void fillEllipse(Ellipse ellipse, List<Line> lineList) {
    double endX, endY, radius, degree, degreeInterval;
    Line radialLine;

    degreeInterval = 360 / NUM_STITCHES;
    degree = 0;
    for (int i = 0; i < NUM_STITCHES; i++) {
      radius = EmbMath.getEllipseRadiusDeg(ellipse, degree);

      endX = ellipse.getCenterX() + (radius * Math.cos(Math.toRadians(degree)));
      endY = ellipse.getCenterY() + (radius * Math.sin(Math.toRadians(degree)));
      radialLine = new Line(ellipse.getCenterX(), ellipse.getCenterY(), endX, endY);

      lineList.add(radialLine);
      degree += degreeInterval;
    }
  }
Example #2
0
 private static void write(Ellipse ellipse, Writer writer) throws IOException {
   writer.write(
       String.format(
           "<ellipse cx=\"%f\" cy=\"%f\" rx=\"%f\" ry=\"%f\" />\n",
           ellipse.getCenterX(),
           ellipse.getCenterY(),
           ellipse.getRadiusX(),
           ellipse.getRadiusY()));
 }