protected void transformLimitedConic(GeoElement a, GeoElement b) {

    GeoConicPart arc = (GeoConicPart) b;
    if (a instanceof GeoConicPart) {
      GeoConicPart source = (GeoConicPart) a;
      arc.setParameters(0, Kernel.PI_2, true);
      if (pt == null) {
        transformedPoint = new GeoPoint(cons);
        pt = new AlgoClosestPoint(cons, arc, transformedPoint);
        cons.removeFromConstructionList(pt);
      }
      transformedPoint.removePath();
      setTransformedObject(source.getPointParam(0), transformedPoint);
      compute();
      transformedPoint.updateCascade();
      // Application.debug("start"+transformedPoint);
      double d = pt.getP().getPathParameter().getT();
      transformedPoint.removePath();
      setTransformedObject(source.getPointParam(1), transformedPoint);
      compute();
      transformedPoint.updateCascade();
      // Application.debug("end"+transformedPoint);
      double e = pt.getP().getPathParameter().getT();
      // Application.debug(d+","+e);
      arc.setParameters(d * Kernel.PI_2, e * Kernel.PI_2, swapOrientation(source));

      setTransformedObject(a, b);
    }
  }
Beispiel #2
0
  private void addPt() {

    GeoPoint p = new GeoPoint(view.getKernel().getConstruction());
    p.setLabelVisible(false);
    DrawPoint d = new DrawPoint(view, p);
    d.setGeoElement(p);

    pts.add(p);
    drawPoints.add(d);
  }
Beispiel #3
0
  @Override
  public final void compute() {
    int size = geoList.size();
    if (!geoList.isDefined() || size <= 1) {
      g.setUndefined();
      return;
    }

    double sigmax = 0;
    double sigmay = 0;
    double sigmaxx = 0;
    // double sigmayy=0; not needed
    double sigmaxy = 0;

    for (int i = 0; i < size; i++) {
      GeoElement geo = geoList.get(i);
      if (geo.isGeoPoint()) {
        double x;
        double y;
        if (geo.isGeoElement3D()) {
          Coords coords = ((GeoPointND) geo).getInhomCoordsInD3();
          if (!Kernel.isZero(coords.getZ())) {
            g.setUndefined();
            return;
          }
          x = coords.getX();
          y = coords.getY();
        } else {
          double xy[] = new double[2];
          ((GeoPoint) geo).getInhomCoords(xy);
          x = xy[0];
          y = xy[1];
        }

        sigmax += x;
        sigmay += y;
        sigmaxx += x * x;
        sigmaxy += x * y;
        // sigmayy+=y*y; not needed
      } else {
        g.setUndefined();
        return;
      }
    }
    // y on x regression line
    // (y - sigmay / n) = (Sxx / Sxy)*(x - sigmax / n)
    // rearranged to eliminate all divisions
    g.x = size * sigmax * sigmay - size * size * sigmaxy;
    g.y = size * size * sigmaxx - size * sigmax * sigmax;
    g.z = size * sigmax * sigmaxy - size * sigmaxx * sigmay; // (g.x)x +
    // (g.y)y +
    // g.z = 0
  }
  public void calcArea() {

    // more accurate method for 2D
    if (A instanceof GeoPoint && B instanceof GeoPoint && centerPoint instanceof GeoPoint) {

      // area = 1/2 | det(P[i], P[i+1]) |
      double area = GeoPoint.det((GeoPoint) A, (GeoPoint) B);
      area += GeoPoint.det((GeoPoint) B, (GeoPoint) this.centerPoint);
      area += GeoPoint.det((GeoPoint) this.centerPoint, (GeoPoint) A);
      area = area * this.n / 2;

      getPoly().setArea(area);

      return;
    }

    // TODO: more accurate method should be possible for 3D too
    double radius = A.distance(centerPoint);

    // 1/2 a b sin(C)
    getPoly().setArea(n * radius * radius * Math.sin(alpha) / 2.0);
  }
  // calc tangent at x=a
  @Override
  public final void compute() {
    double a = n.getDouble();
    if (!f.isDefined() || !deriv.isDefined() || Double.isInfinite(a) || Double.isNaN(a)) {
      tangent.setUndefined();
      return;
    }

    // calc the tangent;
    double fa = f.evaluate(a);
    double slope = deriv.evaluate(a);
    tangent.setCoords(-slope, 1.0, a * slope - fa);
    T.setCoords(a, fa, 1.0);
  }
  @Override
  public final void compute() {
    if (input[0].isDefined() && point.isDefined()) {
      if (path instanceof GeoFunction) {
        Function fun = (Function) ((GeoFunction) path).getFunction().deepCopy(kernel);
        Coords coords = point.getCoordsInD2();
        double val =
            AlgoDistancePointObject.getClosestFunctionValueToPoint(
                fun, coords.getX(), coords.getY());
        ((GeoPoint) P).setCoords(val, fun.evaluate(val), 1.0);
      } else {
        setCoords();
        path.pointChanged(P);
      }

      P.updateCoords();
    } else {
      P.setUndefined();
    }
  }
 /** set coords of closest point to input point coords */
 protected void setCoords() {
   ((GeoPoint) P).setCoords((GeoPoint) point);
 }
 /**
  * @author Tam
  *     <p>for special cases of e.g. AlgoIntersectLineConic
  */
 protected void addIncidence() {
   ((GeoPoint) P).addIncidence((GeoElement) path, false);
 }
 /**
  * create the output point
  *
  * @param cons construction
  * @param path path
  */
 protected void createOutputPoint(Construction cons, Path path) {
   P = new GeoPoint(cons);
   ((GeoPoint) P).setPath(path);
 }
Beispiel #10
0
 @Override
 public final void compute() {
   outputBoolean.setValue(GeoPoint.collinearND(inputPoint1, inputPoint2, inputPoint3));
 }