Package ca.eandb.jmist.math

Examples of ca.eandb.jmist.math.Point2


    /* (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    nx = (p.x() - 0.5) * hfov;
        double    ny = (0.5 - p.y()) * vfov;

        double    sx = Math.sin(nx);
        double    sy = Math.sin(ny);
        double    cx = Math.cos(nx);
        double    cy = Math.cos(ny);
View Full Code Here


      }
      double theta = Math.asin(v.y());
      if (Math.abs(theta) > 0.5 * vfov) {
        return null;
      }
      return new Point2(
          0.5 + phi / hfov,
          0.5 - theta / vfov);
    }
View Full Code Here

      double X = ColorUtil.X_BAR.at(i);
      double Y = ColorUtil.Y_BAR.at(i);
      double Z = ColorUtil.Z_BAR.at(i);
      double x = X / (X + Y + Z);
      double y = Y / (X + Y + Z);
      vertices.add(new Point2(x, y));
    }

    gamutMask = new PolygonMask2(vertices, 100);
  }
View Full Code Here

    for (int fi = 0, nf = faces.size(); fi < nf; fi++) {
      Face f = faces.get(fi);
      if (f.texIndices != null) {
        for (int tri = 0; tri < f.decomp.length; tri += 3) {
          Point2 a = T.times(texCoords.get(f.texIndices[f.decomp[tri]]));
          Point2 b = T.times(texCoords.get(f.texIndices[f.decomp[tri + 1]]));
          Point2 c = T.times(texCoords.get(f.texIndices[f.decomp[tri + 2]]));

          builder.reset();
          builder.add(a);
          builder.add(b);
          builder.add(c);

          Box2 bound = builder.getBoundingBox();

          int i0 = MathUtil.clamp((int) Math.floor(bound.minimumX() * (double) triangleLookupGridSize), 0, triangleLookupGridSize - 1);
          int i1 = MathUtil.clamp((int) Math.floor(bound.maximumX() * (double) triangleLookupGridSize), 0, triangleLookupGridSize - 1);
          int j0 = MathUtil.clamp((int) Math.floor(bound.minimumY() * (double) triangleLookupGridSize), 0, triangleLookupGridSize - 1);
          int j1 = MathUtil.clamp((int) Math.floor(bound.maximumY() * (double) triangleLookupGridSize), 0, triangleLookupGridSize - 1);

          for (int i = i0; i <= i1; i++) {
            double x0 = (double) i / (double) triangleLookupGridSize;
            double x1 = (double) (i + 1) / (double) triangleLookupGridSize;

            for (int j = j0; j <= j1; j++) {
              double y0 = (double) j / (double) triangleLookupGridSize;
              double y1 = (double) (j + 1) / (double) triangleLookupGridSize;

              Box2 cell = new Box2(x0, y0, x1, y1);

              if (GeometryUtil.boxIntersectsTriangle(cell, a, b, c)) {
                int cellIndex = j * triangleLookupGridSize + i;
                int triIndex = fi * maximumTrianglesPerFace + tri / 3;
                IntegerArray list = triangleLookup.get(cellIndex);
                if (list == null) {
                  list = new IntegerArray();
                  triangleLookup.put(cellIndex, list);
                }
                list.add(triIndex);
              }
            }
          }
        }
      }
    }

    int count = 0;
    for (IntegerArray list : triangleLookup.values()) {
      int n = list.size();
      for (int i = 1; i < n; i++) {
        int tri1 = list.get(i);
        int fi1 = tri1 / maximumTrianglesPerFace;
        int ti1 = (tri1 % maximumTrianglesPerFace) * 3;
        Face f1 = faces.get(fi1);
        Point2 a1 = texCoords.get(f1.texIndices[f1.decomp[ti1]]);
        Point2 b1 = texCoords.get(f1.texIndices[f1.decomp[ti1 + 1]]);
        Point2 c1 = texCoords.get(f1.texIndices[f1.decomp[ti1 + 2]]);

        for (int j = 0; j < i; j++) {
          int tri2 = list.get(j);
          int fi2 = tri2 / maximumTrianglesPerFace;
          int ti2 = (tri2 % maximumTrianglesPerFace) * 3;
          Face f2 = faces.get(fi2);
          Point2 a2 = texCoords.get(f2.texIndices[f2.decomp[ti2]]);
          Point2 b2 = texCoords.get(f2.texIndices[f2.decomp[ti2 + 1]]);
          Point2 c2 = texCoords.get(f2.texIndices[f2.decomp[ti2 + 2]]);

          if (GeometryUtil.triangleIntersectsTriangle(a1, b1, c1, a2, b2, c2)) {
            System.err.println("WARNING: Triangles intersect -------------------------------");
            System.err.printf("% 5d: (%5.3f, %5.3f) - (%5.3f, %5.3f) - (%5.3f, %5.3f)", tri1,
                a1.x(), a1.y(),
                b1.x(), b1.y(),
                c1.x(), c1.y());
            System.err.println();
            System.err.printf("% 5d: (%5.3f, %5.3f) - (%5.3f, %5.3f) - (%5.3f, %5.3f)", tri2,
                a2.x(), a2.y(),
                b2.x(), b2.y(),
                c2.x(), c2.y());
            System.err.println();
            count++;
          }
        }
      }
View Full Code Here

  @Override
  public double generateImportanceSampledSurfacePoint(SurfacePoint x,
      ShadingContext context, double ru, double rv, double rj) {

    return getSurfacePointFromUV(context, new Point2(ru, rv));
  }
View Full Code Here

//      double x1      = (double) (x + 1) / width;
//
//      Box2 bounds      = new Box2(x0, y0, x1, y1);

      //Point2 p      = RandomUtil.uniform(bounds, seq);
      Point2 p      = RandomUtil.canonical2(seq);
      seq.mark();

      Color sample    = colorModel.sample(seq);
      seq.mark();
View Full Code Here

      RepeatableRandom seq = seqX.get().cloneSequence();
      seqY.set(seq);
      seq.reset();

      seq.mutate(width);
      Point2 p      = RandomUtil.canonical2(seq);
      seq.mark();

      Color sample    = colorModel.sample(seq);
      seq.mark();
View Full Code Here

      RepeatableRandom seq = seqX.get().cloneSequence();
      seqY.set(seq);
      seq.reset();

      seq.mutate(width);
      Point2 p      = RandomUtil.canonical2(seq);
      seq.mark();

      seq.mutate(width);
      Color sample    = colorModel.sample(seq);
      seq.mark();
View Full Code Here

        Path y = (x != null) ? mutate(x) : generateNewPath();

        Color score      = join(y.getLightTail(), y.getEyeTail(),
                      lightImageWeight, cy);
        if (score != null) {
          Point2 p = y.getPointOnImagePlane();
          cy.add(new Contribution(p, score));
        }

        fy = evaluate(cy);
View Full Code Here

    private Color joinInnerToEye(PathNode lightNode, EyeNode eyeNode,
        double weight, List<Contribution> contrib) {
      double w = strategy.getWeight(lightNode, eyeNode);
      if (w > 0.0) {//MathUtil.EPSILON) {
        Point2 p = eyeNode.project(lightNode.getPosition());
        if (p != null) {
          Color c = measure.evaluate(lightNode, eyeNode);
          c = ColorUtil.mul(c, weight * w);
          if (c != null) {
            contrib.add(new Contribution(p, c));
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.