Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Idea of A
- class Eye{
- constructor(){
- this.viewRegion = createRegion
- }
- isSeeingSomething(targetObject){
- if(targetObject inside viewRegion){
- return [true, objectPos];
- } else {
- return false;
- }
- }
- }
- // Idea of B
- class EyeVector {
- constructor(posOfOrigin, viewRange){
- this.vectorLine = line.setLength(0);
- }
- see(targetObject){
- if (targetObject intersect something) {
- return [true, pointOfIntersection];
- } else {
- return false;
- }
- }
- }
- class Eye {
- constructor(posOfOrigin, viewRange, viewAngle, vectorCount){
- this.vectors = []
- for(var i=0; i<floor(viewAngle / vectorCount); i++){
- this.vectors.push(new EyeVector(posOfOrigin, viewRange));
- }
- }
- see(targetObject){
- var poi = [];
- for(EyeVector i: this.vectors){ //yes its like java, but you got the point
- var temp = i.see(targetObject)
- if(temp[0] == true){
- poi.push(temp[i]);
- }
- }
- this.approxPos(poi);
- }
- approxPos(poi){
- return poi approximation;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement