 
 __host__ __device__ float deg2rad(float deg) { return deg*PI / 180.0;}
 __host__ __device__ float rad2deg(float rad) { return 180.0*rad / PI; }
+
+
+
+
 
 static int3 get_index_3d_from_array(
 	int array_index,

		float3 direction = normalize(dir);	

#if 1
		float z = -2;
		float3 S1 = make_float3(-1.0f, 1.0f, z);
		float3 S2 = make_float3(1.0f, 1.0f, z);
		float3 S3 = make_float3(-1.0f, -1.0f, z);
		float3 hit;

		if (triangle_intersection(camera_pos, direction, S1, S2, S3, hit))
		{
			d_output_image[y * image_width + x] = make_uchar3(255, 255, 255);
		}
		else
		{
			d_output_image[y * image_width + x] = make_uchar3(8, 16, 32);
		}

		//d_output_image[y * image_width + x].x = (uchar)(((direction.x + 1) * 0.5) * 255);
		//d_output_image[y * image_width + x].y = (uchar)(((direction.y + 1) * 0.5) * 255);

		default: return -1;
	}
}


inline __host__ __device__ float3 compute_normal(
	const float3& p1,
