Advertisement
Guest User

Seeing.js

a guest
Oct 14th, 2018
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Idea of A
  2.  
  3. class Eye{
  4.     constructor(){
  5.         this.viewRegion = createRegion
  6.     }
  7.  
  8.     isSeeingSomething(targetObject){
  9.         if(targetObject inside viewRegion){
  10.             return [true, objectPos];
  11.         } else {
  12.             return false;
  13.         }
  14.     }
  15. }
  16.  
  17. // Idea of B
  18.  
  19. class EyeVector {
  20.     constructor(posOfOrigin, viewRange){
  21.         this.vectorLine = line.setLength(0);
  22.     }
  23.  
  24.     see(targetObject){
  25.         if (targetObject intersect something) {
  26.             return [true, pointOfIntersection];
  27.         } else {
  28.             return false;
  29.         }
  30.     }
  31. }
  32.  
  33. class Eye {
  34.     constructor(posOfOrigin, viewRange, viewAngle, vectorCount){
  35.         this.vectors = []
  36.         for(var i=0; i<floor(viewAngle / vectorCount); i++){
  37.             this.vectors.push(new EyeVector(posOfOrigin, viewRange));
  38.         }
  39.     }
  40.  
  41.     see(targetObject){
  42.         var poi = [];
  43.         for(EyeVector i: this.vectors){ //yes its like java, but you got the point
  44.             var temp = i.see(targetObject)
  45.             if(temp[0] == true){
  46.                 poi.push(temp[i]);
  47.             }
  48.         }
  49.  
  50.         this.approxPos(poi);
  51.     }
  52.  
  53.     approxPos(poi){
  54.         return poi approximation;
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement