Examples of Vect3


Examples of jray.common.Vect3

    return root;
  }
 
  public static Octree buildTree(Vect3 center, List<? extends Object3D> objects){
    double maxQuadDist=0, qdist;
    Vect3 dist=new Vect3();
   
    System.out.print("Building octree... ");
   
    for(Object3D o : objects){
      Sphere s = o.getBoundingSphere();
      if(s!=null){
        Vect.subtract(center, s.getPosition(), dist);
        qdist = s.getRadius();
        if(Double.isInfinite(qdist)||Double.isNaN(qdist))
          throw new RuntimeException("Invalid BoundingSphere: "+s+" from "+o);
        qdist = qdist*qdist + dist.quadLength();
        if(maxQuadDist < qdist)
          maxQuadDist = qdist;
      }
    }
   
View Full Code Here

Examples of jray.common.Vect3

import jray.common.Vect3;

public class Triangle {
  public static Vect3 getCircumScribedCircleCenter(Vect3 a, Vect3 b, Vect3 c){
    Vect3 mab = new Vect3();
    Vect3 mac = new Vect3();
    Vect3 normal = new Vect3();
    Vect3 dab = new Vect3();
    Vect3 dac = new Vect3();
   
    Vect.subtract(b, a, mab);
    Vect.subtract(c, a, mac);
    Vect.crossProduct(mab, mac, normal);
    Vect.crossProduct(mab, normal, dab);
    Vect.crossProduct(mac, normal, dac);
    Vect.addMultiple(a, mab, 0.5, mab);
    Vect.addMultiple(a, mac, 0.5, mac);
    dab.normalize();
    dac.normalize();
   
    if(Math.abs(dac.data[0])>1e-9&&Math.abs(dac.data[1])>1e-9&&Math.abs(dab.data[0]/dac.data[0] - dab.data[1]/dac.data[1])>1e-9){
      double x = ((mab.data[1]-mac.data[1])/dac.data[1] - (mab.data[0]-mac.data[0])/dac.data[0])/(dab.data[0]/dac.data[0] - dab.data[1]/dac.data[1]);

      Vect.addMultiple(mab, dab, x);
View Full Code Here

Examples of jray.common.Vect3

     
      for(double x = 1;x<camheight*3;x+=h)
        for(double z = -camheight;z<camheight;z+=h)
          addTree(x+Math.random()*dist-dist/2,-2,z+Math.random()*dist-dist/2);
       
        c = new Camera(new Vect3(-camheight, camheight*2, 0), new Vect3(-camheight+1, camheight*2-1, 0), new Vect3(0.707106781186547, 0.707106781186547, 0), 1, 1, 1);
        objects.add(c);
       
        tree = Octree.buildTree(new Vect3(camheight*1.5,-3.1,0),objects);
    }
View Full Code Here

Examples of jray.common.Vect3

      double ld = 0.2;
     
      int leafColor = IntColors.A+(((int)(IntColors.G*(0.5 + 0.5*Math.random())))&IntColors.G);
     
      if(Math.random()<0.5){
        objects.add(new Cone(new Vect3(x,y+2,z),new Vect3(t0,-1.6,t1),10,leafColor));
        objects.add(new Cone(new Vect3(x,y+2,z),new Vect3(t0*2,-2,t1*2),1,0xFF8B4513));
      }else{
        objects.add(new Sphere(new Vect3(x,y+1.5-ld/2,z),ld,leafColor));
        objects.add(new Cone(new Vect3(x,y+1.5,z),new Vect3(t0*2,-1.5,t1*2),1,0xFF8B4513));
      }
    }
View Full Code Here

Examples of jray.common.Vect3

    private Camera c;
    private Octree tree;
   
    public MeshTest() throws IOException{
      double camheight= 50;
      c = new Camera(new Vect3(0, camheight*2, camheight), new Vect3(0, camheight*2-1, camheight-1), new Vect3(0, 0.707106781186547, -0.707106781186547), 1, 1, 1);
      //c = new Camera(new Vect3(-camheight, camheight*2, 0), new Vect3(-camheight+1, camheight*2-1, 0), new Vect3(0.707106781186547, 0.707106781186547, 0), 1, 1, 1);
      //c = new Camera(new Vect3(0, camheight*2, -camheight), new Vect3(0, camheight*2-1, -camheight+1), new Vect3(0, 0.707106781186547, 0.707106781186547), 1, 1, 1);
      //c = new Camera(new Vect3(0, camheight, -10), new Vect3(0, camheight-1, -10), new Vect3(0, 0, 1), 1, 1, 1);
        objects.add(c);
        TriangleMeshModel model = BinarySTLParser.parse(new File("models/elka.stl"));
       
        int nx = 2;
        int ny = 4;
        for(int i=-nx;i<=nx;i++)
          for(int j=-ny;j<=ny;j++)
            objects.add(new ModelInstance(new Vect3(i*15+(j%2)*7,0,(j+4)*-15),model));
       
        //objects.add(new Plane(new Vect3(0,0,0),new Vect3(0,1,0),0xFFFFFFFF));
        tree = Octree.buildTree(new Vect3(0,0,0),objects);
    }
View Full Code Here

Examples of jray.common.Vect3

  private List<Object3D> objects;
  private Camera cam;
 
  public KugelTest(){
    objects = new ArrayList<Object3D>();
    objects.add(new Sphere(new Vect3(0,0,0),1,0xFFFFFF00));
    cam = new Camera(new Vect3(0,0,-5),new Vect3(0,0,-3),new Vect3(0,1,0));
  }
View Full Code Here

Examples of jray.common.Vect3

   
    /**
     * TODO: 3 vect3 allocated here...
     */
    public static double interpolateTriangleEdge1(Vect3 v1, Vect3 v2, Vect3 v3, Vect3 point){
      Vect3 v23n = new Vect3();
      Vect.subtract(v3, v2, v23n);
      v23n.normalize();
     
      Vect3 v21 = new Vect3();
      Vect.subtract(v1, v2, v21);
     
      Vect3 v1o = new Vect3(); //punkt gegenüber der ecke v1 (o ... opposite)
      Vect.project(v21, v23n, v1o);
      Vect.subtract(v1o, v21, v1o);
     
      Vect3 v1hn = v1o;//höhe auf v1 (h ... height) - von v1 nach v1o - normiert
     
      double h1 = v1hn.length(); //höhe auf v1
      Vect.scale(v1hn, 1/h1, v1hn); //normieren
     
      Vect3 v1p = v21;//von v1 nach point
      Vect.subtract(point, v1, v1p);
     
      Vect3 p1 = v23n;//projektion von v1p auf v1hn
      Vect.project(v1p, v1hn, p1);
     
      return 1-(p1.length()/h1);
    }
View Full Code Here

Examples of jray.common.Vect3

     
      return 1-(p1.length()/h1);
    }
   
    public static Vect3 avg(Vect3 ... vects){
      Vect3 ret = new Vect3();
     
      for(Vect3 v : vects)
        Vect.add(ret, v, ret);
     
      Vect.scale(ret, 1/(float)vects.length, ret);
View Full Code Here

Examples of jray.common.Vect3

  private TriangleMeshModel model;
  private Map<Thread, CollisionData> lastCollision = new HashMap<Thread, CollisionData>();
 
  public ModelInstance(Vect3 position, TriangleMeshModel model) {
    super(position, new Vect3());
    this.model = model;
  }
View Full Code Here

Examples of jray.common.Vect3

  @Override
  public double getHitPointDistance(Ray r) {
    double dist;
    Ray subRay;
    Vect3 tmp = new Vect3();
    Vect.add(position, model.getBoundingSphere().getPosition(), tmp);
   
    if(RaySphere.isRayOriginatingInSphere(r.getOrigin(), r.getDirection(), tmp, model.getBoundingSphere().getRadius())){
      Vect.subtract(r.getOrigin(), position, tmp);
      subRay = new Ray(tmp, r.getDirection());
     
      dist = 0;
    }else{
      dist=RaySphere.getHitPointRaySphereDistance(r.getOrigin(), r.getDirection(), tmp, model.getBoundingSphere().getRadius());
     
      if(Double.isInfinite(dist))
        return dist;
     
      Vect.addMultiple(r.getOrigin(), r.getDirection(), dist, tmp);
      Vect.subtract(tmp, position, tmp);
      subRay = new Ray(tmp, r.getDirection());
    }
   
    CollisionData d = new CollisionData();
    lastCollision.put(Thread.currentThread(), d);
    d.d = RayPath.getFirstCollision(model.getTree(), subRay);
    if(!Double.isInfinite(d.d.d)){
      Vect3 hitPointLocal = new Vect3();
      Vect.addMultiple(subRay.getOrigin(), subRay.getDirection(), d.d.d, hitPointLocal);
      d.hitPointLocal = hitPointLocal;
      Vect3 hitPointGlobal = new Vect3();
      Vect.add(hitPointLocal, position, hitPointGlobal);
      d.hitPointGlobal = hitPointGlobal;
      return d.d.d + dist;
    }else{
      return d.d.d;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.