Ejemplo n.º 1
0
  private GeoElement[] processParametric(Parametric par) throws CircularDefinitionException {

    /*
    ExpressionValue temp = P.evaluate();
          if (!temp.isVectorValue()) {
              String [] str = { "VectorExpected", temp.toString() };
              throw new MyParseError(kernel.getApplication(), str);
          }

          v.resolveVariables();
          temp = v.evaluate();
          if (!(temp instanceof VectorValue)) {
              String [] str = { "VectorExpected", temp.toString() };
              throw new MyParseError(kernel.getApplication(), str);
          } */

    // point and vector are created silently
    boolean oldMacroMode = cons.isSuppressLabelsActive();
    cons.setSuppressLabelCreation(true);

    // get point
    ExpressionNode node = par.getP();
    node.setForcePoint();
    GeoElement[] temp = processExpressionNode(node);
    GeoPoint P = (GeoPoint) temp[0];

    //	get vector
    node = par.getv();
    node.setForceVector();
    temp = processExpressionNode(node);
    GeoVector v = (GeoVector) temp[0];

    // switch back to old mode
    cons.setSuppressLabelCreation(oldMacroMode);

    // Line through P with direction v
    GeoLine line;
    // independent line
    if (P.isConstant() && v.isConstant()) {
      line = new GeoLine(cons);
      line.setCoords(-v.y, v.x, v.y * P.inhomX - v.x * P.inhomY);
    }
    // dependent line
    else {
      line = kernel.Line(par.getLabel(), P, v);
    }
    line.setToParametric(par.getParameter());
    line.updateRepaint();
    GeoElement[] ret = {line};
    return ret;
  }
Ejemplo n.º 2
0
  protected GeoElement[] processLine(Equation equ, boolean inequality) {
    double a = 0, b = 0, c = 0;
    GeoLine line;
    GeoElement[] ret = new GeoElement[1];
    String label = equ.getLabel();
    Polynomial lhs = equ.getNormalForm();
    boolean isExplicit = equ.isExplicit("y");
    boolean isIndependent = lhs.isConstant();

    if (isIndependent) {
      // get coefficients
      a = lhs.getCoeffValue("x");
      b = lhs.getCoeffValue("y");
      c = lhs.getCoeffValue("");
      line = kernel.Line(label, a, b, c);
    } else line = kernel.DependentLine(label, equ);

    if (isExplicit) {
      line.setToExplicit();
      line.updateRepaint();
    }
    ret[0] = line;
    return ret;
  }