//alert("Optics function include file")
// Author Peter Parnham
function angleofview(focallen,frdim){

    //Basic formula  Tangent (Angleofview *.5)=(Frdim*.5)/focallen 
	var AOV 
		AOV=Math.atan((frdim*.5)/focallen)   //Answer in radians
	 	AOV=AOV*(180/Math.PI) 				  //Convert to degrees
		AOV=AOV*2
		return AOV;
	}
 


function focallength(AOV,frdim){
	//Basic formula Focallength = (Frdim*.5)/(Tan(AOV*.5))	

 	AOV = AOV*(3.141593/180)  //Convert degrees to Radians

	var flen = (frdim*.5)/Math.tan(AOV*.5);
	return flen;
}	   


//    comments indicate still converting from asp version

function hyperfocal(flen,fstop,coc){
		
	var hyperfocal=(flen*flen)/(fstop*coc)
	
	return hyperfocal;
}



function distnear(hfdist,dist,flen){
		var result=(hfdist*dist)/(hfdist+(dist-flen));
		return result; 	
}


function distfar(hfdist,dist,flen){

	var	result=(hfdist*dist)/(hfdist-(dist-flen));
	return result; 	
}

function dfisinf(hfdist,dist, distf){
		//Test if Distance far is inf
		var dfisinf;
		if (hfdist>=dist){
			dfisinf=distf;
			}
		else{
			dfisinf="inf";
		}	

	return dfisinf;		
}



function FOVsize(dist,imagesize,focallen){
	var FOV=(dist*imagesize)/focallen;
	return FOV;
}


/* Converting from ASP
Function FOVFocallen(dist,fstop,size)
	FOVFocallen=(Dist*Fstop)/size
End Function

Function FOVfstop(dist,focallen,size)
	FOVfstop=(Focallen*size)/dist
End Function

Function FOVdist(fstop,focallen,size)
	FOVdist=(Size*focallen)/fstop
End Function

Function Aperture(fstop,focallen)
	Aperture=(focallen/fstop)
End Function


Function fstop(Aperture,focallen)
	fstop=(focallen/Aperture)
End Function


*/			



