Package ca.eandb.jmist.math

Examples of ca.eandb.jmist.math.Vector3


   */
  @Override
  public double getScatteringPDF(SurfacePoint x, Vector3 in, Vector3 out,
      boolean adjoint, WavelengthPacket lambda) {

    Vector3 N = x.getNormal();
    if (-N.dot(in) <= 0.0 || N.dot(out) <= 0.0) {
      return 0.0;
    }

    in = in.unit();
    out = out.unit();

    double d = ColorUtil.getMeanChannelValue(diffuse.getColor(x, lambda));
    double s = ColorUtil.getMeanChannelValue(specular.getColor(x, lambda));
    double total = d + s;

    Vector3 n = x.getShadingNormal();

    double D = d / Math.PI;

    double ci = -n.dot(in);
    double co = n.dot(out);
    Vector3 h = out.minus(in).unit();

    double ch = n.dot(h);
    double ch2 = ch * ch;
    double sh2 = 1.0 - ch2;
    double th2 = sh2 / ch2;
View Full Code Here


   */
  @Override
  public ScatteredRay scatter(SurfacePoint x, Vector3 v, boolean adjoint,
      WavelengthPacket lambda, double ru, double rv, double rj) {

    Vector3 n = x.getNormal();
    if (n.dot(v) > 0.0) {
      return null;
    }

    Color d = diffuse.getColor(x, lambda);
    Color s = specular.getColor(x, lambda);
    double davg = ColorUtil.getMeanChannelValue(d);
    double savg = ColorUtil.getMeanChannelValue(s);
    double total = davg + savg;

    Basis3 basis = x.getShadingBasis();
    Vector3 out;

    if (RandomUtil.bernoulli(davg / total, rj)) { // diffuse

      do {
        out = RandomUtil.diffuse(ru, rv).toCartesian(basis);
      } while (n.dot(out) <= 0.0);

    } else { // specular

      do {
        SphericalCoordinates sc = new SphericalCoordinates(
            Math.atan(alpha * Math.sqrt(-Math.log(1.0 - ru))),
            2.0 * Math.PI * rv);

        Vector3 h = sc.toCartesian(basis);
        out = Optics.reflect(v, h);
      } while (n.dot(out) <= 0.0);

    }

View Full Code Here

    public ScatteredRay sample(double ru, double rv, double rj) {
      if (weight < 0.0) {
        return null;
      }
      Point3 o = context.getPosition();
      Vector3 ns = context.getShadingNormal();
      Vector3 ng = context.getNormal();
      Vector3 v = RandomUtil.diffuse(ru, rv).toCartesian(Basis3.fromW(ns));
      while (ng.dot(v) < 0.0) {
        v = RandomUtil.diffuse(Random.DEFAULT).toCartesian(Basis3.fromW(ns));
      }
      Ray3 ray = new Ray3(o, v);
      Color color = getWhite();
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

     */
    public double getPDF(Vector3 v) {
      if (weight < 0.0) {
        return 0.0;
      }
      Vector3 n = context.getNormal();
      return (n.dot(v) > 0.0) ? 1.0 / Math.PI : 0.0;
    }
View Full Code Here

    /* (non-Javadoc)
     * @see ca.eandb.jmist.framework.path.EyeNode#project(ca.eandb.jmist.math.HPoint3)
     */
    @Override
    public Point2 project(HPoint3 q) {
      Vector3 v = q.isPoint() ? q.toPoint3().unitVectorFromOrigin()
                          : q.toVector3().unit();
      SphericalCoordinates sc = SphericalCoordinates.fromCartesian(v,
          BASIS);
      double x = sc.azimuthal() / (2.0 * Math.PI);
      double y = 0.5 * (1.0 - Math.cos(sc.polar()));
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()) {
View Full Code Here

    /* (non-Javadoc)
     * @see ca.eandb.jmist.framework.path.EyeNode#project(ca.eandb.jmist.math.HPoint3)
     */
    @Override
    public Point2 project(HPoint3 q) {
      Vector3 v = q.isPoint() ? q.toPoint3().unitVectorFromOrigin()
                          : q.toVector3().unit();
      Vector3 half = new Vector3(0.5 * v.x(), 0.5 * v.y(),
          0.5 * (v.z() - 1.0)).unit();
      double x = 0.5 * (half.x() + 1.0);
      double y = 0.5 * (1.0 - half.y());
      return new Point2(x, y);
    }
View Full Code Here

      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

    if (Double.isNaN(reversePDF)) {
      if (specular) {
        // FIXME should not assume symmetry in PDF
        reversePDF = (parent.getParent() != null) ? pdf : 1.0;
      } else {
        Vector3 v = PathUtil.getDirection(this, parent);
        reversePDF = parent.getReversePDF(v);
      }
    }
    return reversePDF;
  }
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.