/*--------------------------------------\
| Disclaimer:
|   This code is certified by me to work, and work well,
|   Since I have no credentials as yet,
|    (perhaps other than this code here)
|   my certification means nothing whatsoever.
|
| Simply stated: USE AT YOUR OWN RISK
|
| You have permision to use this library free
|  free programs free of charge. 
| However for anything commercial, I get 
|  a copy of the product.
\---------------------------------------*/

#ifndef TRANSFORM_H_
#define TRANSFROM_H_

#define _F float
#define _D double
#define _CF const float
#define _CD const double

/* Make an orthogonal basis from 2 vectors */
/* Uses e1 as a strong vector, say forward, and e2 as weak, say upp-ish */
void     orthobasisf(_F o1[3], _F o2[3], _F o3[3], _CF e1[3], _CF e2[3]);
void rev_orthobasisf(_F o1[3], _F o2[3], _F o3[3], _CF e1[3], _CF e3[3]);

void     orthobasisd(_D o1[3], _D o2[3], _D o3[3], _CD e1[3], _CD e2[3]);
void rev_orthobasisd(_D o1[3], _D o2[3], _D o3[3], _CD e1[3], _CD e3[3]);

/* world to object space */
void matrixVVXpOf(_F m[16], _CF e1[3], _CF e2[3], _CF pos[3]); /*  back dir + right dir */
void matrixVXVpOf(_F m[16], _CF e1[3], _CF e3[3], _CF pos[3]); /*  back dir +    up dir */
void matrixXVVpOf(_F m[16], _CF e2[3], _CF e3[3], _CF pos[3]); /* right dir +    up dir */

void matrixVVXpOd(_D m[16], _CD e1[3], _CD e2[3], _CD pos[3]); /*  back dir + right dir */
void matrixVXVpOd(_D m[16], _CD e1[3], _CD e3[3], _CD pos[3]); /*  back dir +    up dir */
void matrixXVVpOd(_D m[16], _CD e2[3], _CD e3[3], _CD pos[3]); /* right dir +    up dir */

/* object to world space */
void matrixVVXpWf(_F m[16], _CF e1[3], _CF e2[3], _CF pos[3]); /*  back dir + right dir */
void matrixVXVpWf(_F m[16], _CF e1[3], _CF e3[3], _CF pos[3]); /*  back dir +    up dir */
void matrixXVVpWf(_F m[16], _CF e2[3], _CF e3[3], _CF pos[3]); /* right dir +    up dir */

void matrixVVXpWd(_D m[16], _CD e1[3], _CD e2[3], _CD pos[3]); /*  back dir + right dir */
void matrixVXVpWd(_D m[16], _CD e1[3], _CD e3[3], _CD pos[3]); /*  back dir +    up dir */
void matrixXVVpWd(_D m[16], _CD e2[3], _CD e3[3], _CD pos[3]); /* right dir +    up dir */

#endif