Package ca.eandb.jmist.math

Examples of ca.eandb.jmist.math.Ray3


    public ScatteredRay sample(double ru, double rv, double rj) {
      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;

      return ScatteredRay.diffuse(ray, color, pdf);
    }
View Full Code Here


          (0.5 - pointOnImagePlane.y()) * objPlaneHeight,
          -focusDistance);

      Vector3 direction = origin.unitVectorTo(focus);

      this.ray = new Ray3(origin, direction);
    }
View Full Code Here

    /* (non-Javadoc)
     * @see ca.eandb.jmist.framework.path.EyeNode#project(ca.eandb.jmist.math.HPoint3)
     */
    @Override
    public Point2 project(HPoint3 p) {
      Ray3 pray = new Ray3(ray.origin(), p);
      Vector3 dir = pray.direction();
      if (-dir.z() < MathUtil.EPSILON) {
        return null;
      }

      double      ratio      = -focusDistance / dir.z();
View Full Code Here

      Point2 p = pointOnImagePlane;
      Vector3 v = new Vector3(
          width * (p.x() - 0.5),
          height * (0.5 - p.y()),
          -1.0);
      Ray3 ray = new Ray3(Point3.ORIGIN, v.unit());
      Color color = getWhite();
      double z = v.x() * v.x() + v.y() * v.y() + 1.0;
      double pdf = z * z / (width * height);
      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();
      if (-v.z() < MathUtil.EPSILON) {
        return null;
      }
      Point2 p = new Point2(
          0.5 - v.x() / (width * v.z()),
 
View Full Code Here

  public ScatteredRay emit(SurfacePoint x, WavelengthPacket lambda, double ru, double rv, double rj) {

    if (this.emittance != null) {

      SphericalCoordinates out = RandomUtil.diffuse(ru, rv);
      Ray3 ray = new Ray3(x.getPosition(), out.toCartesian(x.getShadingBasis()));

      if (x.getNormal().dot(ray.direction()) > 0.0) {
        return ScatteredRay.diffuse(ray, emittance.getColor(x, lambda), 1.0 / Math.PI);
      }

    }
View Full Code Here

      SphericalCoordinates out = RandomUtil.diffuse(ru, rv);
      if (!fromFront) {
        out = out.opposite();
      }

      Ray3 ray = new Ray3(x.getPosition(), out.toCartesian(x.getShadingBasis()));
      boolean toFront = ray.direction().dot(x.getNormal()) > 0.0;

      if (fromFront == toFront) {
        return ScatteredRay.diffuse(ray, reflectance.getColor(x, lambda), 1.0 / Math.PI);
      }
View Full Code Here

    if (RandomUtil.bernoulli(r, rj)) {
      Vector3    out    = Optics.reflect(v, normal);
      boolean    toSide  = x.getNormal().dot(out) >= 0.0;

      if (fromSide == toSide) {
        return ScatteredRay.specular(new Ray3(p, out), R.divide(r), r);
      }
    } else {

      if (alpha != null) {
//        if (disperse) {
//          for (int i = 0, channels = cm.getNumChannels(); i < channels; i++) {
//            Complex    eta1  = new Complex(n1.getValue(i), k1.getValue(i));
//            Complex    eta2  = new Complex(n2.getValue(i), k2.getValue(i));
//            Vector3    out    = Optics.refract(v, eta1, eta2, normal);
//            boolean    toSide  = x.getNormal().dot(out) >= 0.0;
//
//            if (fromSide != toSide) {
//              recorder.add(ScatteredRay.transmitSpecular(new Ray3(p, out), T.disperse(i), 1.0));
//            }
//          }
//        } else { // !disperse
          double    n1avg  = ColorUtil.getMeanChannelValue(n1);
          double    k1avg  = ColorUtil.getMeanChannelValue(k1);
          double    n2avg  = ColorUtil.getMeanChannelValue(n2);
          double    k2avg  = ColorUtil.getMeanChannelValue(k2);
          Complex    eta1  = new Complex(n1avg, k1avg);
          Complex    eta2  = new Complex(n2avg, k2avg);
          Vector3    out    = Optics.refract(v, eta1, eta2, normal);
          boolean    toSide  = x.getNormal().dot(out) >= 0.0;

          if (fromSide != toSide) {
            return ScatteredRay.transmitSpecular(new Ray3(p, out), T.divide(1 - r), 1 - r);
          }
//        }
      }

    }
View Full Code Here

   * @see ca.eandb.jmist.framework.ImageShader#shadeAt(ca.eandb.jmist.math.Point2, ca.eandb.jmist.framework.color.WavelengthPacket)
   */
  public Color shadeAt(Point2 p, WavelengthPacket lambda) {
    ScatteredRay sr = lens.rayAt(p, lambda, Random.DEFAULT);
    if (sr != null) {
      Ray3 ray = sr.getRay();
      Color scale = sr.getColor();
      Color shade = rayShader.shadeRay(ray, lambda);
      return shade.times(scale);
    } else {
      return ColorUtil.getBlack(lambda);
View Full Code Here

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.LightSample#castShadowRay(ca.eandb.jmist.framework.VisibilityFunction3)
   */
  public boolean castShadowRay(VisibilityFunction3 vf) {
    return shadows && vf.visibility(new Ray3(x.getPosition(), direction));
  }
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.