Package ca.eandb.jmist.math

Examples of ca.eandb.jmist.math.Vector3


    double      t = face.plane.intersect(ray);

    if (recorder.interval().contains(t)) {

      Point3    p = ray.pointAt(t);
      Vector3    n = face.plane.normal();
      Vector3    u, v;

      for (int i = 0; i < face.indices.length; i++)
      {
        Point3  a = this.vertices.get(face.indices[i]);
        Point3  b = this.vertices.get(face.indices[(i + 1) % face.indices.length]);
        Vector3  ab = a.vectorTo(b);

        u = n.cross(ab);
        v = p.vectorFrom(a);

        if (u.dot(v) < 0.0) {
View Full Code Here


      WavelengthPacket lambda) {
    if ((in.dot(x.getNormal()) < 0.0) == (out.dot(x.getNormal()) > 0.0)) {
      Color kd = kdPainter.getColor(x, lambda);
      Color d = kd.divide(Math.PI);

      Vector3 r = Optics.reflect(in, x.getNormal());
      double rdoto = r.dot(out);
      if (rdoto > 0.0) {
        Color ks = ksPainter.getColor(x, lambda);
        Color s = ks.times(((n + 2.0) / (2.0 * Math.PI)) * Math.pow(rdoto, n));
        return d.plus(s);
      } else {
View Full Code Here

    double rhod = kdY;

    double ksY = ColorUtil.getMeanChannelValue(ks);
    double rhos = Math.min(1.0, ksY * Math.abs(vdotn) * (n + 2.0) / (n + 1.0));

    Vector3 r = Optics.reflect(in, x.getNormal());
    double rdoto = r.dot(out);

    double pdfd = rhod / Math.PI;
    double pdfs = rdoto > 0.0 ? rhos * (Math.pow(rdoto, n) / Math.abs(odotn)) * (n + 1.0) / (2.0 * Math.PI) : 0.0;

    return pdfd + pdfs;
View Full Code Here

    double ksY = ColorUtil.getMeanChannelValue(ks);
    double rhos = Math.min(1.0, ksY * Math.abs(vdotn) * (n + 2.0) / (n + 1.0));

    if (rj < rhod) {
      Vector3 out = RandomUtil.diffuse(ru, rv).toCartesian(x.getBasis());
      Ray3 ray = new Ray3(x.getPosition(), out);
      return ScatteredRay.diffuse(ray, kd.divide(rhod), getScatteringPDF(x, v, out, adjoint, lambda));
    } else if (rj < rhod + rhos) {
      Vector3 r = Optics.reflect(v, x.getNormal());
      Vector3 out = new SphericalCoordinates(Math.acos(Math.pow(ru, 1.0 / (n + 1.0))), 2.0 * Math.PI * rv).toCartesian(Basis3.fromW(r));
      double ndoto = x.getNormal().dot(out);
      Color weight = ks.times(((n + 2.0) / (n + 1.0)) * Math.abs(ndoto) / rhos);
      //double rdoto = r.dot(out);
      double pdf = getScatteringPDF(x, v, out, adjoint, lambda);//rhod / Math.PI + rhos * (Math.pow(rdoto, n) / ndoto) * (n + 1.0) / (2.0 * Math.PI);
      Ray3 ray = new Ray3(x.getPosition(), out);
View Full Code Here

      WavelengthPacket lambda) {
    return lambda.getColorModel().getGray(bsdf(x, in, out), lambda);
  }

  public double bsdf(SurfacePoint x, Vector3 in, Vector3 out) {
    Vector3 n = x.getNormal();
    double ndoti = -n.dot(in);
    double ndoto = n.dot(out);

    return (ndoti > 0.0) == (ndoto > 0.0)
        ? brdf(x, in, out, n)
        : btdf(x, in, out, n);
  }
View Full Code Here

  private double brdf(SurfacePoint x, Vector3 in, Vector3 out, Vector3 n) {
    double ndoti = -n.dot(in);
    double ndoto = n.dot(out);

    /* Eq. (13) */
    Vector3 hr = out.minus(in).times(Math.signum(ndoti)).unit();
    hr = hr.dot(n) > 0.0 ? hr : hr.opposite();

    double g = microfacets.getShadowingAndMasking(in, out, hr, n);
    double d = microfacets.getDistributionPDF(hr, n);
    double f = Optics.reflectance(in, n1, n2, hr);

View Full Code Here

      ni = n2;
      no = n1;
    }

    /* Eq. (16) */
    Vector3 ht = in.times(ni).minus(out.times(no)).unit();
    ht = ht.dot(n) > 0.0 ? ht : ht.opposite();

    double hdoti = -ht.dot(in);
    double hdoto = ht.dot(out);
    double ndoto = n.dot(out);

    double k = Math.abs(hdoti * hdoto / (ndoti * ndoto));
    double c = ni * hdoti + no * hdoto;

 
View Full Code Here

     * @return The <code>Vector3</code> perpendicular to this
     *     <code>Face</code>.
     */
    public Vector3 computeFaceNormal() {

      Vector3  u = vertices.get(indices[0]).vectorTo(vertices.get(indices[1]));
      Vector3  v = vertices.get(indices[0]).vectorTo(vertices.get(indices[indices.length - 1]));

      return u.cross(v).unit();

    }
View Full Code Here

   * @see ca.eandb.jmist.framework.material.AbstractMaterial#getScatteringPDF(ca.eandb.jmist.framework.SurfacePoint, ca.eandb.jmist.math.Vector3, ca.eandb.jmist.math.Vector3, boolean, ca.eandb.jmist.framework.color.WavelengthPacket)
   */
  @Override
  public double getScatteringPDF(SurfacePoint x, Vector3 in, Vector3 out,
      boolean adjoint, WavelengthPacket lambda) {
    Vector3 n = x.getNormal();
    double ndoti = -n.dot(in);
    double ndoto = n.dot(out);
    boolean reflected = (ndoti / ndoto) > 0.0;

    if (reflected) {
      Vector3 hr = out.minus(in).times(Math.signum(ndoti)).unit();
      hr = hr.dot(n) > 0.0 ? hr : hr.opposite();

      double partial = 1.0 / (4.0 * Math.abs(hr.dot(out)));
      double d = microfacets.getDistributionPDF(hr, n);
      double pm = d * Math.abs(hr.dot(n));
      double po = pm * partial;
      return po;// / Math.abs(n.dot(out));
    } else {
      double ni, no;

      if (ndoti > 0.0) {
        ni = n1;
        no = n2;
      } else {
        ni = n2;
        no = n1;
      }

      //Vector3 ht = out.times(no).minus(in.times(ni)).unit();
      Vector3 ht = in.times(ni).minus(out.times(no)).unit();
      ht = ht.dot(n) > 0.0 ? ht : ht.opposite();

      double hdoti = -ht.dot(in);
      double hdoto = ht.dot(out);

      double k = Math.abs(hdoti * hdoto / (ndoti * ndoto));
      double c = ni * hdoti + no * hdoto;

      double partial = no * no * Math.abs(hdoto) / (c * c);
      double d = microfacets.getDistributionPDF(ht, n);
      double pm = d * Math.abs(ht.dot(n));
      double po = pm * partial;
      return po;// / Math.abs(n.dot(out));
    }
  }
View Full Code Here

    }

    public double getSurfaceArea() {
      if (area < 0.0) {
        synchronized (this) {
          Vector3 n = computeFaceNormal();
          Vector3 v0 = vertices.get(indices[indices.length - 1]).vectorFromOrigin();
          Vector3 v1;
          Vector3 r = Vector3.ZERO;
          for (int i = 0; i < indices.length; i++) {
            v1 = vertices.get(indices[i]).vectorFromOrigin();
            r = r.plus(v0.cross(v1));
            v0 = v1;
          }
          area = 0.5 * Math.abs(n.dot(r));
        }
      }
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.