Package ca.eandb.jmist.math

Examples of ca.eandb.jmist.math.Point3


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

    ColorModel  cm      = lambda.getColorModel();
    Point3    p      = x.getPosition();
    Medium    medium    = x.getAmbientMedium();
    Color    n1      = medium.refractiveIndex(p, lambda);
    Color    k1      = medium.extinctionIndex(p, lambda);
    Color    n2      = n.sample(lambda);
    Color    k2      = k.sample(lambda);
View Full Code Here


    if (capped) {
      double t = Plane3.XZ.intersect(ray);

      if (recorder.interval().contains(t)) {
        Point3 p = ray.pointAt(t);
        if (p.distanceToOrigin() <= radius) {
          Intersection x = super.newIntersection(ray, t, ray.origin().y() < 0.0, CONE_SURFACE_BASE)
            .setLocation(p);
          recorder.record(x);
        }
      }
    }

    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);

    double[] t = f.roots();

    if (t.length == 2) {
      for (int i = 0; i < 2; i++) {
        if (recorder.interval().contains(t[i])) {
          Point3 p = ray.pointAt(t[i]);
          if (0.0 <= p.y() && p.y() <= height) {
            Intersection x = super.newIntersection(ray, t[i], i == 0, CONE_SURFACE_BODY)
              .setLocation(p);
            recorder.record(x);
          }
        }
View Full Code Here

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

    ColorModel  cm      = lambda.getColorModel();
    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();
View Full Code Here

  protected Basis3 getBasis(GeometryIntersection x) {
    switch (x.getTag()) {
    case CONE_SURFACE_BODY:
      return Basis3.fromWV(
          getNormal(x),
          x.getPosition().vectorTo(new Point3(0, height, 0)));

    case CONE_SURFACE_BASE:
      return Basis3.fromW(getNormal(x));

    default:
View Full Code Here

   */
  @Override
  protected Vector3 getNormal(GeometryIntersection x) {
    switch (x.getTag()) {
    case CONE_SURFACE_BODY:
      Point3 p = x.getPosition();
      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:
      return Vector3.NEGATIVE_J;

    default:
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 CONE_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() / height);

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

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

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.Bounded3#boundingSphere()
   */
  public Sphere boundingSphere() {
    double yc = (height * height - radius * radius) / (2.0 * height);
    return yc > 0.0 ? new Sphere(new Point3(0, yc, 0), height - yc)
        : new Sphere(Point3.ORIGIN, radius);
  }
View Full Code Here

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.Bounded3#boundingSphere()
   */
  @Override
  public Sphere boundingSphere() {
    Point3 center = new Point3(0.0, 0.5 * (height1 + height2), 0.0);
    double height = Math.abs(height1 - height2);
    double maxR = Math.max(radius1, radius2);
    double radius = Math.sqrt(maxR * maxR + 0.25 * height * height);
    return new Sphere(center, radius);
  }
View Full Code Here

    double[] t = f.roots();

    if (t.length == 2) {
      for (int i = 0; i < 2; i++) {
        if (recorder.interval().contains(t[i])) {
          Point3 p = ray.pointAt(t[i]);
          if (MathUtil.inRangeCC(p.y(),
              Math.min(height1, height2),
              Math.max(height1, height2))) {
            Intersection x = super.newIntersection(ray, t[i], i == 0, TAPERED_CYLINDER_SURFACE_BODY)
              .setLocation(p);
            recorder.record(x);
View Full Code Here

  protected Basis3 getBasis(GeometryIntersection x) {
    switch (x.getTag()) {
    case TAPERED_CYLINDER_SURFACE_BODY:
      return Basis3.fromWV(
          getNormal(x),
          x.getPosition().vectorTo(new Point3(0, height2, 0)));

    case TAPERED_CYLINDER_SURFACE_END_1:
    case TAPERED_CYLINDER_SURFACE_END_2:
      return Basis3.fromW(getNormal(x));
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.