35#define MATH_PI 3.1415926
43#define vectoangles vectoangles2
51 float sr, sp, sy, cr, cp, cy;
53 angle =
angles[1] * (M_PI*2 / 360);
56 angle =
angles[0] * (M_PI*2 / 360);
59 angle =
angles[2] * (M_PI*2 / 360);
67 v_right[0] = (-1*sr*sp*cy+-1*cr*-sy);
68 v_right[1] = (-1*sr*sp*sy+-1*cr*cy);
71 v_up[0] = (cr*sp*cy+-sr*-sy);
72 v_up[1] = (cr*sp*sy+-sr*cy);
85lerpAngle(
float startAngle,
float endAngle,
float lerpAmount)
87 float shortest_angle = ((((endAngle - startAngle) % 360.0f) + 540.0f) % 360.0f) - 180.0f;
88 return shortest_angle * lerpAmount;
98lerp(
float startValue,
float endValue,
float lerpAmount)
100 return (startValue * (1 - lerpAmount)) + (endValue * lerpAmount);
110 if (angleValue > 180) {
112 }
else if (angleValue < -180) {
141reflect(vector hitDirection, vector planeNormal)
143 return hitDirection - 2 * dotproduct(hitDirection, planeNormal) * planeNormal;
154 tmp[0] = random() - 0.5f;
155 tmp[1] = random() - 0.5f;
157 if ( flyUp ==
true ) {
160 tmp[2] = random() - 0.5f;
176 new[0] = pivot[0] + (pos[0] - pivot[0]) * cos(degr) - (pos[1] - pivot[1]) * sin(degr);
177 new[1] = pivot[1] + (pos[0] - pivot[0]) * sin(degr) + (pos[1] - pivot[1]) * cos(degr);
189 static float Math_AngleDiff_S(
float from,
float to) {
190 float angleDelta = from - to;
192 if (angleDelta > 180) {
194 }
else if (angleDelta < -180) {
207 newAngle[0] = Math_AngleDiff_S(angle1[0], angle2[0]);
208 newAngle[1] = Math_AngleDiff_S(angle1[1], angle2[1]);
209 newAngle[2] = Math_AngleDiff_S(angle1[2], angle2[2]);
222 vector col = [0,0,0];
224 h = max(0.0, min(360.0, h));
225 s = max(0.0, min(100.0, s));
226 v = max(0.0, min(100.0, v));
232 col[0] = col[1] = col[2] = rint(v*255);
241 t = v * (1 - s * (1 - f));
245 col[0] = rint(255*v);
246 col[1] = rint(255*t);
247 col[2] = rint(255*p);
250 col[0] = rint(255*q);
251 col[1] = rint(255*v);
252 col[2] = rint(255*p);
255 col[0] = rint(255*p);
256 col[1] = rint(255*v);
257 col[2] = rint(255*t);
260 col[0] = rint(255*p);
261 col[1] = rint(255*q);
262 col[2] = rint(255*v);
265 col[0] = rint(255*t);
266 col[1] = rint(255*p);
267 col[2] = rint(255*v);
270 col[0] = rint(255*v);
271 col[1] = rint(255*p);
272 col[2] = rint(255*q);
vector v_up
Definition: math.h:46
float lerp(float startValue, float endValue, float lerpAmount)
Linear lerp function.
Definition: math.h:98
float fixAngleDelta(float angleValue)
Tecursive function that fixes an euler angle.
Definition: math.h:108
noref const vector g_vec_null
Definition: math.h:36
vector reflect(vector hitDirection, vector planeNormal)
Takes a direction and a plane normal, returns a new trajectory.
Definition: math.h:141
void rotatevectorsbyangle(vector angle)
vector rotateAroundPoint(vector pos, vector pivot, float degr)
Takes a position and a pivot point and rotates point by N degrees around the pivot (YAW)
Definition: math.h:173
vector v_right
Definition: math.h:47
vector angleDifference(vector angle1, vector angle2)
Calculates the difference between two angles.
Definition: math.h:187
float lerpAngle(float startAngle, float endAngle, float lerpAmount)
Euler-angle lerping function that accounts for negative degrees.
Definition: math.h:85
vector v_forward
Definition: math.h:45
vector hsvToRGB(float h, float s, float v)
Converts a Hue-Saturation-Value pair to an RGB vector.
Definition: math.h:219
void makevectors(vector angles)
Definition: math.h:48
vector fixAngle(vector inputAngle)
Recursive function that fixes euler angles.
Definition: math.h:127
vector randomVector(bool flyUp)
Calculates a random Vector, with every axis being a value between -1.0 and 1.0, unless flyUp is true.
Definition: math.h:151
vector vectoangles2(vector fwd, optional vector up)
noref vector angles
Definition: ui_3dview.qc:18