Package ca.eandb.jmist.math

Examples of ca.eandb.jmist.math.Point3


      Vector3 n = plane.normal();
      p = plane.project(p);


      for (int i = 0; i < decomp.length; i += 3) {
        Point3 a = vertices.get(indices[decomp[i]]);
        Point3 b = vertices.get(indices[decomp[i + 1]]);
        Point3 c = vertices.get(indices[decomp[i + 2]]);
        Vector3 ab = a.vectorTo(b);
        Vector3 ac = a.vectorTo(c);
        Vector3 pa = p.vectorTo(a);
        Vector3 pb = p.vectorTo(b);
        Vector3 pc = p.vectorTo(c);
View Full Code Here


   * @see ca.eandb.jmist.framework.AbstractGeometry#getNormal(ca.eandb.jmist.framework.AbstractGeometry.GeometryIntersection)
   */
  @Override
  protected Vector3 getNormal(GeometryIntersection x) {

    Point3  p = x.getPosition();
    Vector3  rel = new Vector3(p.x(), 0.0, p.z());

    double  length = rel.length();

    if (length > 0.0)
    {
      rel = rel.times(major / length);
      return p.vectorFrom(Point3.ORIGIN.plus(rel));
    }
    else
      return Vector3.K;

  }
View Full Code Here

   * @see ca.eandb.jmist.framework.AbstractGeometry#getBasis(ca.eandb.jmist.framework.AbstractGeometry.GeometryIntersection)
   */
  @Override
  protected Basis3 getBasis(GeometryIntersection x) {

    Point3  p  = x.getPosition();
    Vector3  u  = new Vector3(-p.z(), 0.0, p.x()).unit();

    return Basis3.fromWU(x.getNormal(), u, Basis3.Orientation.RIGHT_HANDED);

  }
View Full Code Here

    Vector3 r = surface.scatter(x, v, adjoint, wavelength, rnd);

    if (r != null) {

      Vector3 n = x.getNormal();
      Point3 p = x.getPosition();
      Ray3 ray = new Ray3(p, r);

      Color color = colorModel.getWhite(lambda);

      if (r.dot(n) > 0.0) {
View Full Code Here

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.Texture2#evaluate(ca.eandb.jmist.math.Point2, ca.eandb.jmist.framework.color.WavelengthPacket)
   */
  @Override
  public Color evaluate(Point2 p, WavelengthPacket lambda) {
    Point3 q = origin.plus(u.times(p.x())).plus(v.times(p.y()));
    return source.evaluate(q, lambda);
  }
View Full Code Here

  public static Point2 canonical2(Random random) {
    return new Point2(random.next(), random.next());
  }

  public static Point3 canonical3(Random random) {
    return new Point3(random.next(), random.next(), random.next());
  }
View Full Code Here

  public static Point3 uniform(Box3 box, Random random) {
    return uniform(box, random.next(), random.next(), random.next());
  }

  public static Point3 uniform(Box3 box, double ru, double rv, double rw) {
    return new Point3(
        uniform(box.minimumX(), box.maximumX(), ru),
        uniform(box.minimumY(), box.maximumY(), rv),
        uniform(box.minimumZ(), box.maximumZ(), rw));
  }
View Full Code Here

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.geometry.PrimitiveGeometry#generateRandomSurfacePoint(ca.eandb.jmist.framework.ShadingContext)
   */
  @Override
  public void generateRandomSurfacePoint(ShadingContext context, double ru, double rv, double rj) {
    Point3 p = sphere.center().plus(RandomUtil.uniformOnSphere(sphere.radius(), ru, rv).toCartesian());
    Intersection x = newSurfacePoint(p);
    x.prepareShadingContext(context);
  }
View Full Code Here

  private void readVertex(PlyElement element) {
    double x = element.getProperty("x").getDoubleValue();
    double y = element.getProperty("y").getDoubleValue();
    double z = element.getProperty("z").getDoubleValue();

    geometry.addVertex(new Point3(x, y, z));
  }
View Full Code Here

   * @see ca.eandb.jmist.framework.geometry.PrimitiveGeometry#intersect(ca.eandb.jmist.math.Ray3, ca.eandb.jmist.framework.IntersectionRecorder)
   */
  public void intersect(Ray3 ray, IntersectionRecorder recorder) {

    Interval  I    = recorder.interval();
    Point3    p;
    double    t;

    // first check for intersection of ray with the caps on the ends of the cylinder

    // check bottom cap
    t = (this.base.y() - ray.origin().y()) / ray.direction().y();
    if (I.contains(t))
    {
      p = ray.pointAt(t);

      if (this.base.squaredDistanceTo(p) < this.radius * this.radius)
      {
        Intersection x = super.newIntersection(ray, t, (ray.direction().y() > 0.0), CYLINDER_SURFACE_BASE)
          .setLocation(p);

        recorder.record(x);
      }
    }

    // check top cap
    t = (this.base.y() + this.height - ray.origin().y()) / ray.direction().y();
    if (I.contains(t))
    {
      p = ray.pointAt(t);

      double r = (p.x() - this.base.x()) * (p.x() - this.base.x()) + (p.z() - this.base.z()) * (p.z() - this.base.z());

      if (r < this.radius * this.radius)
      {
        Intersection x = super.newIntersection(ray, t, (ray.direction().y() < 0.0), CYLINDER_SURFACE_TOP)
          .setLocation(p);

        recorder.record(x);
      }
    }

    // now check for intersection of ray with the body
    Vector3    orig  = this.base.vectorTo(ray.origin());
    Vector3    dir    = ray.direction();

    Polynomial  f    = new Polynomial(
                orig.x() * orig.x() + orig.z() * orig.z() - this.radius * this.radius,
                2.0 * (orig.x() * dir.x() + orig.z() * dir.z()),
                dir.x() * dir.x() + dir.z() * dir.z()
              );
    double[]  x    = f.roots();

    if (x.length == 2)
    {
      // for each solution, make sure the point lies between the base and the apex
      p = ray.pointAt(x[0]);
      if (MathUtil.inRangeOO(p.y(), this.base.y(), this.base.y() + this.height))
      {
        Intersection isect = super.newIntersection(ray, x[0], (x[0] < x[1]), CYLINDER_SURFACE_BODY)
          .setLocation(p);

        recorder.record(isect);
      }

      p = ray.pointAt(x[1]);
      if (MathUtil.inRangeOO(p.y(), this.base.y(), this.base.y() + this.height))
      {
        Intersection isect = super.newIntersection(ray, x[1], (x[0] > x[1]), CYLINDER_SURFACE_BODY)
          .setLocation(p);

        recorder.record(isect);
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.