Package raytracer.common.type

Examples of raytracer.common.type.Vector


  private double rayon;
 
  @Override
  public double[] primitive(Ray ray) {
    double coef[] = new double[3];
    Vector ori = ray.getOrigin().transformation(this.center, this.rotation);
    Vector dir = ray.getDirection().transformation(null, this.rotation);
    coef[0] = dir.getX() * dir.getX() + dir.getY() * dir.getY();
    coef[1] = 2. * (dir.getX() * ori.getX() + dir.getY() * ori.getY());
    coef[2] = ori.getX() * ori.getX() + ori.getY() * ori.getY() - rayon * rayon;
    return (Solver.deg2(coef));
  }
View Full Code Here


    return (Solver.deg2(coef));
  }

  @Override
  public Vector normal(Vector inter) {
    Vector tmp = inter.transformation(this.center, this.rotation);
    tmp.setZ(0);
    return (tmp.reverseRotation(this.rotation).normal());
  }
View Full Code Here

  Vector center;
  Color color;
  Vector rotation;

  public RtObject() {
    center = new Vector();
    color = new Color(1, 1, 1);
    rotation = new Vector(0, 0, 0);
  }
View Full Code Here

  @Override
  public void setParameters(Camera cam, int width, int height) {
    pos = cam.getOrigin();
    double h;
    double l;
    Vector dir = cam.getDirection();

    h = 2. * cam.getDistance() * Math.tan(cam.getFovY() / 2.);
    l = h * (((double) width) / ((double) height));
    u = dir.crossProduct(cam.getUp()).normal().product(l / (double) width);
    v = dir.crossProduct(u).normal().product(h / (double) height);
    ori = pos.add(dir.product(cam.getDistance()))
        .add(u.product(-(double) width / 2.))
        .add(v.product(-(double) height / 2.));
  }
View Full Code Here

    return (Solver.deg1(coef));
  }

  @Override
  public Vector normal(Vector inter) {
    return (new Vector(0., 0., 1.).reverseRotation(this.rotation).normal());
  }
View Full Code Here

  private double rayon;
 
  @Override
  public double[] primitive(Ray ray) {
    double coef[] = new double[3];
    Vector tmp = ray.getOrigin().add(this.center.product(-1.));
    coef[0] = ray.getDirection().scalarProduct(ray.getDirection());
    coef[1] = 2. * tmp.scalarProduct(ray.getDirection());
    coef[3] = tmp.scalarProduct(tmp) - this.rayon * this.rayon;
    return Solver.deg2(coef);
  }
View Full Code Here

  double primitiveParam; /* = tan(alpha)�*/
 
  @Override
  public double[] primitive(Ray ray) {
    double coef[] = new double [3];
    Vector ori = ray.getOrigin().transformation(this.center, this.rotation);
    Vector dir = ray.getDirection().transformation(null, this.rotation);
    coef[0] = dir.getX() * dir.getX() + dir.getY() * dir.getY() - dir.getZ() * dir.getZ() * this.primitiveParam;
    coef[1] = 2. * (dir.getX() * ori.getX() + dir.getY() * ori.getY() - dir.getZ() * ori.getZ() * this.primitiveParam);
    coef[2] = ori.getX() * ori.getX() + ori.getY() * ori.getY() - ori.getZ() * ori.getZ() * this.primitiveParam;
    return (Solver.deg2(coef));
  }
View Full Code Here

    return (Solver.deg2(coef));
  }

  @Override
  public Vector normal(Vector inter) {
    Vector result = inter.transformation(this.center, this.rotation);
    result.setZ(-result.getZ() * Math.pow(Math.tan(this.alpha), 2.));
    return (inter.reverseRotation(this.rotation).normal());
  }
View Full Code Here

TOP

Related Classes of raytracer.common.type.Vector

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.