Package ca.eandb.jmist.math

Examples of ca.eandb.jmist.math.Point3


    for (int ix = 0; ix < nx; ix++) {
      double x = (double) ix / (double) (nx - 1);
      for (int iz = 0; iz < nz; iz++) {
        double z = (double) iz / (double) (nz - 1);
        points.add(new Point3(bounds.interpolateX(x), height.at(ix, iz), bounds.interpolateZ(z)));
      }
    }

    return Sphere.smallestContaining(points);
View Full Code Here


      assert(ray.direction().x() != 0.0 || ray.direction().y() != 0.0 || ray.direction().z() != 0.0);

      double    t;
      int      n = 0;
      Point3    p;

      // Check for intersection with each of the six sides of the box.
      if (ray.direction().x() != 0.0) {
        t = (box.minimumX() - ray.origin().x()) / ray.direction().x();
        if (t > 0.0) {
          p = ray.pointAt(t);
          if (box.minimumY() < p.y() && p.y() < box.maximumY() && box.minimumZ() < p.z() && p.z() < box.maximumZ()) {
            Intersection x = super.newIntersection(ray, t, ray.direction().x() > 0.0, BOX_SURFACE_MIN_X)
              .setLocation(p);
            recorder.record(x);
            if (++n == 2) return;
          }
        }

        t = (box.maximumX() - ray.origin().x()) / ray.direction().x();
        if (t > 0.0) {
          p = ray.pointAt(t);
          if (box.minimumY() < p.y() && p.y() < box.maximumY() && box.minimumZ() < p.z() && p.z() < box.maximumZ()) {
            Intersection x = super.newIntersection(ray, t, ray.direction().x() < 0.0, BOX_SURFACE_MAX_X)
              .setLocation(p);
            recorder.record(x);
            if (++n == 2) return;
          }
        }
      }

      if (ray.direction().y() != 0.0) {
        t = (box.minimumY() - ray.origin().y()) / ray.direction().y();
        if (t > 0.0) {
          p = ray.pointAt(t);
          if (box.minimumX() < p.x() && p.x() < box.maximumX() && box.minimumZ() < p.z() && p.z() < box.maximumZ()) {
            Intersection x = super.newIntersection(ray, t, ray.direction().y() > 0.0, BOX_SURFACE_MIN_Y)
              .setLocation(p);
            recorder.record(x);
            if (++n == 2) return;
          }
        }

        t = (box.maximumY() - ray.origin().y()) / ray.direction().y();
        if (t > 0.0) {
          p = ray.pointAt(t);
          if (box.minimumX() < p.x() && p.x() < box.maximumX() && box.minimumZ() < p.z() && p.z() < box.maximumZ()) {
            Intersection x = super.newIntersection(ray, t, ray.direction().y() < 0.0, BOX_SURFACE_MAX_Y)
              .setLocation(p);
            recorder.record(x);
            if (++n == 2) return;
          }
        }
      }

      if (ray.direction().z() != 0.0) {
        t = (box.minimumZ() - ray.origin().z()) / ray.direction().z();
        if (t > 0.0) {
          p = ray.pointAt(t);
          if (box.minimumX() < p.x() && p.x() < box.maximumX() && box.minimumY() < p.y() && p.y() < box.maximumY()) {
            Intersection x = super.newIntersection(ray, t, ray.direction().z() > 0.0, BOX_SURFACE_MIN_Z)
              .setLocation(p);
            recorder.record(x);
            if (++n == 2) return;
          }
        }

        t = (box.maximumZ() - ray.origin().z()) / ray.direction().z();
        if (t > 0.0) {
          p = ray.pointAt(t);
          if (box.minimumX() < p.x() && p.x() < box.maximumX() && box.minimumY() < p.y() && p.y() < box.maximumY()) {
            Intersection x = super.newIntersection(ray, t, ray.direction().z() < 0.0, BOX_SURFACE_MAX_Z)
              .setLocation(p);
            recorder.record(x);
            if (++n == 2) return;
          }
View Full Code Here

   */
  @Override
  protected Point2 getTextureCoordinates(GeometryIntersection x) {

    Point2  facePoint;
    Point3  p = x.getPosition();

    switch (x.getTag())
    {
    case BOX_SURFACE_MAX_X:
      facePoint = new Point2(
          (box.maximumZ() - p.z()) / box.lengthX(),
          (box.maximumY() - p.y()) / box.lengthY()
      );
      break;

    case BOX_SURFACE_MIN_X:
      facePoint = new Point2(
          (p.z() - box.minimumZ()) / box.lengthZ(),
          (box.maximumY() - p.y()) / box.lengthY()
      );
      break;

    case BOX_SURFACE_MAX_Y:
      facePoint = new Point2(
          (p.x() - box.minimumX()) / box.lengthX(),
          (p.z() - box.minimumZ()) / box.lengthZ()
      );
      break;

    case BOX_SURFACE_MIN_Y:
      facePoint = new Point2(
          (p.x() - box.minimumX()) / box.lengthX(),
          (box.maximumZ() - p.z()) / box.lengthZ()
      );
      break;

    case BOX_SURFACE_MAX_Z:
      facePoint = new Point2(
          (p.x() - box.minimumX()) / box.lengthX(),
          (box.maximumY() - p.y()) / box.lengthY()
      );
      break;

    case BOX_SURFACE_MIN_Z:
      facePoint = new Point2(
          (p.x() - box.minimumX()) / box.lengthX(),
          (p.y() - box.minimumY()) / box.lengthY()
      );
      break;

    default:
      throw new IllegalArgumentException("invalid surface id");
View Full Code Here

    SeedReference ref = new SeedReference(rj);
    double total = xyArea + xzArea + yzArea;
    boolean dir = RandomUtil.coin(ref);
    int id;
    Point3 p;

    ref.seed *= total;

    if (ref.seed < xyArea) {
      id = dir ? BOX_SURFACE_MAX_Z : BOX_SURFACE_MIN_Z;
      p = new Point3(
          RandomUtil.uniform(box.spanX(), ru),
          RandomUtil.uniform(box.spanY(), rv),
          dir ? box.maximumZ() : box.minimumZ());
    } else if (ref.seed < xyArea + xzArea) {
      id = dir ? BOX_SURFACE_MAX_Y : BOX_SURFACE_MIN_Y;
      p = new Point3(RandomUtil.uniform(box.spanX(), ru),
          dir ? box.maximumY() : box.minimumY(),
          RandomUtil.uniform(box.spanZ(), rv));

    } else {
      id = dir ? BOX_SURFACE_MAX_X : BOX_SURFACE_MIN_X;
      p = new Point3(dir ? box.maximumX() : box.minimumX(),
          RandomUtil.uniform(box.spanY(), ru),
          RandomUtil.uniform(box.spanZ(), rv));
    }

    Intersection x = newSurfacePoint(p, id);
View Full Code Here

TOP

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

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.