예제 #1
0
  AlgoTangentCurve(Construction cons, String label, GeoPoint P, GeoCurveCartesian f) {
    super(cons);
    this.P = P;
    this.f = f;
    tangent = new GeoLine(cons);

    // check if P is defined as a point of the curve's graph
    pointOnCurve = false;
    if (P.getParentAlgorithm() instanceof AlgoPointOnPath) {
      AlgoPointOnPath algo = (AlgoPointOnPath) P.getParentAlgorithm();
      pointOnCurve = algo.getPath() == f;
    }

    if (pointOnCurve) T = P;
    else T = new GeoPoint(cons);
    tangent.setStartPoint(T);

    // First derivative of curve f
    AlgoDerivative algo = new AlgoDerivative(cons, f);
    this.df = (GeoCurveCartesian) algo.getDerivative();

    cons.removeFromConstructionList(algo);
    setInputOutput(); // for AlgoElement
    compute();
    tangent.setLabel(label);
  }
예제 #2
0
  AlgoDirectrix(Construction cons, String label, GeoConic c) {
    super(cons);
    this.c = c;

    eigenvec = c.eigenvec;
    b = c.b;

    directrix = new GeoLine(cons);
    P = new GeoPoint(cons);
    directrix.setStartPoint(P);

    setInputOutput(); // for AlgoElement
    compute();
    directrix.setLabel(label);
  }
예제 #3
0
  /**
   * Creates a new ray using a geometric transform.
   *
   * @param type of transform (Kernel constant)
   */
  public GeoElement[] createTransformedObject(
      int type, String label, GeoPoint Q, GeoLine l, GeoVector vec, NumberValue n) {
    AlgoElement algoParent = keepTypeOnGeometricTransform ? getParentAlgorithm() : null;

    // CREATE RAY
    if (algoParent instanceof AlgoJoinPointsRay) {
      //	transform points
      AlgoJoinPointsRay algo = (AlgoJoinPointsRay) algoParent;
      GeoPoint[] points = {algo.getP(), algo.getQ()};
      points = kernel.transformPoints(type, points, Q, l, vec, n);
      GeoElement ray = kernel.Ray(label, points[0], points[1]);
      ray.setVisualStyleForTransformations(this);
      GeoElement[] geos = {ray, points[0], points[1]};
      return geos;
    } else if (algoParent instanceof AlgoRayPointVector) {
      // transform startpoint
      GeoPoint[] points = {getStartPoint()};
      points = kernel.transformPoints(type, points, Q, l, vec, n);

      // get transformed line from this ray
      GeoLine transformedLine = kernel.getTransformedLine(type, this, Q, l, vec, n);
      cons.removeFromConstructionList(transformedLine.getParentAlgorithm());

      // get direction of transformed line
      boolean oldSuppressLabelCreation = cons.isSuppressLabelsActive();
      cons.setSuppressLabelCreation(true);
      AlgoDirection algoDir = new AlgoDirection(cons, transformedLine);
      cons.removeFromConstructionList(algoDir);
      GeoVector direction = algoDir.getVector();
      cons.setSuppressLabelCreation(oldSuppressLabelCreation);

      // ray through transformed point with direction of transformed line
      GeoElement ray = kernel.Ray(label, points[0], direction);
      ray.setVisualStyleForTransformations(this);
      GeoElement[] geos = {ray, points[0], direction};
      return geos;

    } else {
      //	create LINE
      GeoLine transformedLine = kernel.getTransformedLine(type, this, Q, l, vec, n);
      transformedLine.setLabel(label);
      GeoElement[] ret = {transformedLine};
      return ret;
    }
  }