summaryrefslogtreecommitdiffstats
path: root/Smoke/funcs.c
blob: a991e42c16424b541af15e6ee2dec6c4d703ea56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Includes

#ifdef G_OS_WIN32
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif

#include "funcs.h"

float quake_root(float number)
{
  long i;
  float x, y;
  const float f = 1.5f;

  x = number * 0.5f;
  y  = number;
  i  = * ( long * ) &y;
  i  = 0x5f3759df - ( i >> 1 );
  y  = * ( float * ) &i;
  y  = y * ( f - ( x * y * y ) );
  y  = y * ( f - ( x * y * y ) );
  return number * y;
}

float vec_len2f(float x, float y)
{
  return (quake_root((x * x) + (y * y)));
}

float vec_len3f(float x, float y, float z)
{
  return (quake_root((x * x) + (y * y) + (z * z)));
}