Package ca.eandb.jmist.math

Examples of ca.eandb.jmist.math.Vector3


      return Math.pow((c + 0.055) / 1.055, 2.4);
    }
  }

  public static RGB convertXYZ2RGB(double x, double y, double z) {
    Vector3 xyz = new Vector3(x, y, z);
    Vector3 rgb = XYZ_TO_sRGBLin.times(xyz);
    return new RGB(
        delinearize(rgb.x()),
        delinearize(rgb.y()),
        delinearize(rgb.z()));
  }
View Full Code Here


    /* (non-Javadoc)
     * @see ca.eandb.jmist.framework.path.PathNode#getPDF(ca.eandb.jmist.math.Vector3)
     */
    public double getPDF(Vector3 v) {
      Vector3 n = context.getNormal();
      return (n.dot(v) > 0.0) ? 1.0 / Math.PI : 0.0;
    }
View Full Code Here

        double    cx = Math.cos(nx);
        double    cy = Math.cos(ny);

        Ray3    ray = new Ray3(
                  Point3.ORIGIN,
                  new Vector3(-sx * cy, sy, -cx * cy));
        Color    color = getWhite();
        double    pdf = 1.0 / solidAngle;
      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().unit();
      double phi = Math.atan2(v.x(), -v.z());
      if (Math.abs(phi) > 0.5 * hfov) {
        return null;
      }
      double theta = Math.asin(v.y());
      if (Math.abs(theta) > 0.5 * vfov) {
        return null;
      }
      return new Point2(
          0.5 + phi / hfov,
View Full Code Here

  public Vector3 scatter(SurfacePointGeometry x, Vector3 v, boolean adjoint,
      double lambda, Random rnd) {

    double n1 = riAbove;
    double n2 = riBelow;
    Vector3 N = x.getNormal();
    double R = Optics.reflectance(v, n1, n2, N);

    boolean fromSide = (v.dot(N) < 0.0);
    boolean toSide;
    Vector3 w;
    double specularity;

    if (RandomUtil.bernoulli(R, rnd)) {
      toSide = fromSide;
      specularity = fromSide ? n11 : n22;
      w = Optics.reflect(v, N);
    } else {
      toSide = !fromSide;
      specularity = fromSide ? n12 : n21;
      w = Optics.refract(v, n1, n2, N);
    }

    if (!Double.isInfinite(specularity)) {
      Basis3 basis = Basis3.fromW(w);
      do {
        SphericalCoordinates perturb = new SphericalCoordinates(
            Math.acos(Math.pow(1.0 - rnd.next(),
                1.0 / (specularity + 1.0))), 2.0 * Math.PI
                * rnd.next());
        w = perturb.toCartesian(basis);
      } while ((w.dot(N) > 0.0) != toSide);
    }

    return w;
  }
View Full Code Here

  public ScatteredRay scatter(SurfacePoint x, Vector3 v, boolean adjoint,
      WavelengthPacket lambda, double ru, double rv, double rj) {

    double n1 = riAbove;
    double n2 = riBelow;
    Vector3 N = x.getNormal();
    double R = Optics.reflectance(v, n1, n2, N);

    boolean fromSide = (v.dot(N) < 0.0);
    boolean toSide;
    Vector3 w;
    double specularity;

    if (RandomUtil.bernoulli(R, rj)) {
      toSide = fromSide;
      specularity = fromSide ? n11 : n22;
      w = Optics.reflect(v, N);
    } else {
      toSide = !fromSide;
      specularity = fromSide ? n12 : n21;
      w = Optics.refract(v, n1, n2, N);
    }

    if (!Double.isInfinite(specularity)) {
      Basis3 basis = Basis3.fromW(w);
      do {
        SphericalCoordinates perturb = new SphericalCoordinates(
            Math.acos(Math.pow(1.0 - ru, 1.0 / (specularity + 1.0))),
            2.0 * Math.PI * rv);
        w = perturb.toCartesian(basis);
      } while ((w.dot(N) > 0.0) != toSide);
    }

    return new ScatteredRay(new Ray3(x.getPosition(), w),
        lambda.getColorModel().getWhite(lambda),
        Double.isInfinite(specularity) ? Type.SPECULAR : Type.DIFFUSE,
View Full Code Here

  @Override
  public ScatteredRay scatter(SurfacePoint x, Vector3 v, boolean adjoint,
      WavelengthPacket lambda, double ru, double rv, double rj) {
    double n1 = riAbove;
    double n2 = riBelow;
    Vector3 N = x.getNormal();
    double R = Optics.reflectance(v, n1, n2, N);

    if (RandomUtil.bernoulli(R, rj)) {
      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) * ru)) - 1.0) / (sigma2 - 1.0)));
      double phi = 2.0 * Math.PI * rv;
      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 ScatteredRay.diffuse(new Ray3(x.getPosition(), out), lambda.getColorModel().getWhite(lambda), 1.0);
View Full Code Here

  @Override
  public ScatteredRay scatter(SurfacePoint x, Vector3 v, boolean adjoint,
      WavelengthPacket lambda, double ru, double rv, double rj) {

    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) lut.length);
View Full Code Here

  public ScatteredRay scatter(SurfacePoint x, Vector3 v, boolean adjoint,
      WavelengthPacket lambda, double ru, double rv, double rj) {

    double n1 = riAbove;
    double n2 = riBelow;
    Vector3 N = x.getNormal();
    double R = Optics.reflectance(v, n1, n2, N);

    if (RandomUtil.bernoulli(R, ru)) {
      v = Optics.reflect(v, N);
      return ScatteredRay.specular(new Ray3(x.getPosition(), v),
View Full Code Here

   */
  @Override
  public ScatteredRay scatter(SurfacePoint x, Vector3 v, boolean adjoint,
      WavelengthPacket lambda, double ru, double rv, double rj) {

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

    ScatteredRay sr;
    Color col = lambda.getColorModel().getWhite(lambda);
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.