1 /****************************************************************************************/
\r
4 /* Author: John Pollard */
\r
5 /* Description: Various math functions not included in Vec3d.h, etc... */
\r
7 /* The contents of this file are subject to the Genesis3D Public License */
\r
8 /* Version 1.01 (the "License"); you may not use this file except in */
\r
9 /* compliance with the License. You may obtain a copy of the License at */
\r
10 /* http://www.genesis3d.com */
\r
12 /* Software distributed under the License is distributed on an "AS IS" */
\r
13 /* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See */
\r
14 /* the License for the specific language governing rights and limitations */
\r
15 /* under the License. */
\r
17 /* The Original Code is Genesis3D, released March 25, 1999. */
\r
18 /*Genesis3D Version 1.1 released November 15, 1999 */
\r
19 /* Copyright (C) 1999 WildTangent, Inc. All Rights Reserved */
\r
21 /****************************************************************************************/
\r
22 #include <Windows.h>
\r
25 #include "MathLib.h"
\r
27 geVec3d VecOrigin = {0.0f, 0.0f, 0.0f};
\r
29 //====================================================================================
\r
31 //====================================================================================
\r
32 void ClearBounds(geVec3d *Mins, geVec3d *Maxs)
\r
34 Mins->X = MIN_MAX_BOUNDS;
\r
35 Mins->Y = MIN_MAX_BOUNDS;
\r
36 Mins->Z = MIN_MAX_BOUNDS;
\r
38 Maxs->X = -MIN_MAX_BOUNDS;
\r
39 Maxs->Y = -MIN_MAX_BOUNDS;
\r
40 Maxs->Z = -MIN_MAX_BOUNDS;
\r
43 //=======================================================================================
\r
45 //=======================================================================================
\r
46 void AddPointToBounds(geVec3d *v, geVec3d *Mins, geVec3d *Maxs)
\r
51 for (i=0 ; i<3 ; i++)
\r
53 Val = VectorToSUB(*v, i);
\r
55 if (Val < VectorToSUB(*Mins, i))
\r
56 VectorToSUB(*Mins, i) = Val;
\r
57 if (Val > VectorToSUB(*Maxs, i))
\r
58 VectorToSUB(*Maxs, i) = Val;
\r
62 //=======================================================================================
\r
64 //=======================================================================================
\r
65 geFloat ColorNormalize(geVec3d *C1, geVec3d *C2)
\r
78 geVec3d_Scale(C1, 1.0f/Max, C2);
\r
83 //=======================================================================================
\r
85 //=======================================================================================
\r
86 geFloat ColorClamp(geVec3d *C1, geFloat Clamp, geVec3d *C2)
\r
98 if (VectorToSUB(C3, i) < 1.0f)
\r
99 VectorToSUB(C3, i) = 1.0f;
\r
101 if (VectorToSUB(C3, i) > Max)
\r
102 Max = VectorToSUB(C3, i);
\r
110 geVec3d_Scale(C1, Max2/Max, C2);
\r
115 //=======================================================================================
\r
116 // geVec3d_PlaneType
\r
117 //=======================================================================================
\r
118 int32 geVec3d_PlaneType(geVec3d *V1)
\r
122 X = (geFloat)fabs(V1->X);
\r
123 Y = (geFloat)fabs(V1->Y);
\r
124 Z = (geFloat)fabs(V1->Z);
\r
129 else if (Y == 1.0f)
\r
132 else if (Z == 1.0f)
\r
135 if (X >= Y && X >= Z)
\r
138 else if (Y >= X && Y >= Z)
\r