Package ca.eandb.jmist.math

Examples of ca.eandb.jmist.math.Vector3


  }

  private void transformShadingContext(ShadingContext context) {

    Basis3 basis = context.getShadingBasis();
    Vector3 u = t.apply(basis.u());
    Vector3 v = t.apply(basis.v());

    context.setShadingBasis(Basis3.fromUV(u, v));

    basis = context.getBasis();
    u = t.apply(basis.u());
View Full Code Here


  private void initialize() {
    if (!ready) {
      AffineMatrix3 matrix = t.apply(AffineMatrix3.IDENTITY);
      scaleFactor = Math.cbrt(matrix.determinant());

      Vector3 u = t.apply(Vector3.I).unit();
      Vector3 v = t.apply(Vector3.J).unit();
      Vector3 w = t.apply(Vector3.K).unit();

      shapePreserving = (u.dot(v) < MathUtil.EPSILON)
          && (v.dot(w) < MathUtil.EPSILON)
          && (w.dot(u) < MathUtil.EPSILON);
    }
  }
View Full Code Here

        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);
        Color ri = mat.emission(context, v, lambda).times(atten);
        LightSample sample = new PointLightSample(x, p, ri);

        target.addLightSample(sample);
View Full Code Here

    // sum irradiance from all photons.
    for (int i = 1; i < np.found; i++) {
      int index = np.index[i];
      // the following check can be omitted (for speed) if the scene does
      // not have any thin surfaces.
      Vector3 pdir = photons.getDir(index);
      if (pdir.dot(normal) < 0.0) {
        irrad += photons.getPower(index);
      }
    }

    irrad *= (1.0 / Math.PI) / np.squaredDistance[0]// estimate of density
View Full Code Here

      Point3 focus = new Point3(
          (pointOnImagePlane.x() - 0.5) * objPlaneWidth,
          (0.5 - pointOnImagePlane.y()) * objPlaneHeight,
          -focusDistance);

      Vector3 direction = origin.unitVectorTo(focus);

      this.ray = new Ray3(origin, direction);
    }
View Full Code Here

     * @see ca.eandb.jmist.framework.path.EyeNode#project(ca.eandb.jmist.math.HPoint3)
     */
    @Override
    public Point2 project(HPoint3 p) {
      Ray3 pray = new Ray3(ray.origin(), p);
      Vector3 dir = pray.direction();
      if (-dir.z() < MathUtil.EPSILON) {
        return null;
      }

      double      ratio      = -focusDistance / dir.z();
      double      x        = ray.origin().x() + ratio * dir.x();
      double      y        = ray.origin().y() + ratio * dir.y();

      final double  u        = 0.5 + x / objPlaneWidth;
      if (!MathUtil.inRangeCC(u, 0.0, 1.0)) {
        return null;
      }
View Full Code Here

    /* (non-Javadoc)
     * @see ca.eandb.jmist.framework.path.PathNode#sample(double, double, double)
     */
    @Override
    public ScatteredRay sample(double ru, double rv, double rj) {
      Vector3 v = ray.direction();
      Color color = getWhite();
      double pdf = (focusDistance * focusDistance)
          / (v.z() * v.z() * v.z() * v.z() * objPlaneWidth * objPlaneHeight);
      return ScatteredRay.diffuse(ray, color, pdf);
    }
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) {
      Point2 p = pointOnImagePlane;
      Vector3 v = new Vector3(
          width * (p.x() - 0.5),
          height * (0.5 - p.y()),
          -1.0);
      Ray3 ray = new Ray3(Point3.ORIGIN, v.unit());
      Color color = getWhite();
      double z = v.x() * v.x() + v.y() * v.y() + 1.0;
      double pdf = z * z / (width * height);
      return ScatteredRay.diffuse(ray, color, pdf);
    }
View Full Code Here

    /* (non-Javadoc)
     * @see ca.eandb.jmist.framework.path.EyeNode#project(ca.eandb.jmist.math.HPoint3)
     */
    public Point2 project(HPoint3 x) {
      Ray3 ray = new Ray3(Point3.ORIGIN, x);
      Vector3 v = ray.direction();
      if (-v.z() < MathUtil.EPSILON) {
        return null;
      }
      Point2 p = new Point2(
          0.5 - v.x() / (width * v.z()),
          0.5 + v.y() / (height * v.z()));
      return Box2.UNIT.contains(p) ? p : null;
    }
View Full Code Here

   */
  @Override
  public Color bsdf(SurfacePoint x, Vector3 in, Vector3 out,
      WavelengthPacket lambda) {

    Vector3 p = out.unit().minus(in.unit()).unit();
    Basis3 basis = x.getShadingBasis();
    SphericalCoordinates omegaO = SphericalCoordinates.fromCartesian(out, basis).canonical();
    SphericalCoordinates omegaP = SphericalCoordinates.fromCartesian(p, basis).canonical();

    double NdotI = -basis.w().dot(in);
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.