Example #1
0
GLUSfloat GLUSAPIENTRY glusOrientedBoxDistancePoint4f(const GLUSfloat center[4], const GLUSfloat halfExtend[3], const GLUSfloat orientation[3], const GLUSfloat point[4])
{
	GLUSfloat matrix[9];
	GLUSfloat vector[3];

	GLUSfloat insideDistance;
	GLUSfloat outsideDistance;

	glusPoint4SubtractPoint4f(vector, point, center);

	glusMatrix3x3Identityf(matrix);
	glusMatrix3x3RotateRzRyRxf(matrix, -orientation[2], -orientation[1], -orientation[0]);
	glusMatrix3x3MultiplyVector3f(vector, matrix, vector);

	vector[0] = fabsf(vector[0]) - halfExtend[0];
	vector[1] = fabsf(vector[1]) - halfExtend[1];
	vector[2] = fabsf(vector[2]) - halfExtend[2];

	insideDistance = glusMathMinf(glusMathMaxf(vector[0], glusMathMaxf(vector[1], vector[2])), 0.0f);

	vector[0] = glusMathMaxf(vector[0], 0.0f);
	vector[1] = glusMathMaxf(vector[1], 0.0f);
	vector[2] = glusMathMaxf(vector[2], 0.0f);

	outsideDistance = glusVector3Lengthf(vector);

	return insideDistance + outsideDistance;
}
Example #2
0
GLUSboolean GLUSAPIENTRY glusVector3Normalizef(GLUSfloat vector[3])
{
	GLUSint i;

	GLUSfloat length = glusVector3Lengthf(vector);

	if (length == 0.0f)
	{
		return GLUS_FALSE;
	}

	for (i = 0; i < 3; i++)
	{
		vector[i] /= length;
	}

	return GLUS_TRUE;
}
Example #3
0
float Vector3::length() const
{
    return glusVector3Lengthf(v);
}