// Javascript copyright Sean T. McHugh
// Cambridge in Colour Photography
// http://www.cambridgeincolour.com

var spheregrid = new Image(); spheregrid.src = "graphics/tut_stitchsoft_spheregrid2.png"; spheregrid.src = "graphics/tut_stitchsoft_spheregrid3.png"; spheregrid.src = "graphics/tut_stitchsoft_spheregrid4.png"; spheregrid.src = "graphics/tut_stitchsoft_spheregrid5.png"; spheregrid.src = "graphics/tut_stitchsoft_spheregrid6.png"; spheregrid.src = "graphics/tut_stitchsoft_spheregrid7.png";

<!-- Begin Panorama Angle of View Calculator
function pano_aov_calc(pano_aov_form) {
focal = pano_aov_form.focal.value; // focal length in mm
hor_size = pano_aov_form.hor_size.value;
vert_size = pano_aov_form.vert_size.value;
percent_overlap = pano_aov_form.percent_overlap.value;
orientation = pano_aov_form.orientation.value;
sensor = pano_aov_form.sensor.value;

if (isNaN(focal)) {
alert('Please enter a numerical value for lens focal length.');
document.pano_aov_form.focal.focus();
document.pano_aov_form.focal.select();
}
else {
if (isNaN(percent_overlap)) {
alert('Please enter a numerical value for approximate percent overlap between photographs.');
document.pano_aov_form.percent_overlap.focus();
document.pano_aov_form.percent_overlap.select();
}
else {
if (sensor<0.0165) {
	aspect = 1.333
}
else {
	aspect = 1.5
}

//note: sensor_width is defined as longest sensor dimension
overlap_fraction = percent_overlap / 100;
crop_factor = 0.033 / sensor;
sensor_width = 36 / crop_factor; //sensor width in mm
sensor_height = sensor_width / aspect; //sensor height in mm

if (orientation==2) {
temp1 = sensor_width;
sensor_width = sensor_height;
sensor_height = temp1;
}

hor_aov = 2 * (180 / Math.PI) * Math.atan(sensor_width / (2 * focal)); //horizontal angle of view in degrees
vert_aov = 2 * (180 / Math.PI) * Math.atan( sensor_height / (2 * focal) ); //horizontal angle of view in degrees

if (overlap_fraction>0.5) {
hor_aov = hor_aov + (180 / Math.PI) * (hor_size-1) * Math.atan(overlap_fraction * sensor_width / focal);
vert_aov = vert_aov + (180 / Math.PI) * (vert_size-1) * Math.atan(overlap_fraction * sensor_height / focal);
}
else {
hor_aov = hor_aov + (180 / Math.PI) * (hor_size-1) * (Math.atan(0.5 * sensor_width / focal) + Math.atan((0.5-overlap_fraction) * sensor_width / focal));
vert_aov = vert_aov + (180 / Math.PI) * (vert_size-1) * (Math.atan(0.5 * sensor_height / focal) + Math.atan((0.5-overlap_fraction) * sensor_height / focal));
}


pano_aov_form.hor_aov.value = Math.round(10 * hor_aov) / 10 + "\u00B0";
pano_aov_form.vert_aov.value = Math.round(10 * vert_aov) / 10 + "\u00B0";

	}
	}
}
//  End Panorama Angle of View Calculator -->

<!-- Begin 360 Degree Panorama Calculator
function pano_360_calc(pano_360_form) {
focal0 = pano_360_form.focal0.value; // focal length in mm
percent_overlap0 = pano_360_form.percent_overlap0.value;
orientation0 = pano_360_form.orientation0.value;
sensor0 = pano_360_form.sensor0.value;

if (isNaN(focal0)) {
alert('Please enter a numerical value for lens focal length.');
document.pano_360_form.focal0.focus();
document.pano_360_form.focal0.select();
}
else {
if (isNaN(percent_overlap0)) {
alert('Please enter a numerical value for approximate percent overlap between photographs.');
document.pano_360_form.percent_overlap0.focus();
document.pano_360_form.percent_overlap0.select();
}
else {
if (sensor0<0.0165) {
	aspect = 1.333
}
else {
	aspect = 1.5
}

//note: sensor_width is defined as longest sensor dimension
overlap_fraction = percent_overlap0 / 100;
crop_factor = 0.033 / sensor0;
sensor_width = 36 / crop_factor; //sensor width in mm
sensor_height = sensor_width / aspect; //sensor height in mm

if (orientation0==2) {
temp1 = sensor_width;
sensor_width = sensor_height;
sensor_height = temp1;
}

if (overlap_fraction>0.5) {
temp2 = Math.atan(overlap_fraction * sensor_width / focal0); //horizontal angle of view in degrees

}
else {
temp2 = Math.atan(0.5 * sensor_width / focal0) + Math.atan((0.5-overlap_fraction) * sensor_width / focal0);
}

num_photos = 2 * Math.PI / temp2;

pano_360_form.num_photos.value = Math.round(num_photos);

	}
	}
}
//  End 360 Degree Panorama Calculator -->