Package ca.eandb.jmist.math

Examples of ca.eandb.jmist.math.Vector3


        if (sr != null) {
          if (sr.getType() == Type.SPECULAR) {
            return ScatteredRay.select(sr, w);
          } else {
            Ray3 ray = sr.getRay();
            Vector3 v = ray.direction();
            double pdf = w * sr.getPDF() + (1.0 - w) * inner.getEmissionPDF(x, v, lambda);
            Color edf = inner.emission(x, sr.getRay().direction(), lambda);
            return new ScatteredRay(ray, edf.divide(pdf), sr.getType(), pdf, sr.isTransmitted());
          }
        }
      } else {
        ScatteredRay sr = inner.emit(x, lambda, ru, rv, ref.seed);
        if (sr != null) {
          if (sr.getType() == Type.SPECULAR) {
            return ScatteredRay.select(sr, 1.0 - w);
          } else {
            Ray3 ray = sr.getRay();
            Vector3 v = ray.direction();
            double pdf = w * strategy.getEmissionPDF(x, v, lambda) + (1.0 - w) * sr.getPDF();
            Color edf = inner.emission(x, sr.getRay().direction(), lambda);
            return new ScatteredRay(ray, edf.divide(pdf), sr.getType(), pdf, sr.isTransmitted());
          }
        }
View Full Code Here


      if (sr != null) {
        if (sr.getType() == Type.SPECULAR) {
          return ScatteredRay.select(sr, w);
        } else {
          Ray3 ray = sr.getRay();
          Vector3 r = ray.direction();
          Vector3 in = adjoint ? r.opposite() : v;
          Vector3 out = adjoint ? v.opposite() : r;
          double pdf = w * sr.getPDF() + (1.0 - w) * inner.getScatteringPDF(x, v, r, adjoint, lambda);
          Color bsdf = inner.bsdf(x, in, out, lambda);
          return new ScatteredRay(ray, bsdf.divide(pdf), sr.getType(), pdf, sr.isTransmitted());
        }
      }
    } else {
      ScatteredRay sr = inner.scatter(x, v, adjoint, lambda, ru, rv, ref.seed);
      if (sr != null) {
        if (sr.getType() == Type.SPECULAR) {
          return ScatteredRay.select(sr, 1.0 - w);
        } else {
          Ray3 ray = sr.getRay();
          Vector3 r = ray.direction();
          Vector3 in = adjoint ? r.opposite() : v;
          Vector3 out = adjoint ? v.opposite() : r;
          double pdf = w * strategy.getScatteringPDF(x, v, r, adjoint, lambda) + (1.0 - w) * sr.getPDF();
          Color bsdf = inner.bsdf(x, in, out, lambda);
          return new ScatteredRay(ray, bsdf.divide(pdf), sr.getType(), pdf, sr.isTransmitted());
        }
      }
View Full Code Here

   * @see ca.eandb.jmist.framework.material.AbstractMaterial#scatter(ca.eandb.jmist.framework.SurfacePoint, ca.eandb.jmist.math.Vector3, boolean, ca.eandb.jmist.framework.color.WavelengthPacket, double, double, double)
   */
  @Override
  public ScatteredRay scatter(SurfacePoint x, Vector3 v, boolean adjoint, WavelengthPacket lambda, double ru, double rv, double rj) {

    Vector3 out = Optics.reflect(v, x.getShadingNormal());

    return ScatteredRay.specular(new Ray3(x.getPosition(), out),
        reflectance.getColor(x, lambda), 1.0);

  }
View Full Code Here

     * @see ca.eandb.jmist.framework.path.EyeNode#sample(ca.eandb.jmist.math.Point2, ca.eandb.jmist.framework.Random)
     */
    public ScatteredRay sample(double ru, double rv, double rj) {
      Point2 p = pointOnImagePlane;
      double theta = (p.x() - 0.5) * hfov;
      Vector3 v = new Vector3(
          Math.sin(theta),
          (0.5 - p.y()) * height,
          -Math.cos(theta));
      double r = v.length();
      Ray3 ray = new Ray3(Point3.ORIGIN, v.divide(r));
      Color color = getWhite();
      double pdf = (r * r * r * r) / (hfov * 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();
      double theta = Math.atan2(v.x(), -v.z());
      if (Math.abs(theta) > 0.5 * hfov) {
        return null;
      }
      double h = v.y() / Math.hypot(v.x(), v.z());
      if (Math.abs(h) > 0.5 * height) {
        return null;
      }
      return new Point2(
          0.5 + theta / hfov,
View Full Code Here

    /* (non-Javadoc)
     * @see ca.eandb.jmist.framework.path.EyeNode#project(ca.eandb.jmist.math.HPoint3)
     */
    @Override
    public Point2 project(HPoint3 x) {
      Vector3 v = x.isPoint() ? x.toPoint3().vectorFromOrigin()
                              : x.toVector3();
      double d = v.length();

      if (-v.z() / d < MathUtil.EPSILON) {
        return null;
      }
      return new Point2(
          (v.x() / d + 1.0) / 2.0,
          (1.0 - v.y() / d) / 2.0);
    }
View Full Code Here

      if (d2 > 1.0)
        return null;

      Ray3 ray = new Ray3(
          Point3.ORIGIN,
          new Vector3(nx, ny,  -Math.sqrt(1.0 - d2)));
      Color color = getWhite();
      double pdf = 0.25;

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

  public static CIEXYZ convertxyY2XYZ(CIExyY xyY) {
    return convertxyY2XYZ(xyY.x(), xyY.y(), xyY.Y());
  }

  public static CIEXYZ convertRGB2XYZ(double r, double g, double b) {
    Vector3 rgb = new Vector3(linearize(r), linearize(g), linearize(b));
    Vector3 xyz = sRGBLin_TO_XYZ.times(rgb);
    return new CIEXYZ(xyz.x(), xyz.y(), xyz.z());
  }
View Full Code Here

    /* (non-Javadoc)
     * @see ca.eandb.jmist.framework.path.EyeNode#sample(ca.eandb.jmist.math.Point2, ca.eandb.jmist.framework.Random)
     */
    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

    /* (non-Javadoc)
     * @see ca.eandb.jmist.framework.path.PathNode#getCosine(ca.eandb.jmist.math.Vector3)
     */
    public double getCosine(Vector3 v) {
      Vector3 n = context.getNormal();
      return n.dot(v);
    }
View Full Code Here

TOP

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

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.