Package ca.eandb.jmist.math

Examples of ca.eandb.jmist.math.Interval


  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.scene.SceneElementDecorator#intersect(int, ca.eandb.jmist.math.Ray3, ca.eandb.jmist.framework.IntersectionRecorder)
   */
  @Override
  public void intersect(int index, Ray3 ray, IntersectionRecorder recorder) {
    Interval I = recorder.interval();

    do {
      NearestIntersectionRecorder rec = new NearestIntersectionRecorder(I);
      super.intersect(index, ray, rec);

      if (rec.isEmpty()) {
        break;
      }
      Intersection x = rec.nearestIntersection();
      MinimalShadingContext ctx = new MinimalShadingContext(Random.DEFAULT);
      x.prepareShadingContext(ctx);
      Point2 uv = ctx.getUV();
      if (trim.opacity(new Point2(uv.x(), 1.0 - uv.y())) > 0.5) {
        recorder.record(x);
        if (!recorder.needAllIntersections()) {
          break;
        }
      }
      ray = ray.advance(x.getDistance());
      I = new Interval(0, I.maximum() - x.getDistance());
    } while (true);

  }
View Full Code Here


  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.scene.SceneElementDecorator#intersect(ca.eandb.jmist.math.Ray3, ca.eandb.jmist.framework.IntersectionRecorder)
   */
  @Override
  public void intersect(Ray3 ray, IntersectionRecorder recorder) {
    Interval I = recorder.interval();

    do {
      NearestIntersectionRecorder rec = new NearestIntersectionRecorder(I);
      super.intersect(ray, rec);

      if (rec.isEmpty()) {
        break;
      }
      Intersection x = rec.nearestIntersection();
      MinimalShadingContext ctx = new MinimalShadingContext(Random.DEFAULT);
      x.prepareShadingContext(ctx);
      Point2 uv = ctx.getUV();
      if (trim.opacity(new Point2(uv.x(), 1.0 - uv.y())) > 0.5) {
        recorder.record(x);
        if (!recorder.needAllIntersections()) {
          break;
        }
      }
      ray = ray.advance(x.getDistance());
      I = new Interval(0, I.maximum() - x.getDistance());
    } while (true);

  }
View Full Code Here

   * @see ca.eandb.jmist.framework.IntersectionRecorder#record(ca.eandb.jmist.framework.Intersection)
   */
  public void record(Intersection intersection) {
    if (this.interval.contains(intersection.getDistance(), intersection.getTolerance())) {
      this.nearest = intersection;
      this.interval = new Interval(interval.minimum(), nearest.getDistance());
    }
  }
View Full Code Here

   * @param index The index of the primitive to intersect the ray with.
   * @return The nearest <code>Intersection</code>, or <code>null</code> if
   *     none exists.
   */
  public static Intersection computeNearestIntersection(Ray3 ray, SceneElement geometry, int index) {
    Interval I = new Interval(0.0, ray.limit());
    NearestIntersectionRecorder recorder = new NearestIntersectionRecorder(I);
    geometry.intersect(index, ray, recorder);
    return recorder.nearestIntersection();
  }
View Full Code Here

   *     with.
   * @return The nearest <code>Intersection</code>, or <code>null</code> if
   *     none exists.
   */
  public static Intersection computeNearestIntersection(Ray3 ray, SceneElement geometry) {
    Interval I = new Interval(0.0, ray.limit());
    NearestIntersectionRecorder recorder = new NearestIntersectionRecorder(I);
    geometry.intersect(ray, recorder);
    return recorder.nearestIntersection();
  }
View Full Code Here

    if (I.isEmpty()) { // missed the grid entirely
      return false;
    }

    Interval  cellI = new Interval(I.minimum(), I.minimum());
    Vector3    d = ray.direction();
    Point3    p = ray.pointAt(I.minimum());
    Cell    cell;
    Cell    nextCell = this.nearestCell(p);
    double    rx = p.x() - (bound.minimumX() + (double) nextCell.cx * dx);
    double    ry = p.y() - (bound.minimumY() + (double) nextCell.cy * dy);
    double    rz = p.z() - (bound.minimumZ() + (double) nextCell.cz * dz);

    do {

      cell = nextCell;

      double  tx, ty, tz, t;

      tx = (d.x() > 0.0) ? (dx - rx) / d.x() : -rx / d.x();
      ty = (d.y() > 0.0) ? (dy - ry) / d.y() : -ry / d.y();
      tz = (d.z() > 0.0) ? (dz - rz) / d.z() : -rz / d.z();

      if (tx < ty && tx < tz) {
        t = tx;
        rx = (d.x() > 0.0) ? 0.0 : dx;
        ry += t * d.y();
        rz += t * d.z();
        nextCell = new Cell(cell.cx + (d.x() > 0.0 ? 1 : -1), cell.cy, cell.cz);
      } else if (ty < tz) {
        t = ty;
        rx += t * d.x();
        ry = (d.y() > 0.0) ? 0.0 : dy;
        rz += t * d.z();
        nextCell = new Cell(cell.cx, cell.cy + (d.y() > 0.0 ? 1 : -1), cell.cz);
      } else { // tz <= tx && tz <= ty
        t = tz;
        rx += t * d.x();
        ry += t * d.y();
        rz = (d.z() > 0.0) ? 0.0 : dz;
        nextCell = new Cell(cell.cx, cell.cy, cell.cz + (d.z() > 0.0 ? 1 : -1));
      }

      cellI = new Interval(cellI.maximum(), cellI.maximum() + t);

      if (cellI.maximum() > I.maximum()) {
        cellI = cellI.intersect(I);
        visitor.visit(ray, cellI, cell);
        break;
      }


View Full Code Here

      Point2    p    = pointOnImagePlane;
      double    nx    = 2.0 * (p.x() - 0.5);
      double    ny    = 2.0 * (0.5 - p.y());

      Ray3    init  = new Ray3(new Point3(nx, ny, 1.0), Vector3.K);
      Interval  I    = LENS_SPHERE.intersect(init);

      if (I.isEmpty()) {
        return null;
      }

      Vector3    n    = LENS_SPHERE.center().vectorTo(init.pointAt(I.minimum()));
      Vector3    r    = Optics.reflect(init.direction(), n);

      Ray3    ray    = new Ray3(Point3.ORIGIN, r);
      Color    color  = getWhite();
      double    pdf    = 1.0 / 16.0;
View Full Code Here

  /**
   * @param maxDistance
   */
  public DistanceShader(double maxDistance) {
    this(new Interval(0, maxDistance));
  }
View Full Code Here

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.scene.SceneElementDecorator#visibility(ca.eandb.jmist.math.Ray3)
   */
  @Override
  public boolean visibility(Ray3 ray) {
    NearestIntersectionRecorder recorder = new NearestIntersectionRecorder(new Interval(0.0, ray.limit()));
    intersect(ray, recorder);
    return recorder.isEmpty();
  }
View Full Code Here

   * @see ca.eandb.jmist.framework.scene.SceneElementDecorator#intersect(ca.eandb.jmist.math.Ray3, ca.eandb.jmist.framework.IntersectionRecorder)
   */
  @Override
  public void intersect(Ray3 ray, IntersectionRecorder recorder) {
    ensureReady();
    Interval I = boundingBox.intersect(ray).intersect(recorder.interval());
    if (!I.isEmpty()) {
      intersectNode(root, I.minimum(), I.maximum(), ray, recorder);
    }
  }
View Full Code Here

TOP

Related Classes of ca.eandb.jmist.math.Interval

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.