Exemplo n.º 1
0
  @Override
  public void remove() {
    if (removed) return;
    super.remove();
    f.removeAlgorithm(algo);
    f.removeAlgorithm(cv);
    A.removeAlgorithm(algo);
    A.removeAlgorithm(cv);

    // make sure all AlgoCASDerivatives get removed
    cv.remove();
  }
  // calc tangent at x=a
  public final void compute() {
    if (!(f.isDefined() && P.isDefined() && deriv.isDefined())) {
      tangent.setUndefined();
      return;
    }

    // calc the tangent;
    double a = P.inhomX;
    double fa = f.evaluate(a);
    double slope = deriv.evaluate(a);
    tangent.setCoords(-slope, 1.0, a * slope - fa);

    if (!pointOnFunction) T.setCoords(a, fa, 1.0);
  }
Exemplo n.º 3
0
  @Override
  public final void update() {
    isVisible = geo.isEuclidianVisible();
    if (!isVisible) return;
    labelVisible = geo.isLabelVisible();
    updateStrokes(n);
    if (!geo.getDrawAlgorithm().equals(geo.getParentAlgorithm())) init();

    if (gp == null) gp = new GeneralPathClipped(view);
    else gp.reset();

    // init gp
    double aRW = a.getDouble();
    double bRW = b.getDouble();

    // for DrawParametricCurve.plotCurve to work with special values,
    // these changes are needed (also filter out out of screen integrals)
    // see #1234
    aRW = Math.max(aRW, view.getXmin() - EuclidianStatic.CLIP_DISTANCE);
    if (aRW > view.getXmax() + EuclidianStatic.CLIP_DISTANCE) return;

    bRW = Math.min(bRW, view.getXmax() + EuclidianStatic.CLIP_DISTANCE);
    if (bRW < view.getXmin() - EuclidianStatic.CLIP_DISTANCE) return;

    double ax = view.toScreenCoordXd(aRW);
    double bx = view.toScreenCoordXd(bRW);
    float y0 = (float) view.getyZero();

    // plot definite integral

    if (Kernel.isEqual(aRW, bRW)) {
      gp.moveTo(ax, y0);
      gp.lineTo(ax, view.toScreenCoordYd(f.evaluate(aRW)));
      gp.lineTo(ax, y0);
      return;
    }

    gp.moveTo(ax, y0);
    DrawParametricCurve.plotCurve(f, aRW, bRW, view, gp, false, DrawParametricCurve.GAP_LINE_TO);
    gp.lineTo(bx, y0);
    gp.lineTo(ax, y0);

    // gp on screen?
    if (!gp.intersects(0, 0, view.getWidth(), view.getHeight())) {
      isVisible = false;
      // don't return here to make sure that getBounds() works for
      // offscreen points too
    }

    if (labelVisible) {
      xLabel = (int) Math.round((ax + bx) / 2) - 6;
      yLabel = (int) view.getyZero() - view.getFontSize();
      labelDesc = geo.getLabelDescription();
      addLabelOffset();
    }
  }
Exemplo n.º 4
0
  @Override
  public final void compute() {

    size = inputList.size();
    if (!inputList.isDefined() || !function.toGeoElement().isDefined()) {
      r2.setUndefined();
      return;
    }

    GeoFunction funGeo = function.getGeoFunction();

    // Calculate errorsum and ssy:
    double sumyy = 0.0d;
    double sumy = 0.0d;
    double syy = 0.0d;
    double errorsum = 0.0d;
    GeoElement geo = null;
    GeoPoint point = null;
    double x, y, v;

    for (int i = 0; i < size; i++) {
      geo = inputList.get(i);
      if (geo.isGeoPoint()) {
        point = (GeoPoint) geo;
        x = point.getX();
        y = point.getY();
        v = funGeo.evaluate(x);
        errorsum += (v - y) * (v - y);
        sumy += y;
        sumyy += y * y;
      } else {
        r2.setUndefined();
        return;
      } // if calculation is possible
    } // for all points

    syy = sumyy - sumy * sumy / size;

    // calculate RSquare
    r2.setValue(1 - errorsum / syy);
  } // compute()
Exemplo n.º 5
0
  @Override
  public final void compute() {
    // bugfix Michael Borcherds
    // undefined unless A is a point on f
    if (!f.isOnPath(A, Kernel.MIN_PRECISION)) {
      circle.setUndefined();
      return;
    }

    double radius = 1 / Math.abs(curv.getValue());
    double r2 = radius * radius;
    double x = r2 * v.x;
    double y = r2 * v.y;

    R.setCoords(A.inhomX + x, A.inhomY + y, 1.0);
    circle.setCircle(R, A);
  }
 public final String toString() {
   // Michael Borcherds 2008-03-30
   // simplified to allow better Chinese translation
   return app.getPlain("TangentToAatB", f.getLabel(), "x = x(" + P.getLabel() + ")");
 }