GLfloat getYbalanced( GLfloat x , GLfloat y, GLfloat z, GLfloat * dreiArray )
{
// x, y ,z = Point to test
// dreiArray = array holding points of triangle - some offset in it !
GLfloat result = 0.0f;
// distance point 1 x + z
GLfloat w1 = sqrt( powit( ( dreiArray[0] - x ) ) + powit( ( dreiArray[2] - z ) ) );
// distance point 2 x + z
GLfloat w2 = sqrt( powit( ( dreiArray[8] - x ) ) + powit( ( dreiArray[10] - z ) ) );
// distance point 3 x + z
GLfloat w3 = sqrt( powit( ( dreiArray[16] - x ) ) + powit( ( dreiArray[18] - z ) ) );
// total distance
GLfloat w_all = absu( w1 ) + absu( w2 ) + absu( w3 );
// get points relativ distance -> as a factor to multiply later
GLfloat f1 = ( 1.0f / ( w1 / w_all ) );
GLfloat f2 = ( 1.0f / ( w2 / w_all ) );
GLfloat f3 = ( 1.0f / ( w3 / w_all ) );
result += f1 * dreiArray[1]; // factor for point - multiply with hight of point
result += f2 * dreiArray[9]; // factor for point - multiply with hight of point
result += f3 * dreiArray[17]; // factor for point - multiply with hight of point
return ( result / ( f1 + f2 + f3 ) ); // result needs to be devided by total factor sum
}