Package ca.eandb.jmist.math

Examples of ca.eandb.jmist.math.Point3


            ia = index;
            indices.add(index);
          } else {
            assert(!splitMap.containsKey(edge));
            Ray3 ray = new Ray3(v1.position, v3.position);
            Point3 p = ray.pointAt(plane.intersect(ray));
            int index = addVertex(p);
            ia = index;
            vertices.get(index).tempInt = -1;
            vertices.get(index).flag = true;
            indices.add(index);
            splitMap.put(edge, index);
          }
        }
        if (v2.flag) {
          Edge edge = new Edge(i1, i2);
          Edge edgeRev = edge.reverse();
          if (splitMap.containsKey(edgeRev)) {
            int index = splitMap.get(edgeRev);
            assert(ia >= 0);
            vertices.get(index).tempInt = ia;
            ia = -1;
            indices.add(index);
          } else {
            assert(!splitMap.containsKey(edge));
            Ray3 ray = new Ray3(v1.position, v2.position);
            Point3 p = ray.pointAt(plane.intersect(ray));
            int index = addVertex(p);
            assert(ia >= 0);
            if (ia < 0) {
              ia = -1;
            }
View Full Code Here


//        System.err.printf("Non-standard angle: %f degrees", angle);
//        System.err.println();
//        return;
//      }

      Point3 insertionPoint = new Point3(p[0], p[1], p[2]);
      Vector3 extrusionDir = new Vector3(ext[0], ext[1], ext[2]);

//      if (extrusionDir.minus(Vector3.K).squaredLength() > MathUtil.EPSILON) { System.err.printf("%f %f %f", extrusionDir.x(), extrusionDir.y(), extrusionDir.z()); System.err.println(); return; }
//      if (!MathUtil.areEqual(scale)) {
//        System.err.println("Non-uniform scaling");
//      }

      if (block.root == null) {
        int np = block.geometry.getNumPrimitives();
        if (np >= ACCEL_THRESHOLD) {
          block.root = new BoundingIntervalHierarchy(block.geometry);
        } else {
          block.root = block.geometry;
        }
      }

      TransformableSceneElement e = new TransformableSceneElement(block.root);
      e.translate(block.base.vectorFromOrigin());
      e.stretch(scale[0], scale[1], scale[2]);
      e.rotateZ(Math.toRadians(angle));

      e.translate(insertionPoint.vectorFromOrigin());
      Basis3 basis = DxfUtil.getBasisFromArbitraryAxis(extrusionDir);
      AffineMatrix3 T = AffineMatrix3.fromColumns(basis.u(), basis.v(), basis.w());
      e.transform(T);

View Full Code Here

        int primitive = primIndex[index];

        generateImportanceSampledSurfacePoint(primitive, x, context, rng.next(), rng.next(), rng.next());
        context.getModifier().modify(context);

        Point3 p = context.getPosition();
        Material mat = context.getMaterial();
        Vector3 v = x.getPosition().unitVectorFrom(p);
        Vector3 n = context.getShadingNormal();
        double d2 = x.getPosition().squaredDistanceTo(p);
        double atten = Math.max(n.dot(v), 0.0) * totalWeight / (4.0 * Math.PI * d2);
 
View Full Code Here

    Face      face = this.faces.get(faceIndex);
    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);
View Full Code Here

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.geometry.AbstractGeometry#generateRandomSurfacePoint(int, ca.eandb.jmist.framework.ShadingContext)
   */
  @Override
  public void generateRandomSurfacePoint(int index, ShadingContext context, double ru, double rv, double rj) {
    Point3 p = faces.get(index).generateRandomSurfacePoint(ru, rv, rj);
    Intersection x = super.newSurfacePoint(p, index).setPrimitiveIndex(index);
    x.prepareShadingContext(context);
  }
View Full Code Here

        n = na.times(A).plus(nb.times(B)).plus(nc.times(C));
      } else {
        n = plane.normal();
      }

      Point3 pa = vertices.get(indices[decomp[3 * tri]]);
      Point3 pb = vertices.get(indices[decomp[3 * tri + 1]]);
      Point3 pc = vertices.get(indices[decomp[3 * tri + 2]]);

      double geomArea = GeometryUtil.areaOfTriangle(pa, pb, pc);

      Point3 p = new Point3(
          pa.x() * A + pb.x() * B + pc.x() * C,
          pa.y() * A + pb.y() * B + pc.y() * C,
          pa.z() * A + pb.z() * B + pc.z() * C);

      context.setPosition(p);
View Full Code Here

    public Point3 generateRandomSurfacePoint(double ru, double rv, double rj) {
      decompose();
      SeedReference vref = new SeedReference(rv);
      int tri = 3 * rnd.next(vref);
      Point3 a = vertices.get(indices[decomp[tri]]);
      Point3 b = vertices.get(indices[decomp[tri + 1]]);
      Point3 c = vertices.get(indices[decomp[tri + 2]]);
      return RandomUtil.uniformOnTriangle(a, b, c, ru, vref.seed);
    }
View Full Code Here

    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]]);

      Vector3 ab = a.vectorTo(b);
      Vector3 ac = a.vectorTo(c);

      Vector2 tab = ta.vectorTo(tb);
View Full Code Here

      Vector3 n = plane.normal();
      p = plane.project(p);

      for (int i = 0; i < decomp.length; i += 3) {
        Point3 a = vertices.get(indices[decomp[i]]);
        Point3 b = vertices.get(indices[decomp[i + 1]]);
        Point3 c = vertices.get(indices[decomp[i + 2]]);
        Vector3 ab = a.vectorTo(b);
        Vector3 ac = a.vectorTo(c);
        Vector3 pa = p.vectorTo(a);
        Vector3 pb = p.vectorTo(b);
        Vector3 pc = p.vectorTo(c);
View Full Code Here

      Vector3 n = plane.normal();
      p = plane.project(p);


      for (int i = 0; i < decomp.length; i += 3) {
        Point3 a = vertices.get(indices[decomp[i]]);
        Point3 b = vertices.get(indices[decomp[i + 1]]);
        Point3 c = vertices.get(indices[decomp[i + 2]]);
        Vector3 ab = a.vectorTo(b);
        Vector3 ac = a.vectorTo(c);
        Vector3 pa = p.vectorTo(a);
        Vector3 pb = p.vectorTo(b);
        Vector3 pc = p.vectorTo(c);
View Full Code Here

TOP

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

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.