Package ca.eandb.jmist.math

Examples of ca.eandb.jmist.math.Vector3


   * @see ca.eandb.jmist.framework.scatter.SurfaceScatterer#scatter(ca.eandb.jmist.framework.SurfacePointGeometry, ca.eandb.jmist.math.Vector3, boolean, ca.eandb.jmist.framework.color.WavelengthPacket, ca.eandb.jmist.framework.Random)
   */
  public Vector3 scatter(SurfacePointGeometry x, Vector3 v, boolean adjoint,
      double lambda, Random rnd) {

    Vector3 N = x.getNormal();
    int  depth = (v.dot(N) > 0.0) ? (layers.size() - 1) : 0;
    int dir;

    do  {

View Full Code Here


        t = (lambda - wavelengths[index - 1]) / (wavelengths[index] - wavelengths[index - 1]);
      }
    }

    Basis3 basis = Basis3.fromW(v);
    Vector3 N = x.getNormal();
    boolean inDir = (v.dot(N) < 0.0);
    boolean outDir;

    do {
      int j = (int) Math.floor(rnd.next() * (double) lut0.length);
View Full Code Here

   */
  public Vector3 scatter(SurfacePointGeometry x, Vector3 v, boolean adjoint,
      double lambda, Random rnd) {
    double n1 = riAbove.evaluate(lambda);
    double n2 = riBelow.evaluate(lambda);
    Vector3 N = x.getNormal();
    double R = Optics.reflectance(v, n1, n2, N);

    if (RandomUtil.bernoulli(R, rnd)) {
      Basis3 basis = x.getBasis();
      double sigma2 = oblateness * oblateness;
      double sigma4 = sigma2 * sigma2;
      Vector3 out;
      double theta = Math.acos(Math.sqrt(((sigma2 / Math.sqrt(sigma4 + (1.0 - sigma4) * rnd.next())) - 1.0) / (sigma2 - 1.0)));
      double phi = 2.0 * Math.PI * rnd.next();
      SphericalCoordinates sc = new SphericalCoordinates(theta, phi);
      Vector3 microN = sc.toCartesian(basis);
      out = Optics.reflect(v, microN);
      if (out.dot(N) <= 0.0) {
        return null;
      }
      return out;
View Full Code Here

    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

            public boolean isFront() {
              return true;
            }
            public void prepareShadingContext(ShadingContext context) {
              Plane3 plane = Plane3.throughPoints(vertices[vertexIndex], vertices[vertexIndex+1], vertices[vertexIndex+2]);
              Vector3 n = plane.normal();
              Vector3 v = ray.direction();
              context.setPosition(ray.pointAt(t));
              context.setNormal(v.dot(n) > 0.0 ? n.opposite() : n);
              context.setMaterial(hairMaterial != null ? hairMaterial : emitterContext.getMaterial());
              context.setModifier(emitterContext.getModifier());
              context.setPrimitiveIndex(base + strandIndex);
              context.setShader(emitterContext.getShader());
              context.setUV(emitterContext.getUV());
View Full Code Here

        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);
        Color ri = mat.emission(context, v, lambda).times(atten);

        LightSample sample = new PointLightSample(x, p, ri);

        target.addLightSample(sample);
View Full Code Here

//        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");
//      }
View Full Code Here

   * @see ca.eandb.jmist.framework.Material#emit(ca.eandb.jmist.framework.SurfacePoint, ca.eandb.jmist.framework.color.WavelengthPacket, double, double, double)
   */
  @Override
  public ScatteredRay emit(SurfacePoint x, WavelengthPacket lambda,
      double ru, double rv, double rj) {
    Vector3 r = RandomUtil.diffuse(ru, rv).toCartesian(x.getBasis());
    Ray3 ray = new Ray3(x.getPosition(), r);
    double pdf = 1.0 / Math.PI;
    Color color = inner.emission(x, r, lambda).divide(pdf);
    return ScatteredRay.diffuse(ray, color, pdf);
  }
View Full Code Here

  @Override
  public ScatteredRay scatter(SurfacePoint x, Vector3 v, boolean adjoint,
      WavelengthPacket lambda, double ru, double rv, double rj) {
    SeedReference ref = new SeedReference(ru);
    boolean reflect = RandomUtil.bernoulli(reflectance, ref);
    Vector3 r = RandomUtil.diffuse(ref.seed, rv).toCartesian(x.getBasis());
    double pdf = 1.0 / Math.PI;

    if (!reflect) {
      r = r.opposite();
      pdf *= (1.0 - reflectance);
    } else {
      pdf *= reflectance;
    }

View Full Code Here

    for (int i = 0, nf = faces.size(); i < nf; i++) {
      Face face = faces.get(i);
      for (int j = 0; j < face.normalIndices.length; j++) {
        int k = face.normalIndices[j];
        if (toGenerate.get(k)) {
          Vector3 normal = normals.get(k);
          normal = normal.plus(face.plane.normal());
          normals.set(k, normal);
        }
      }
    }
    for (int i = 0; i < n; i++) {
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.