コード例 #1
0
  private boolean setQuadric() {
    // check end points
    if (!((GeoElement) origin).isDefined()
        || origin.isInfinite()
        || !((GeoElement) secondPoint).isDefined()
        || secondPoint.isInfinite()
        || !radius.isDefined()) {
      getQuadric().setUndefined();
      return false;
    }

    Coords o = origin.getInhomCoordsInD3();
    Coords o2 = secondPoint.getInhomCoordsInD3();
    Coords d = o2.sub(o);

    if (d.equalsForKernel(0, Kernel.STANDARD_PRECISION)) {
      getQuadric().setUndefined();
      return false;
    }

    double r = radius.getDouble();

    d.calcNorm();
    double altitude = d.getNorm();

    quadric.setDefined();

    setQuadric(o, o2, d.mul(1 / altitude), r, 0, altitude);

    return true;
  }
コード例 #2
0
 @Override
 public void compute() {
   // cover undefined cases
   if (!degree.isDefined() || !min.isDefined() || !max.isDefined() || degree.getDouble() < 0) {
     polynomial.setUndefined();
     return;
   }
   int lower = (int) Math.ceil(min.getDouble());
   int upper = (int) Math.floor(max.getDouble());
   if (lower > upper || (lower == 0 && upper == 0)) {
     polynomial.setUndefined();
     return;
   }
   // input is sane, we can do the computation
   int deg = (int) Math.floor(degree.getDouble());
   ExpressionNode varExpr = new ExpressionNode(kernel, fv);
   ExpressionNode newExpr = randomCoef(deg != 0);
   for (int i = 1; i <= deg; i++) {
     newExpr = varExpr.power(new MyDouble(kernel, i)).multiply(randomCoef(i != deg)).plus(newExpr);
   }
   f.setExpression(newExpr, fv);
   polynomial.setFunction(f);
 }