Package ca.eandb.jmist.math

Examples of ca.eandb.jmist.math.Point2


      }
      return area;
    }

    public double getSurfacePointFromUV(ShadingContext context, Point2 uv, int tri) {
      Point2 a = texCoords.get(texIndices[decomp[3 * tri]]);
      Point2 b = texCoords.get(texIndices[decomp[3 * tri + 1]]);
      Point2 c = texCoords.get(texIndices[decomp[3 * tri + 2]]);

      if (!GeometryUtil.pointInTriangle(uv, a, b, c)) {
        return -1.0;
      }

View Full Code Here


      return RandomUtil.uniformOnTriangle(a, b, c, ru, vref.seed);
    }

    // See http://www.terathon.com/code/tangent.html
    private Basis3 getBasis(int tri) {
      Point2 ta = texCoords.get(texIndices[decomp[tri]]);
      Point2 tb = texCoords.get(texIndices[decomp[tri + 1]]);
      Point2 tc = texCoords.get(texIndices[decomp[tri + 2]]);

      Point3 a = vertices.get(indices[decomp[tri]]);
      Point3 b = vertices.get(indices[decomp[tri + 1]]);
      Point3 c = vertices.get(indices[decomp[tri + 2]]);
View Full Code Here

        double B = n.dot(pc.cross(pa)) / area;
        if (B < 0.0) continue;
        double C = 1.0 - A - B;
        if (C < 0.0) continue;

        Point2 ta = null, tb = null, tc = null;
        if (texIndices != null) {
          ta = texCoords.get(texIndices[decomp[i]]);
          tb = texCoords.get(texIndices[decomp[i + 1]]);
          tc = texCoords.get(texIndices[decomp[i + 2]]);
        } else {
          ta = Point2.ORIGIN;
          if (i == 0) {
            tb = new Point2(1, 0);
            tc = new Point2(1, 1);
          } else {
            tb = new Point2(1, 1);
            tc = new Point2(0, 1);
          }
        }

        return new Point2(ta.x() * A + tb.x() * B + tc.x() * C, ta.y() * A + tb.y() * B + tc.y() * C);
      }

      return Point2.ORIGIN;
    }
View Full Code Here

    return strategy.traceLightPath(light, pathInfo, rnd);
  }

  private final PathNode generateEyePath(Random rnd, WavelengthPacket lambda) {
    Lens lens = scene.getLens();
    Point2 p = RandomUtil.canonical2(rnd);
    PathInfo pathInfo = new PathInfo(scene, lambda);
    return strategy.traceEyePath(lens, p, pathInfo, rnd);
  }
View Full Code Here

    Vector3  cp  = x.getPosition().vectorFromOrigin();
    Vector3  R  = Vector3.unit(cp.x(), 0.0, cp.z());
    Vector3  r  = cp.minus(R.times(major)).unit();

    return new Point2(
      (Math.PI + Math.atan2(-cp.z(), cp.x())) / (2.0 * Math.PI),
      (Math.PI + Math.atan2(cp.y(), R.dot(r))) / (2.0 * Math.PI)
    );

  }
View Full Code Here

      return raster.get();
    }

    private void record(Path x, Raster image, Color c) {
      Point2 p = x.getPointOnImagePlane();
      if (p != null) {
        RasterUtil.addPixel(image, p, c);
      }
    }
View Full Code Here

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.Texture2#evaluate(ca.eandb.jmist.math.Point2, ca.eandb.jmist.framework.color.WavelengthPacket)
   */
  @Override
  public Color evaluate(Point2 p, WavelengthPacket lambda) {
    p = new Point2(p.x() - Math.floor(p.x()), p.y() - Math.floor(p.y()));
    return inner.evaluate(p, lambda);
  }
View Full Code Here

  public static double canonical(Random random) {
    return random.next();
  }

  public static Point2 canonical2(Random random) {
    return new Point2(random.next(), random.next());
  }
View Full Code Here

  public static Point2 uniform(Box2 box, Random random) {
    return uniform(box, random.next(), random.next());
  }

  public static Point2 uniform(Box2 box, double ru, double rv) {
    return new Point2(
        uniform(box.minimumX(), box.maximumX(), ru),
        uniform(box.minimumY(), box.maximumY(), rv));
  }
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) {
      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);
 
View Full Code Here

TOP

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

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.