Package ca.eandb.jmist.math

Examples of ca.eandb.jmist.math.Point3


    case TAPERED_CYLINDER_SURFACE_BODY:
      double dr = radius2 - radius1;
      double dh = height2 - height1;
      double dh2 = dh * dh;
      double det = radius1 * height2 - radius2 * height1;
      Point3 p = x.getPosition();

      return Vector3.unit(
          p.x() * dh2,
          -dr * (dr * p.y() + det),
          p.z() * dh2);
//
//      double dh = height2 - height1;
//      double dr = radius2 - radius1;
//      double side = Math.hypot(dr, dh);
//      double c = dr / side;
View Full Code Here


  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.geometry.AbstractGeometry#getTextureCoordinates(ca.eandb.jmist.framework.geometry.AbstractGeometry.GeometryIntersection)
   */
  @Override
  protected Point2 getTextureCoordinates(GeometryIntersection x) {
    Point3 p = x.getPosition();
    switch (x.getTag()) {
    case TAPERED_CYLINDER_SURFACE_BODY:
      double angle = Math.PI + Math.atan2(p.z(), p.x());
      return new Point2(angle / ((capped ? 4.0 : 2.0) * Math.PI),
          (p.y() - height1) / (height2 - height1));

    case TAPERED_CYLINDER_SURFACE_END_1:
      return new Point2(0.5 + (p.x() + radius1) / (4.0 * radius1),
          (p.z() + radius1) / (4.0 * radius1));

    case TAPERED_CYLINDER_SURFACE_END_2:
      return new Point2(0.5 + (p.x() + radius2) / (4.0 * radius2),
          (p.z() + radius2) / (4.0 * radius2));

    default:
      throw new IllegalArgumentException("Invalid surface ID");
    }
  }
View Full Code Here

    public boolean hasAppearance(String name) {
      return appearanceNames.contains(name);
    }

    public void addVertex(Point3 p, double w) {
      this.vs.add(new Point3(p.x() * scale, p.y() * scale, p.z() * scale));
      this.weights.add(w);
    }
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) {
      Point3 o = context.getPosition();
      Vector3 n = context.getNormal();
      Vector3 v = RandomUtil.diffuse(ru, rv).toCartesian(Basis3.fromW(n));
      Ray3 ray = new Ray3(o, v);
      Color color = getWhite();
      return ScatteredRay.diffuse(ray, color, 1.0 / Math.PI);
View Full Code Here

    Strand strand = new Strand();
    strand.vertices = new Point3[2 * (segments + 1)];
    strand.emitterContext = context;
    strand.strandIndex = index;

    Point3 pos = context.getPosition();
    Vector3 vel = context.getBasis().toStandard(meanInitialVelocity).plus(
        RandomUtil.uniformInsideSphere(randomInitialVelocity, adapter)
            .toCartesian());
    double dt = 1.0 / (double) segments;
    double orientation = 2.0 * Math.PI * rnd.nextDouble();
    double co = Math.cos(orientation);
    double so = Math.sin(orientation);
    Basis3 basis = Basis3.fromWU(vel, context.getTangent());

    int segment = 0;
    int i = 0;
    while (true) {
      double t = (double) segment / (double) segments;
      double width = MathUtil.interpolate(baseWidth, tipWidth, t);

      strand.vertices[i++] = pos.plus(basis.toStandard(-0.5 * width * co, -0.5 * width * so, 0.0));
      strand.vertices[i++] = pos.plus(basis.toStandard(0.5 * width * co, 0.5 * width * so, 0.0));

      if (++segment > segments) {
        break;
      }

      pos = pos.plus(vel.times(dt));
      pos = pos.plus(RandomUtil.uniformInsideSphere(roughness, adapter).toCartesian());
    }

    return strand;
  }
View Full Code Here

        System.err.printf("Block xref: %s", xref);
        System.err.println();
      }

      state.currentBlock = new Block();
      state.currentBlock.base = new Point3(p[0], p[1], p[2]);
      state.currentBlock.geometry = new MergeSceneElement();

      if (state.currentBlock.base.squaredDistanceToOrigin() > MathUtil.EPSILON) {
        System.out.println("Block with non-origin base.");
      }
View Full Code Here

        ShadingContext context = new MinimalShadingContext(rng);
        generateImportanceSampledSurfacePoint(x, context, rng.next(), rng.next(), rng.next());
        context.getModifier().modify(context);

        Point3 p = context.getPosition();
        Material mat = material;//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) * surfaceArea / (4.0 * Math.PI * d2);
 
View Full Code Here

        return;
      }

      Point3[] vertices = new Point3[4];
      for (int i = 0; i < 4; i++) {
        vertices[i] = new Point3(v[3 * i + 0], v[3 * i + 1], v[3 * i + 2]);
      }

      int nv = vertices[3].squaredDistanceTo(vertices[2]) < MathUtil.EPSILON ? 3 : 4;
      int offset = mesh.getNumVertices();

View Full Code Here

        }
      } while (gc != 0);

      if ((flags & 64) != 0) { // mesh vertex
        state.currentMesh.addVertex(new Point3(v[0], v[1], v[2]));
      } else { // mesh face
        if (f[2] > 0) { // we require at least 3 vertices
          state.currentMesh.addFace(new int[]{ f[0] - 1, f[1] - 1, f[2] - 1 });
          if (f[3] > 0) { // quad
            state.currentMesh.addFace(new int[]{ f[2] - 1, f[3] - 1, f[0] - 1 });
View Full Code Here

    b.faces.add(bot);
    for (int i = 0; i < sideFaces; i++) {
      double theta = 2.0 * Math.PI * (double) i / (double) sideFaces;
      double x = radius * Math.cos(theta);
      double y = radius * Math.sin(theta);
      b.vertices.add(new Vertex(new Point3(x, y, 0.0)));
      b.vertices.add(new Vertex(new Point3(x, y, height)));
      int i0 = 2 * i;
      int i1 = 2 * i + 1;
      int i2 = 2 * (i - 1) + 1;
      int i3 = 2 * (i - 1);
      if (i2 < 0) {
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.