#pragma once

#include <stdio.h>
#include <math.h>

namespace MobilePhotoTool{

typedef unsigned short 	pixeltype;
#define	 pixeltypeMAX		65535
#define pixeltypeMIN		0


	typedef unsigned int streamoff;


	class Mathe
	{
	public:
		Mathe(void);
		~Mathe(void);

		static float det_matrix_2x2(const float matrix[4]);

		static float det_matrix_3x3(const float matrix[9]);

		static void invers_matrix3x3(const float in_matrix[9], float out_matrix[9]);

		static void mul_matrix3x3(const float in1_matrix[9], const float in2_matrix[9], float out_matrix[9]);

		static void mul_matrix3x3_vector(const float in1_matrix[9], const float in2_vector[3], float out_vector[3]);

		static void normal_matrix3x3(float in_out_matrix[9], float value, float out_vector[3]); 

		static void min_max_vector3(float vector[3], float *min, float *max);

		static void scalar_vector3(float vector[3], float scalar);

		static float gamma(float in);

		static pixeltype crop(float in);

	};

	inline 	pixeltype Mathe::crop(float in){
		unsigned int v = (unsigned int)in;
		if(v <= 0xFFFF){
			return (pixeltype) in;
		}else{
			if((v & 0x80000000)){
				return 0;
			}else{
				return 0xFFFF;
			}
		}
	}
}
