Package ca.eandb.jmist.math

Examples of ca.eandb.jmist.math.Vector3


   * @see ca.eandb.jmist.framework.Shader#shade(ca.eandb.jmist.framework.ShadingContext)
   */
  public Color shade(ShadingContext sc) {
    Material mat = sc.getMaterial();
    WavelengthPacket lambda = sc.getWavelengthPacket();
    Vector3 normal = sc.getShadingNormal();
    Color sum = sc.getColorModel().getBlack(lambda);
    for (LightSample sample : sc.getLightSamples()) {
      if (!sample.castShadowRay(sc)) {
        Vector3 in = sample.getDirToLight().opposite();
        Vector3 out = sc.getIncident().opposite();
        Color bsdf = mat.bsdf(sc, in, out, lambda);
        double dot = Math.abs(in.dot(normal));
        sum = sum.plus(sample.getRadiantIntensity().times(bsdf.times(dot)));
      }
    }
View Full Code Here


  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.Light#illuminate(ca.eandb.jmist.framework.SurfacePoint, ca.eandb.jmist.framework.color.WavelengthPacket, ca.eandb.jmist.framework.Random, ca.eandb.jmist.framework.Illuminable)
   */
  public void illuminate(SurfacePoint x, WavelengthPacket lambda, Random rng, Illuminable target) {

    Vector3  source = RandomUtil.uniformOnUpperHemisphere(rng).toCartesian(Basis3.fromW(zenith));

    if (source.dot(x.getNormal()) > 0.0) {
      double sdotn = source.dot(x.getShadingNormal());
      Color radiance = lambda.getColorModel().getContinuous(new SkyRadianceSpectrum(source)).sample(lambda);
      target.addLightSample(new DirectionalLightSample(x, source, radiance.times(sdotn), shadows));
    }

    if (daytime && sun.dot(x.getNormal()) > 0.0) {
View Full Code Here

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.Light#illuminate(ca.eandb.jmist.framework.SurfacePoint, ca.eandb.jmist.framework.color.WavelengthPacket, ca.eandb.jmist.framework.Random, ca.eandb.jmist.framework.Illuminable)
   */
  public void illuminate(SurfacePoint x, WavelengthPacket lambda, Random rng, Illuminable target) {

    Vector3    lightIn      = x.getPosition().vectorTo(this.position);
    double    dSquared    = lightIn.squaredLength();

    lightIn = lightIn.divide(Math.sqrt(dSquared));

    double    ndotl      = x.getShadingNormal().dot(lightIn);
    double    attenuation    = Math.abs(ndotl) / (4.0 * Math.PI * dSquared);

    target.addLightSample(new PointLightSample(x, position, emittedPower.sample(lambda).times(attenuation), shadows));
View Full Code Here

    public boolean isSpecular() {
      return true;
    }

    public ScatteredRay sample(double ru, double rv, double rj) {
      Vector3 v = RandomUtil.uniformOnSphere(ru, rv).toCartesian();
      Ray3 ray = new Ray3(position, v);
      return ScatteredRay.diffuse(ray, sample(emittedPower),
          1.0 / (4.0 * Math.PI));
    }
View Full Code Here

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.Light#illuminate(ca.eandb.jmist.framework.SurfacePoint, ca.eandb.jmist.framework.color.WavelengthPacket, ca.eandb.jmist.framework.Random, ca.eandb.jmist.framework.Illuminable)
   */
  public void illuminate(SurfacePoint x, WavelengthPacket lambda, Random rng, Illuminable target) {

    Vector3  source = RandomUtil.uniformOnUpperHemisphere(rng).toCartesian(basis);
    double  dot = x.getShadingNormal().dot(source);

    target.addLightSample(new DirectionalLightSample(x, source, environment.evaluate(source, lambda).times(dot), shadows));

  }
View Full Code Here

    Point3    p      = x.getPosition();
    Medium    medium    = x.getAmbientMedium();
    Color    n1      = medium.refractiveIndex(p, lambda);
    Color    k1      = medium.extinctionIndex(p, lambda);
    Color    n2      = refractiveIndex.sample(lambda);
    Vector3    normal    = x.getShadingNormal();
    boolean    fromSide  = x.getNormal().dot(v) < 0.0;
    Color    R      = MaterialUtil.reflectance(v, n1, k1, n2, null, normal);
    Color    T      = cm.getWhite(lambda).minus(R);
    double    r      = ColorUtil.getMeanChannelValue(R);

    if (RandomUtil.bernoulli(r, rj)) {
      Vector3    out    = Optics.reflect(v, normal);
      boolean    toSide  = x.getNormal().dot(out) >= 0.0;

      if (fromSide == toSide) {
        return ScatteredRay.specular(new Ray3(p, out), R.divide(r), r);
      }
    } else {

    if (false && disperse) {
//      for (int i = 0, channels = cm.getNumChannels(); i < channels; i++) {
//        Complex    eta1  = new Complex(n1.getValue(i), k1.getValue(i));
//        Complex    eta2  = new Complex(n2.getValue(i));
//        Vector3    out    = Optics.refract(v, eta1, eta2, normal);
//        boolean    toSide  = x.getNormal().dot(out) >= 0.0;
//
//        if (fromSide != toSide) {
//          recorder.add(ScatteredRay.transmitSpecular(new Ray3(p, out), T.disperse(i), 1.0));
//        }
//      }
    } else { // !disperse
      double    n1avg  = ColorUtil.getMeanChannelValue(n1);
      double    k1avg  = ColorUtil.getMeanChannelValue(k1);
      double    n2avg  = ColorUtil.getMeanChannelValue(n2);
      Complex    eta1  = new Complex(n1avg, k1avg);
      Complex    eta2  = new Complex(n2avg);
      Vector3    out    = Optics.refract(v, eta1, eta2, normal);
      boolean    toSide  = x.getNormal().dot(out) >= 0.0;

      if (fromSide != toSide) {
        return ScatteredRay.transmitSpecular(new Ray3(p, out), T.divide(1 - r), 1 - r);
      }
View Full Code Here

        }
      }
    }

    Point3 org = ray.origin();
    Vector3 dir = ray.direction();

    double x0 = org.x() / radius;
    double y0 = org.y() / height - 1.0;
    double z0 = org.z() / radius;
    double x1 = dir.x() / radius;
    double y1 = dir.y() / height;
    double z1 = dir.z() / radius;

    Polynomial f = new Polynomial(
        x0 * x0 - y0 * y0 + z0 * z0,
        2.0 * (x0 * x1 - y0 * y1 + z0 * z1),
        x1 * x1 - y1 * y1 + z1 * z1);
 
View Full Code Here

      double side = Math.hypot(radius, height);
      double c = radius / side;
      double s = height / side;
      double hyp = Math.hypot(p.x(), p.z());

      return new Vector3(
          s * p.x() / hyp,
          c,
          s * p.z() / hyp);

    case CONE_SURFACE_BASE:
View Full Code Here

    TransformableLens lens = new TransformableLens(
        PinholeLens.fromHfovAndAspect(2.0 * Math.atan2(0.25 / 2.0, 0.35), 1.0));

    lens.rotateY(Math.PI);
    lens.translate(new Vector3(278.0, 273.0, -800.0));

    return lens;

  }
View Full Code Here

            return null;
          }
          progCountdown = progInterval;
        }

        Vector3 in;
        sensor0[0] = -1;
        do {
          in = RandomUtil.uniformOnSphere(rng).toCartesian();
          incidentCollector.record(in, new Callback() {
            public void record(int sensor) {
              result.cast[sensor]++;
              sensor0[0] = sensor;
            }
          });
        } while (sensor0[0] < 0);
        in = incidentPointsOutward ? in.opposite() : in;

        double wavelength = info.channel.sample(rng);
        Vector3 v = info.specimen.scatter(SurfacePointGeometry.STANDARD, in, adjoint, wavelength, rng);

        if (v != null) {
          v = exitantVectorStrategy.getExitantVector(in, v);
          exitantCollector.record(v, new Callback() {
            public void record(int sensor) {
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.