////////////////////////////////////////////////////////
// filename: common.h
// author: Chafumi Touji
// version: 1.0.0
// date: 2020/03/05
////////////////////////////////////////////////////////

#ifndef __COMMON_H__
#define __COMMON_H__

float ToRadian(float angle);
float ToAngle(float radian);
void MatrixSet(matrix *mtx, float m0, float m1, float m2, float m3, float m4, float m5, float m6, float m7, float m8, float m9, float m10, float m11, float m12, float m13, float m14, float m15);
void MatrixInit(matrix *mtx);
bool GetParam(char *line, char *param1, char *param2, char *c1);
bool GetParamW(wchar_t* line, wchar_t* param1, wchar_t* param2, wchar_t* c1);
bool SetVertex(struct CVertex *vtx, float pos_x, float pos_y, float pos_z, float normal_x, float normal_y, float normal_z, float color_r, float color_g, float color_b, float color_a, float u, float v);
XMFLOAT4 CalcCenterPos(XMFLOAT4 pos1, XMFLOAT4 pos2, XMFLOAT4 pos3);
bool CalcDistPointPoint(XMFLOAT4 pos1, XMFLOAT4 pos2, XMFLOAT4 *near_point, float *dist );
bool CalcDistPointLine(XMFLOAT4 pos, XMFLOAT4 p1, XMFLOAT4 p2, XMFLOAT4 *near_point, float *dist );
bool CalcDistLineLine(XMFLOAT4 p0, XMFLOAT4 p1, XMFLOAT4 pos1, XMFLOAT4 pos2, XMFLOAT4 *near_point, XMFLOAT4 *near_vector, float *dist );
bool CalcDistPointPolygon(XMFLOAT4 pos, XMFLOAT4 p1, XMFLOAT4 p2, XMFLOAT4 p3, XMFLOAT4 normal, XMFLOAT4 *near_point, float *dist);
bool CalcDistLinePolygon(XMFLOAT4 pos0, XMFLOAT4 pos1, XMFLOAT4 p1, XMFLOAT4 p2, XMFLOAT4 p3, XMFLOAT4 normal, XMFLOAT4 *near_point, float *dist);
bool InsArea(CChaColliderObject* obj1, CChaColliderObject* obj2);
bool InsArea(CChaColliderObject* obj, CColliderVertex vtx1, CColliderVertex vtx2, CColliderVertex vtx3);

#endif