Package ca.eandb.jmist.math

Examples of ca.eandb.jmist.math.Ray3


     */
    public ScatteredRay sample(double ru, double rv, double rj) {
      Point3 o = context.getPosition();
      Vector3 n = context.getNormal();
      Vector3 v = RandomUtil.diffuse(ru, rv).toCartesian(Basis3.fromW(n));
      Ray3 ray = new Ray3(o, v);
      Color color = getWhite();
      return ScatteredRay.diffuse(ray, color, 1.0 / Math.PI);
    }
View Full Code Here


        double    sx = Math.sin(nx);
        double    sy = Math.sin(ny);
        double    cx = Math.cos(nx);
        double    cy = Math.cos(ny);

        Ray3    ray = new Ray3(
                  Point3.ORIGIN,
                  new Vector3(-sx * cy, sy, -cx * cy));
        Color    color = getWhite();
        double    pdf = 1.0 / solidAngle;
      return ScatteredRay.diffuse(ray, color, pdf);
View Full Code Here

    /* (non-Javadoc)
     * @see ca.eandb.jmist.framework.path.EyeNode#project(ca.eandb.jmist.math.HPoint3)
     */
    public Point2 project(HPoint3 x) {
      Ray3 ray = new Ray3(Point3.ORIGIN, x);
      Vector3 v = ray.direction().unit();
      double phi = Math.atan2(v.x(), -v.z());
      if (Math.abs(phi) > 0.5 * hfov) {
        return null;
      }
      double theta = Math.asin(v.y());
View Full Code Here

      if (v > 0.0) { // left to right

        if (0.0 < ld) {
          int child = buffer.getLeftChild(node);
          if (child >= 0) {
            ray = new Ray3(
                ray.origin(),
                ray.direction(),
                Math.min(ld, ray.limit()));
            if (!nodeVisibility(child, ray)) {
              return false;
            }
          }
        }

        if (rd < ray.limit()) {
          int child = buffer.getRightChild(node);
          if (child >= 0) {
            if (rd > 0.0) {
              ray = ray.advance(rd);
            }
            if (!nodeVisibility(child, ray)) {
              return false;
            }
          }
        }

      } else { // right to left

        if (0.0 < rd) {
          int child = buffer.getRightChild(node);
          if (child >= 0) {
            ray = new Ray3(
                ray.origin(),
                ray.direction(),
                Math.min(rd, ray.limit()));
            if (!nodeVisibility(child, ray)) {
              return false;
View Full Code Here

//    }
//
//    return null;

    col = col.times(-thickness / Math.abs(x.getNormal().dot(v))).exp();
    return ScatteredRay.transmitSpecular(new Ray3(x.getPosition(), v), col, 1.0);

  }
View Full Code Here

      Vector3 microN = sc.toCartesian(basis);
      out = Optics.reflect(v, microN);
      if (out.dot(N) <= 0.0) {
        return null;
      }
      return ScatteredRay.diffuse(new Ray3(x.getPosition(), out), lambda.getColorModel().getWhite(lambda), 1.0);
    } else {
      v = Optics.refract(v, n1, n2, N);
      return ScatteredRay.transmitDiffuse(new Ray3(x.getPosition(), v), lambda.getColorModel().getWhite(lambda), 1.0);
    }
  }
View Full Code Here

      SphericalCoordinates sc = new SphericalCoordinates(theta, phi);
      v = sc.toCartesian(basis);
      outDir = (v.dot(N) < 0.0);
    } while (inDir != outDir);

    return ScatteredRay.diffuse(new Ray3(x.getPosition(), v), lambda.getColorModel().getWhite(lambda), 1.0);
  }
View Full Code Here

    Vector3 N = x.getNormal();
    double R = Optics.reflectance(v, n1, n2, N);

    if (RandomUtil.bernoulli(R, ru)) {
      v = Optics.reflect(v, N);
      return ScatteredRay.specular(new Ray3(x.getPosition(), v),
          lambda.getColorModel().getWhite(lambda), 1.0);
    } else {
      v = Optics.refract(v, n1, n2, N);
      return ScatteredRay.transmitSpecular(new Ray3(x.getPosition(), v),
          lambda.getColorModel().getWhite(lambda), 1.0);
    }

  }
View Full Code Here

//    }
//
//    return null;

    col = col.times(-thickness / Math.cos(Math.abs(x.getNormal().dot(v)))).exp();
    return ScatteredRay.transmitSpecular(new Ray3(x.getPosition(), v), col, 1.0);

  }
View Full Code Here

            int index = splitMap.get(edgeRev);
            ia = index;
            indices.add(index);
          } else {
            assert(!splitMap.containsKey(edge));
            Ray3 ray = new Ray3(v1.position, v3.position);
            Point3 p = ray.pointAt(plane.intersect(ray));
            int index = addVertex(p);
            ia = index;
            vertices.get(index).tempInt = -1;
            vertices.get(index).flag = true;
            indices.add(index);
            splitMap.put(edge, index);
          }
        }
        if (v2.flag) {
          Edge edge = new Edge(i1, i2);
          Edge edgeRev = edge.reverse();
          if (splitMap.containsKey(edgeRev)) {
            int index = splitMap.get(edgeRev);
            assert(ia >= 0);
            vertices.get(index).tempInt = ia;
            ia = -1;
            indices.add(index);
          } else {
            assert(!splitMap.containsKey(edge));
            Ray3 ray = new Ray3(v1.position, v2.position);
            Point3 p = ray.pointAt(plane.intersect(ray));
            int index = addVertex(p);
            assert(ia >= 0);
            if (ia < 0) {
              ia = -1;
            }
View Full Code Here

TOP

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

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.