Beispiel #1
0
  /**
   * <u>Berechnen des Kotangens der komplexen Zahl</u><br>
   *
   * @param comp Komplexe Zahl
   * @return R&uuml;ckgabe eines Objektes vom Typ Complex mit L&ouml;sung aus cot(<u>z</u>)
   */
  public static Complex cot(Complex comp) {
    double nn =
        Math.pow(Math.sin(comp.real) * Math.cosh(comp.imag), 2)
            + Math.pow(Math.cos(comp.real) * Math.sinh(comp.imag), 2);

    return new Complex(
        (Math.cos(comp.real) * Math.sin(comp.real)) / nn,
        (Math.cosh(comp.imag) * Math.sinh(comp.imag)) / nn);
  }
Beispiel #2
0
  /**
   * <u>Berechnen des Kotangens der komplexen Zahl</u><br>
   *
   * @return R&uuml;ckgabe eines Objektes vom Typ Complex mit L&ouml;sung aus cot(<u>z</u>)
   */
  public Complex cot() {
    double nn =
        Math.pow(Math.sin(this.real) * Math.cosh(this.imag), 2)
            + Math.pow(Math.cos(this.real) * Math.sinh(this.imag), 2);

    return new Complex(
        (Math.cos(this.real) * Math.sin(this.real)) / nn,
        (Math.cosh(this.imag) * Math.sinh(this.imag)) / nn);
  }
Beispiel #3
0
 @Override
 public Intent execute(Context context) {
   String[] titles = new String[] {"sin + cos"};
   List<double[]> x = new ArrayList<double[]>();
   List<double[]> values = new ArrayList<double[]>();
   int step = 4;
   int count = 360 / step + 1;
   x.add(new double[count]);
   double[] sinValues = new double[count];
   values.add(sinValues);
   for (int i = 0; i < count; i++) {
     int angle = i * step;
     x.get(0)[i] = angle;
     double rAngle = Math.toRadians(angle);
     sinValues[i] = Math.sinh(rAngle);
   }
   int[] colors = new int[] {Color.RED};
   PointStyle[] styles = new PointStyle[] {PointStyle.POINT};
   XYMultipleSeriesRenderer renderer = buildRenderer(colors, styles);
   setChartSettings(
       renderer,
       "Trigonometric functions",
       "X (in degrees)",
       "Y",
       0,
       360,
       -2,
       2,
       Color.GRAY,
       Color.LTGRAY);
   renderer.setXLabels(20);
   renderer.setYLabels(10);
   return ChartFactory.getLineChartIntent(context, buildDataset(titles, x, values), renderer);
 }
  /** {@inheritDoc} */
  public OpenMapRealVector mapSinhToSelf() {

    Iterator iter = entries.iterator();
    while (iter.hasNext()) {
      iter.advance();
      entries.put(iter.key(), Math.sinh(iter.value()));
    }
    return this;
  }
  /**
   * @param args the function arguments which must be either one object of type Double or Long
   * @return the result of the function evaluation which is the natural logarithm of the first
   *     argument
   */
  public Object evaluateFunction(final Object[] args) {
    final double angleInRadians;
    try {
      angleInRadians = FunctionUtil.getArgAsDouble(args[0]);
    } catch (final Exception e) {
      throw new IllegalArgumentException(
          "can't convert \"" + args[0] + "\" to an angle in radians in a call to TANH().");
    }

    return Math.sinh(angleInRadians) / Math.cosh(angleInRadians);
  }
Beispiel #6
0
  /**
   * draws the inside of the hyperobola part
   *
   * @param center center
   * @param v1 1st eigenvector
   * @param v2 2nd eigenvector
   * @param a 1st eigenvalue
   * @param b 2nd eigenvalue
   * @param tMin t min
   * @param tMax t max
   */
  public void hyperbolaPart(
      Coords center, Coords v1, Coords v2, double a, double b, double tMin, double tMax) {

    manager.startGeometry(Manager.Type.TRIANGLE_FAN);

    manager.texture(0, 0);
    manager.normal(v1.crossProduct(v2));

    int longitude = manager.getLongitudeDefault();

    Coords m;

    float dt = (float) (tMax - tMin) / longitude;

    float u, v;

    // first point on the branch
    u = (float) Math.cosh(tMin);
    v = (float) Math.sinh(tMin);
    m = v1.mul(a * u).add(v2.mul(b * v));

    // center of the fan is midpoint of branch ends
    u = (float) Math.cosh(tMax);
    v = (float) Math.sinh(tMax);
    manager.triangleFanApex(center.add((m.add(v1.mul(a * u).add(v2.mul(b * v)))).mul(0.5)));

    // first point
    manager.triangleFanVertex(center.add(m));

    for (int i = 1; i <= longitude; i++) {
      u = (float) Math.cosh(tMin + i * dt);
      v = (float) Math.sinh(tMin + i * dt);

      m = v1.mul(a * u).add(v2.mul(b * v));
      manager.triangleFanVertex(center.add(m));
    }

    manager.endGeometry();
  }
Beispiel #7
0
 public LuaValue call(LuaValue arg) {
   switch (opcode) {
     case 0:
       return valueOf(Math.acos(arg.checkdouble()));
     case 1:
       return valueOf(Math.asin(arg.checkdouble()));
     case 2:
       return valueOf(Math.atan(arg.checkdouble()));
     case 3:
       return valueOf(Math.cosh(arg.checkdouble()));
     case 4:
       return valueOf(Math.exp(arg.checkdouble()));
     case 5:
       return valueOf(Math.log(arg.checkdouble()));
     case 6:
       return valueOf(Math.log10(arg.checkdouble()));
     case 7:
       return valueOf(Math.sinh(arg.checkdouble()));
     case 8:
       return valueOf(Math.tanh(arg.checkdouble()));
   }
   return NIL;
 }
Beispiel #8
0
 protected double call(double d) {
   return Math.sinh(d);
 }
Beispiel #9
0
  @Override
  protected boolean updateForItSelf() {

    Renderer renderer = getView3D().getRenderer();
    GeoQuadric3D quadric = (GeoQuadric3D) getGeoElement();
    PlotterSurface surface;
    int type = quadric.getType();

    double min, max;

    switch (type) {
      case GeoQuadricNDConstants.QUADRIC_SPHERE:
        Coords center = quadric.getMidpoint3D();
        double radius = quadric.getHalfAxis(0);
        boundsMin.setValues(center, 3);
        boundsMax.setValues(center, 3);
        boundsMin.addInside(-radius);
        boundsMax.addInside(radius);
        checkSphereVisible(center, radius);
        if (visible != Visible.TOTALLY_OUTSIDE) {
          surface = renderer.getGeometryManager().getSurface();
          surface.start(getReusableSurfaceIndex());
          scale = getView3D().getScale();
          longitude = surface.calcSphereLongitudesNeeded(radius, scale);
          drawSphere(surface, center, radius);
          setSurfaceIndex(surface.end());
        } else {
          setSurfaceIndex(-1);
        }
        break;
      case GeoQuadricNDConstants.QUADRIC_ELLIPSOID:
        center = quadric.getMidpoint3D();
        double r0 = quadric.getHalfAxis(0);
        double r1 = quadric.getHalfAxis(1);
        double r2 = quadric.getHalfAxis(2);
        surface = renderer.getGeometryManager().getSurface();
        surface.start(getReusableSurfaceIndex());
        scale = getView3D().getScale();
        radius = Math.max(r0, Math.max(r1, r2));
        longitude = surface.calcSphereLongitudesNeeded(radius, scale);
        Coords ev0 = quadric.getEigenvec3D(0);
        Coords ev1 = quadric.getEigenvec3D(1);
        Coords ev2 = quadric.getEigenvec3D(2);
        surface.drawEllipsoid(center, ev0, ev1, ev2, r0, r1, r2, longitude);
        setSurfaceIndex(surface.end());
        break;

      case GeoQuadricNDConstants.QUADRIC_HYPERBOLOID_ONE_SHEET:
        center = quadric.getMidpoint3D();
        r0 = quadric.getHalfAxis(0);
        r1 = quadric.getHalfAxis(1);
        r2 = quadric.getHalfAxis(2);
        surface = renderer.getGeometryManager().getSurface();
        surface.start(getReusableSurfaceIndex());
        ev0 = quadric.getEigenvec3D(0);
        ev1 = quadric.getEigenvec3D(1);
        ev2 = quadric.getEigenvec3D(2);
        if (vMinMax == null) {
          vMinMax = new double[2];
        }
        vMinMax[0] = Double.POSITIVE_INFINITY;
        vMinMax[1] = Double.NEGATIVE_INFINITY;
        getView3D().getMinIntervalOutsideClipping(vMinMax, center, ev2.mul(r2));
        scale = getView3D().getScale();
        // get radius at max
        radius =
            Math.max(r0, r1)
                * Math.max(Math.abs(vMinMax[0]), Math.max(Math.abs(vMinMax[1]), 1))
                / r2;
        longitude = surface.calcSphereLongitudesNeeded(radius, scale);
        min = DrawConic3D.asinh(vMinMax[0]);
        max = DrawConic3D.asinh(vMinMax[1]);
        surface.drawHyperboloidOneSheet(
            center, ev0, ev1, ev2, r0, r1, r2, longitude, min, max, !getView3D().useClippingCube());
        setSurfaceIndex(surface.end());
        break;

      case GeoQuadricNDConstants.QUADRIC_HYPERBOLOID_TWO_SHEETS:
        center = quadric.getMidpoint3D();
        r0 = quadric.getHalfAxis(0);
        r1 = quadric.getHalfAxis(1);
        r2 = quadric.getHalfAxis(2);
        surface = renderer.getGeometryManager().getSurface();
        surface.start(getReusableSurfaceIndex());
        ev0 = quadric.getEigenvec3D(0);
        ev1 = quadric.getEigenvec3D(1);
        ev2 = quadric.getEigenvec3D(2);
        if (vMinMax == null) {
          vMinMax = new double[2];
        }
        vMinMax[0] = Double.POSITIVE_INFINITY;
        vMinMax[1] = Double.NEGATIVE_INFINITY;
        getView3D().getMinIntervalOutsideClipping(vMinMax, center, ev2.mul(r2));
        scale = getView3D().getScale();
        // get radius at max
        radius = Math.max(r0, r1) * Math.max(Math.abs(vMinMax[0]), Math.abs(vMinMax[1])) / r2;
        longitude = surface.calcSphereLongitudesNeeded(radius, scale);
        if (vMinMax[0] < -1) { // bottom exists
          min = -DrawConic3D.acosh(-vMinMax[0]);
        } else if (vMinMax[0] <= 1) { // top ends at pole
          min = 0;
        } else { // top pole is cut
          min = DrawConic3D.acosh(vMinMax[0]);
        }
        if (vMinMax[1] > 1) { // top exists
          max = DrawConic3D.acosh(vMinMax[1]);
        } else if (vMinMax[1] >= -1) { // bottom ends at pole
          max = 0;
        } else { // bottom pole is cut
          max = -DrawConic3D.acosh(-vMinMax[1]);
        }
        surface.drawHyperboloidTwoSheets(
            center, ev0, ev1, ev2, r0, r1, r2, longitude, min, max, !getView3D().useClippingCube());
        setSurfaceIndex(surface.end());
        break;

      case GeoQuadricNDConstants.QUADRIC_PARABOLOID:
        center = quadric.getMidpoint3D();
        r0 = quadric.getHalfAxis(0);
        r1 = quadric.getHalfAxis(1);
        surface = renderer.getGeometryManager().getSurface();
        surface.start(getReusableSurfaceIndex());
        ev0 = quadric.getEigenvec3D(0);
        ev1 = quadric.getEigenvec3D(1);
        ev2 = quadric.getEigenvec3D(2);
        if (quadric.getHalfAxis(2) < 0) {
          ev0 = ev0.mul(-1);
          ev2 = ev2.mul(-1);
        }
        if (vMinMax == null) {
          vMinMax = new double[2];
        }
        vMinMax[0] = Double.POSITIVE_INFINITY;
        vMinMax[1] = Double.NEGATIVE_INFINITY;
        getView3D().getMinIntervalOutsideClipping(vMinMax, center, ev2);
        if (vMinMax[1] < 0) {
          // nothing to draw
          setSurfaceIndex(surface.end());
        } else {
          scale = getView3D().getScale();
          // get radius at max
          if (vMinMax[0] <= 0) {
            vMinMax[0] = 0;
          } else {
            vMinMax[0] = Math.sqrt(vMinMax[0]);
          }
          vMinMax[1] = Math.sqrt(vMinMax[1]);
          radius = Math.max(r0, r1) * vMinMax[1];
          longitude = surface.calcSphereLongitudesNeeded(radius, scale);
          surface.drawParaboloid(
              center,
              ev0,
              ev1,
              ev2,
              r0,
              r1,
              longitude,
              vMinMax[0],
              vMinMax[1],
              !getView3D().useClippingCube());
          setSurfaceIndex(surface.end());
        }
        break;

      case GeoQuadricNDConstants.QUADRIC_HYPERBOLIC_PARABOLOID:
        center = quadric.getMidpoint3D();
        r0 = quadric.getHalfAxis(0);
        r1 = quadric.getHalfAxis(1);
        surface = renderer.getGeometryManager().getSurface();
        surface.start(getReusableSurfaceIndex());
        ev0 = quadric.getEigenvec3D(0);
        ev1 = quadric.getEigenvec3D(1);
        ev2 = quadric.getEigenvec3D(2);
        if (uMinMax == null) {
          uMinMax = new double[2];
        }
        uMinMax[0] = Double.POSITIVE_INFINITY;
        uMinMax[1] = Double.NEGATIVE_INFINITY;
        getView3D().getMinIntervalOutsideClipping(uMinMax, center, ev0);
        if (vMinMax == null) {
          vMinMax = new double[2];
        }
        vMinMax[0] = Double.POSITIVE_INFINITY;
        vMinMax[1] = Double.NEGATIVE_INFINITY;
        getView3D().getMinIntervalOutsideClipping(vMinMax, center, ev1);
        surface.drawHyperbolicParaboloid(
            center,
            ev0,
            ev1,
            ev2,
            r0,
            r1,
            uMinMax[0],
            uMinMax[1],
            vMinMax[0],
            vMinMax[1],
            !getView3D().useClippingCube());
        setSurfaceIndex(surface.end());
        break;

      case GeoQuadricNDConstants.QUADRIC_PARABOLIC_CYLINDER:
        center = quadric.getMidpoint3D();
        r2 = quadric.getHalfAxis(2);
        surface = renderer.getGeometryManager().getSurface();
        surface.start(getReusableSurfaceIndex());
        ev0 = quadric.getEigenvec3D(0);
        ev1 = quadric.getEigenvec3D(1);
        ev2 = quadric.getEigenvec3D(2);
        if (uMinMax == null) {
          uMinMax = new double[2];
        }
        uMinMax[0] = Double.POSITIVE_INFINITY;
        uMinMax[1] = Double.NEGATIVE_INFINITY;
        if (vMinMax == null) {
          vMinMax = new double[2];
        }
        vMinMax[0] = Double.POSITIVE_INFINITY;
        vMinMax[1] = Double.NEGATIVE_INFINITY;
        getView3D().getMinIntervalOutsideClipping(vMinMax, center, ev0);
        if (vMinMax[1] < 0) {
          // nothing to draw
          setSurfaceIndex(surface.end());
        } else {
          scale = getView3D().getScale();
          // get radius at max
          if (vMinMax[0] <= 0) {
            vMinMax[0] = 0;
          } else {
            vMinMax[0] = Math.sqrt(vMinMax[0]);
          }
          vMinMax[1] = Math.sqrt(vMinMax[1]);
          getView3D().getMinIntervalOutsideClipping(uMinMax, center, ev1);
          surface.drawParabolicCylinder(
              center,
              ev0,
              ev1,
              ev2,
              r2,
              vMinMax[0],
              vMinMax[1],
              uMinMax[0],
              uMinMax[1],
              !getView3D().useClippingCube());
          setSurfaceIndex(surface.end());
        }
        break;

      case GeoQuadricNDConstants.QUADRIC_HYPERBOLIC_CYLINDER:
        center = quadric.getMidpoint3D();
        r0 = quadric.getHalfAxis(0);
        r1 = quadric.getHalfAxis(1);
        surface = renderer.getGeometryManager().getSurface();
        surface.start(getReusableSurfaceIndex());
        ev0 = quadric.getEigenvec3D(0);
        ev1 = quadric.getEigenvec3D(1);
        ev2 = quadric.getEigenvec3D(2);
        if (uMinMax == null) {
          uMinMax = new double[2];
        }
        uMinMax[0] = Double.POSITIVE_INFINITY;
        uMinMax[1] = Double.NEGATIVE_INFINITY;
        getView3D().getMinIntervalOutsideClipping(uMinMax, center, ev0.mul(r0));
        scale = getView3D().getScale();
        if (uMinMax[0] < -1) { // bottom exists
          min = -DrawConic3D.acosh(-uMinMax[0]);
        } else if (uMinMax[0] <= 1) { // top ends at pole
          min = 0;
        } else { // top pole is cut
          min = DrawConic3D.acosh(uMinMax[0]);
        }
        if (uMinMax[1] > 1) { // top exists
          max = DrawConic3D.acosh(uMinMax[1]);
        } else if (uMinMax[1] >= -1) { // bottom ends at pole
          max = 0;
        } else { // bottom pole is cut
          max = -DrawConic3D.acosh(-uMinMax[1]);
        }
        if (vMinMax == null) {
          vMinMax = new double[2];
        }
        vMinMax[0] = Double.POSITIVE_INFINITY;
        vMinMax[1] = Double.NEGATIVE_INFINITY;
        getView3D().getMinIntervalOutsideClipping(vMinMax, center, ev2);
        if (min < 0) {
          surface.drawHyperbolicCylinder(
              center,
              ev0.mul(-1),
              ev1.mul(-1),
              ev2,
              r0,
              r1,
              -max,
              -min,
              vMinMax[0],
              vMinMax[1],
              !getView3D().useClippingCube());
        }
        if (max > 0) {
          surface.drawHyperbolicCylinder(
              center,
              ev0,
              ev1,
              ev2,
              r0,
              r1,
              min,
              max,
              vMinMax[0],
              vMinMax[1],
              !getView3D().useClippingCube());
        }
        uMinMax[0] = Math.sinh(min);
        uMinMax[1] = Math.sinh(max);
        setSurfaceIndex(surface.end());

        break;

      case GeoQuadricNDConstants.QUADRIC_CONE:
        surface = renderer.getGeometryManager().getSurface();
        surface.start(getReusableSurfaceIndex());
        if (quadric instanceof GeoQuadric3DPart) { // simple cone
          double height =
              ((GeoQuadric3DPart) quadric).getBottomParameter()
                  - ((GeoQuadric3DPart) quadric).getTopParameter();
          Coords top = quadric.getMidpoint3D();
          ev1 = quadric.getEigenvec3D(0);
          ev2 = quadric.getEigenvec3D(1);
          radius = quadric.getHalfAxis(0);
          double radius2 = quadric.getHalfAxis(1);
          Coords bottomCenter =
              surface.cone(
                  top,
                  ev1,
                  ev2,
                  quadric.getEigenvec3D(2),
                  radius,
                  radius2,
                  0,
                  2 * Math.PI,
                  height,
                  1f);

          boundsMin.setValues(top, 3);
          boundsMax.setValues(top, 3);
          radius *= height;
          enlargeBoundsToDiagonal(boundsMin, boundsMax, bottomCenter, ev1, ev2, radius, radius2);

        } else { // infinite cone
          if (vMinMax == null) {
            vMinMax = new double[2];
          }
          vMinMax[0] = Double.POSITIVE_INFINITY;
          vMinMax[1] = Double.NEGATIVE_INFINITY;
          getMinMax(vMinMax);
          min = vMinMax[0];
          max = vMinMax[1];
          // min -= delta;
          // max += delta;
          // App.debug(min+","+max);
          center = quadric.getMidpoint3D();
          ev1 = quadric.getEigenvec3D(0);
          ev2 = quadric.getEigenvec3D(1);
          Coords ev3 = quadric.getEigenvec3D(2);
          r1 = quadric.getHalfAxis(0);
          r2 = quadric.getHalfAxis(1);

          if (min * max < 0) {
            if (getView3D().useClippingCube()) {
              surface.cone(center, ev1, ev2, ev3, r1, r2, 0, 2 * Math.PI, min, 1f);
              surface.cone(center, ev1, ev2, ev3, r1, r2, 0, 2 * Math.PI, max, 1f);
            } else {
              surface.cone(
                  center,
                  ev1,
                  ev2,
                  ev3,
                  r1,
                  r2,
                  0,
                  2 * Math.PI,
                  min,
                  (float) ((-9 * min - max) / (min - max)));
              surface.cone(
                  center,
                  ev1,
                  ev2,
                  ev3,
                  r1,
                  r2,
                  0,
                  2 * Math.PI,
                  max,
                  (float) ((-9 * max - min) / (max - min)));
            }
          } else {
            if (getView3D().useClippingCube()) {
              surface.cone(center, ev1, ev2, ev3, r1, r2, 0, 2 * Math.PI, min, max, false, false);
            } else {
              double delta = (max - min) / 10;
              surface.cone(
                  center,
                  ev1,
                  ev2,
                  ev3,
                  r1,
                  r2,
                  0,
                  2 * Math.PI,
                  min + delta,
                  max - delta,
                  false,
                  false);
              surface.cone(
                  center, ev1, ev2, ev3, r1, r2, 0, 2 * Math.PI, min, min + delta, true, false);
              surface.cone(
                  center, ev1, ev2, ev3, r1, r2, 0, 2 * Math.PI, max - delta, max, false, true);
            }
          }
        }

        setSurfaceIndex(surface.end());
        break;

      case GeoQuadricNDConstants.QUADRIC_CYLINDER:
        center = quadric.getMidpoint3D();
        ev1 = quadric.getEigenvec3D(0);
        ev2 = quadric.getEigenvec3D(1);
        Coords ev3 = quadric.getEigenvec3D(2);

        surface = renderer.getGeometryManager().getSurface();
        surface.start(getReusableSurfaceIndex());

        if (quadric instanceof GeoQuadric3DPart) { // simple cylinder
          radius = quadric.getHalfAxis(0);
          double radius2 = quadric.getHalfAxis(1);
          longitude = renderer.getGeometryManager().getLongitude(radius, getView3D().getScale());
          Coords bottomCenter =
              surface.cylinder(
                  center,
                  ev1,
                  ev2,
                  ev3,
                  radius,
                  radius2,
                  0,
                  2 * Math.PI,
                  quadric.getMinParameter(1),
                  quadric.getMaxParameter(1),
                  false,
                  false,
                  longitude);

          boundsMin.set(Double.POSITIVE_INFINITY);
          boundsMax.set(Double.NEGATIVE_INFINITY);
          enlargeBoundsToDiagonal(boundsMin, boundsMax, center, ev1, ev2, radius, radius);
          enlargeBoundsToDiagonal(boundsMin, boundsMax, bottomCenter, ev1, ev2, radius, radius);

        } else {
          if (vMinMax == null) {
            vMinMax = new double[2];
          }
          vMinMax[0] = Double.POSITIVE_INFINITY;
          vMinMax[1] = Double.NEGATIVE_INFINITY;
          getMinMax(vMinMax);
          min = vMinMax[0];
          max = vMinMax[1];
          r1 = quadric.getHalfAxis(0);
          r2 = quadric.getHalfAxis(1);
          radius = Math.max(r1, r2);

          longitude = renderer.getGeometryManager().getLongitude(radius, getView3D().getScale());
          if (getView3D().useClippingCube()) {
            surface.cylinder(
                center, ev1, ev2, ev3, r1, r2, 0, 2 * Math.PI, min, max, false, false, longitude);
          } else {
            double delta = (max - min) / 10;
            surface.cylinder(
                center,
                ev1,
                ev2,
                ev3,
                r1,
                r2,
                0,
                2 * Math.PI,
                min + delta,
                max - delta,
                false,
                false,
                longitude);
            surface.cylinder(
                center,
                ev1,
                ev2,
                ev3,
                r1,
                r2,
                0,
                2 * Math.PI,
                min,
                min + delta,
                true,
                false,
                longitude);
            surface.cylinder(
                center,
                ev1,
                ev2,
                ev3,
                r1,
                r2,
                0,
                2 * Math.PI,
                max - delta,
                max,
                false,
                true,
                longitude);
          }
        }

        setSurfaceIndex(surface.end());

        break;

      case GeoQuadricNDConstants.QUADRIC_SINGLE_POINT:
        surface = renderer.getGeometryManager().getSurface();
        surface.start(getReusableSurfaceIndex());
        Coords m = quadric.getMidpoint3D();
        double thickness =
            quadric.getLineThickness() / getView3D().getScale() * DrawPoint3D.DRAW_POINT_FACTOR;
        surface.drawSphere(quadric.getLineThickness(), m, thickness);
        setSurfaceIndex(surface.end());

        boundsMin.setValues(m, 3);
        boundsMax.setValues(m, 3);
        boundsMin.addInside(-thickness);
        boundsMax.addInside(thickness);
        break;

      case GeoQuadricNDConstants.QUADRIC_PARALLEL_PLANES:
      case GeoQuadricNDConstants.QUADRIC_INTERSECTING_PLANES:
        initDrawPlanes(quadric);
        drawPlanes[0].updateForItSelf();
        drawPlanes[1].updateForItSelf();
        break;

      case GeoQuadricNDConstants.QUADRIC_PLANE:
        initDrawPlanes(quadric);
        drawPlanes[0].updateForItSelf();
        break;

      case GeoQuadricNDConstants.QUADRIC_LINE:
        initDrawLine(quadric);
        drawLine.updateForItSelf();
        break;

      default:
        setSurfaceIndex(-1);
    }

    return true;
  }
Beispiel #10
0
 public static IntervalDouble math_sinh(IntervalDouble a) {
   IntervalDouble res =
       new IntervalDouble(Math.sinh(a.value), DoubleInterval.sinh(a.interval), a.isUnStable);
   return res;
 }
  @Override
  public Object visit(RealUnaryExpression n, Void arg) {
    Double doubleObject = (Double) n.getOperand().accept(this, null);
    double doubleVal = doubleObject.doubleValue();

    Operator op = n.getOperator();
    switch (op) {
      case ABS:
        return Math.abs(doubleVal);
      case ACOS:
        return Math.acos(doubleVal);
      case ASIN:
        return Math.asin(doubleVal);
      case ATAN:
        return Math.atan(doubleVal);
      case CBRT:
        return Math.cbrt(doubleVal);
      case CEIL:
        return Math.ceil(doubleVal);
      case COS:
        return Math.cos(doubleVal);
      case COSH:
        return Math.cosh(doubleVal);
      case EXP:
        return Math.exp(doubleVal);
      case EXPM1:
        return Math.expm1(doubleVal);
      case FLOOR:
        return Math.floor(doubleVal);
      case LOG:
        return Math.log(doubleVal);
      case LOG10:
        return Math.log10(doubleVal);
      case LOG1P:
        return Math.log1p(doubleVal);
      case NEG:
        return -doubleVal;
      case NEXTUP:
        return Math.nextUp(doubleVal);
      case RINT:
        return Math.rint(doubleVal);
      case SIGNUM:
        return Math.signum(doubleVal);
      case SIN:
        return Math.sin(doubleVal);
      case SINH:
        return Math.sinh(doubleVal);
      case SQRT:
        return Math.sqrt(doubleVal);
      case TAN:
        return Math.tan(doubleVal);
      case TANH:
        return Math.tanh(doubleVal);
      case TODEGREES:
        return Math.toDegrees(doubleVal);
      case TORADIANS:
        return Math.toRadians(doubleVal);
      case ULP:
        return Math.ulp(doubleVal);

      default:
        log.warn("RealUnaryExpression: unimplemented operator: " + op);
        return null;
    }
  }
Beispiel #12
0
 @Override
 public O compute(I x, O output) {
   double value = Math.sinh(x.getRealDouble());
   output.setReal(value);
   return output;
 }
 // To add/remove functions change evaluateOperator() and registration
 public double evaluateFunction(String fncnam, ArgParser fncargs) throws ArithmeticException {
   switch (Character.toLowerCase(fncnam.charAt(0))) {
     case 'a':
       {
         if (fncnam.equalsIgnoreCase("abs")) {
           return Math.abs(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("acos")) {
           return Math.acos(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("asin")) {
           return Math.asin(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("atan")) {
           return Math.atan(fncargs.next());
         }
       }
       break;
     case 'c':
       {
         if (fncnam.equalsIgnoreCase("cbrt")) {
           return Math.cbrt(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("ceil")) {
           return Math.ceil(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("cos")) {
           return Math.cos(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("cosh")) {
           return Math.cosh(fncargs.next());
         }
       }
       break;
     case 'e':
       {
         if (fncnam.equalsIgnoreCase("exp")) {
           return Math.exp(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("expm1")) {
           return Math.expm1(fncargs.next());
         }
       }
       break;
     case 'f':
       {
         if (fncnam.equalsIgnoreCase("floor")) {
           return Math.floor(fncargs.next());
         }
       }
       break;
     case 'g':
       {
         //              if(fncnam.equalsIgnoreCase("getExponent"   )) { return
         // Math.getExponent(fncargs.next());                } needs Java 6
       }
       break;
     case 'l':
       {
         if (fncnam.equalsIgnoreCase("log")) {
           return Math.log(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("log10")) {
           return Math.log10(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("log1p")) {
           return Math.log1p(fncargs.next());
         }
       }
       break;
     case 'm':
       {
         if (fncnam.equalsIgnoreCase("max")) {
           return Math.max(fncargs.next(), fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("min")) {
           return Math.min(fncargs.next(), fncargs.next());
         }
       }
       break;
     case 'n':
       {
         //              if(fncnam.equalsIgnoreCase("nextUp"        )) { return Math.nextUp
         // (fncargs.next());                } needs Java 6
       }
       break;
     case 'r':
       {
         if (fncnam.equalsIgnoreCase("random")) {
           return Math.random();
         } // impure
         if (fncnam.equalsIgnoreCase("round")) {
           return Math.round(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("roundHE")) {
           return Math.rint(fncargs.next());
         } // round half-even
       }
       break;
     case 's':
       {
         if (fncnam.equalsIgnoreCase("signum")) {
           return Math.signum(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("sin")) {
           return Math.sin(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("sinh")) {
           return Math.sinh(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("sqrt")) {
           return Math.sqrt(fncargs.next());
         }
       }
       break;
     case 't':
       {
         if (fncnam.equalsIgnoreCase("tan")) {
           return Math.tan(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("tanh")) {
           return Math.tanh(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("toDegrees")) {
           return Math.toDegrees(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("toRadians")) {
           return Math.toRadians(fncargs.next());
         }
       }
       break;
     case 'u':
       {
         if (fncnam.equalsIgnoreCase("ulp")) {
           return Math.ulp(fncargs.next());
         }
       }
       break;
       // no default
   }
   throw new UnsupportedOperationException(
       "MathEval internal function setup is incorrect - internal function \""
           + fncnam
           + "\" not handled");
 }
Beispiel #14
0
  /**
   * Evaluates the Jacobian elliptic functions sn(u|m), cn(u|m), and dn(u|m) of parameter m between
   * 0 and 1, and real argument u. (based on the function from the Cephes Math Library)
   *
   * @param u
   * @param m
   * @return an array containing the values of the functions sn(u|m), cn(u|m), dn(u|m) and phi, the
   *     amplitude of u
   */
  public static double[] calculateJacobianEllipticFunctionsValues(double u, double m) {

    double ai, b, phi, t, twon;
    double sn, cn, ph, dn;
    double[] a = new double[9];
    double[] c = new double[9];
    int i;

    // Check for special cases
    if (m < 0.0 || m > 1.0 || Double.isNaN(m))
      throw new IllegalArgumentException("m should be in <0,1>");
    if (m < 1.0e-9) {

      t = Math.sin(u);
      b = Math.cos(u);
      ai = 0.25 * m * (u - t * b);
      sn = t - ai * b;
      cn = b + ai * t;
      ph = u - ai;
      dn = 1.0 - 0.5 * m * t * t;
      return new double[] {sn, cn, dn, ph};
    }
    if (m >= 0.9999999999) {
      ai = 0.25 * (1.0 - m);
      b = Math.cosh(u);
      t = Math.tanh(u);
      phi = 1.0 / b;
      twon = b * Math.sinh(u);

      sn = t + ai * (twon - u) / (b * b);
      ph = 2.0 * Math.atan(Math.exp(u)) - Math.PI / 2 + ai * (twon - u) / b;
      ai *= t * phi;
      cn = phi - ai * (twon - u);
      dn = phi + ai * (twon + u);
      return new double[] {sn, cn, dn, ph};
    }

    //	A. G. M. scale
    a[0] = 1.0;
    b = Math.sqrt(1.0 - m);
    c[0] = Math.sqrt(m);
    twon = 1.0;
    i = 0;

    while (Math.abs(c[i] / a[i]) > getMachineEpsilon()) {

      if (i > 7)
        throw new IllegalArgumentException(
            "Jacobian elliptic functions cannot be calculated due to overflow range error");
      ai = a[i];
      i++;
      c[i] = (ai - b) / 2.0;
      t = Math.sqrt(ai * b);
      a[i] = (ai + b) / 2.0;
      b = t;
      twon *= 2.0;
    }

    // backward recurrence
    phi = twon * a[i] * u;
    do {

      t = c[i] * Math.sin(phi) / a[i];
      b = phi;
      phi = (Math.asin(t) + phi) / 2.0;
      i--;

    } while (i > 0);

    sn = Math.sin(phi);
    t = Math.cos(phi);
    cn = t;
    dn = t / Math.cos(phi - b);
    ph = phi;

    return new double[] {sn, cn, dn, ph};
  }
Beispiel #15
0
 public static double gamma(double n) {
   return Math.sqrt(2.0 * Math.PI / n)
       * Math.pow(
           (n / Math.E) * Math.sqrt(n * Math.sinh((1.0 / n) + (1 / 810 * Math.pow(n, 6)))), n);
 }
 @Override
 protected double compute(double value) {
   return Double.isNaN(value) ? Double.NaN : Math.sinh(value);
 }
Beispiel #17
0
 // return a new Complex object whose value is the complex cosine of this
 public Complex cos() {
   return new Complex(Math.cos(re) * Math.cosh(im), -Math.sin(re) * Math.sinh(im));
 }
Beispiel #18
0
 /**
  * <u>Berechnen der e-Funktion der komplexen Zahl</u><br>
  *
  * @return R&uuml;ckgabe eines Objektes vom Typ Complex mit L&ouml;sung aus exp(<u>z</u>)
  */
 public Complex exp() {
   return new Complex(
       Math.cos(this.getImag()) * (Math.sinh(this.getReal()) + Math.cosh(this.getReal())),
       Math.sin(this.getImag()) * (Math.cosh(this.getReal()) + Math.sinh(this.getReal())));
 }
Beispiel #19
0
 public RealNumber sinh() {
   return new RealNumber(Math.sinh(this.value));
 }
Beispiel #20
0
 /**
  * <u>Berechnen der e-Funktion der komplexen Zahl</u><br>
  *
  * @param comp Komplexe Zahl
  * @return R&uuml;ckgabe eines Objektes vom Typ Complex mit L&ouml;sung aus exp(<u>z</u>)
  */
 public static Complex exp(Complex comp) {
   return new Complex(
       Math.cos(comp.getImag()) * (Math.sinh(comp.getReal()) + Math.cosh(comp.getReal())),
       Math.sin(comp.getImag()) * (Math.cosh(comp.getReal()) + Math.sinh(comp.getReal())));
 }
Beispiel #21
0
 public static double besselJ(double nu, double x) {
   double next, sum, next1, next2, sum1, sum2, int1, int2, yp, y, yn, h;
   long m, N;
   if (x < 0) return Double.NaN;
   if ((nu < 0) && (Math.round(nu) == nu))
     if (((int) Math.round(nu)) % 2 == 1) return -besselJ(-nu, x);
     else return besselJ(-nu, x);
   if ((nu == 0.0) && (x == 0.0)) return 1.0;
   if (x == 0.0) return 0.0;
   // power series
   if ((x <= 15) || (x * x < 15 * nu)) {
     next = Math.pow(x / 2, nu) / eulergamma(nu + 1);
     sum = next;
     // int max = (int)(200>5*nu?200*x:5*nu*x);
     int max = 200;
     for (m = 1; m < max; m++) {
       next *= (-1) * (x * x / 4) / (m * (m + nu));
       sum += next;
     }
     return sum;
   } else if (8 * x > (nu * nu)) {
     // asymptotic expansion
     // if((x>30)&&(x>(3*(nu*nu-0.25)))){
     next1 = 1;
     sum1 = next1;
     next2 = (4 * nu * nu - 1) / (8 * x);
     sum2 = next2;
     int max = 10 > nu ? 10 : (int) nu;
     for (m = 1; m <= max; m++) {
       next1 *=
           -(4 * nu * nu - (4 * m - 3) * (4 * m - 3))
               * (4 * nu * nu - (4 * m - 1) * (4 * m - 1))
               / ((2 * m - 1) * 2 * m * 8 * x * 8 * x);
       sum1 += next1;
       next2 *=
           -(4 * nu * nu - (4 * m - 1) * (4 * m - 1))
               * (4 * nu * nu - (4 * m + 1) * (4 * m + 1))
               / (2 * m * (2 * m + 1) * 8 * x * 8 * x);
       sum2 += next2;
     }
     return Math.sqrt(2 / (pi * x))
         * (Math.cos(x - pi * nu / 2 - pi / 4) * sum1 - Math.sin(x - pi * nu / 2 - pi / 4) * sum2);
   }
   // integral
   N = (long) 40 * Math.round(x);
   h = pi / N;
   yp = 1;
   y = Math.cos(nu * h - x * Math.sin(h));
   yn = Math.cos(nu * 2 * h - x * Math.sin(2 * h));
   int1 = h / 3 * (yp + 4 * y + yn);
   for (m = 3; m < N; m += 2) {
     yp = yn;
     y = Math.cos(nu * m * h - x * Math.sin(m * h));
     yn = Math.cos(nu * (m + 1) * h - x * Math.sin((m + 1) * h));
     int1 += h / 3 * (yp + 4 * y + yn);
   }
   if (nu == Math.round(nu)) return int1 / pi;
   h = 0.0004;
   yp = 1;
   y = Math.exp(-x * Math.sinh(h) - nu * h);
   yn = Math.exp(-x * Math.sinh(2 * h) - nu * h);
   int2 = h / 3 * (yp + 4 * y + yn);
   for (m = 3; m < 5000; m += 2) {
     yp = yn;
     y = Math.exp(-x * Math.sinh(m * h) - nu * m * h);
     yn = Math.exp(-x * Math.sinh((m + 1) * h) - nu * (m + 1) * h);
     int2 += h / 3 * (yp + 4 * y + yn);
   }
   return int1 / pi - Math.sin(nu * pi) * int2 / pi;
 }