| 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 |
#ifndef _VJ_CONFIG_H_ |
|---|
| 35 |
#define _VJ_CONFIG_H_ |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
#include <vjDefines.h> |
|---|
| 49 |
|
|---|
| 50 |
#ifdef _DEBUG |
|---|
| 51 |
# define VJ_DEBUG |
|---|
| 52 |
#else |
|---|
| 53 |
# define VJ_OPT |
|---|
| 54 |
#endif |
|---|
| 55 |
|
|---|
| 56 |
#ifdef WIN32 |
|---|
| 57 |
|
|---|
| 58 |
#define WIN32_LEAN_AND_MEAN |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
#pragma warning(disable:4786) |
|---|
| 62 |
|
|---|
| 63 |
#include <windows.h> |
|---|
| 64 |
|
|---|
| 65 |
#ifndef HAVE_STRCASECMP |
|---|
| 66 |
#define strcasecmp _stricmp |
|---|
| 67 |
#endif |
|---|
| 68 |
|
|---|
| 69 |
#define M_PI 3.14159265358979323846 |
|---|
| 70 |
#define M_PI_2 1.57079632679489661923 |
|---|
| 71 |
#define M_PI_4 0.78539816339744830962 |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
#endif |
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
#ifdef __cplusplus |
|---|
| 80 |
#include <iostream> |
|---|
| 81 |
#include <iomanip> |
|---|
| 82 |
#include <fstream> |
|---|
| 83 |
#include <vector> |
|---|
| 84 |
#include <map> |
|---|
| 85 |
#include <string> |
|---|
| 86 |
#include <algorithm> |
|---|
| 87 |
#include <math.h> |
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
inline void VJ_LERP( float& result, const float& lerp, const float& a, |
|---|
| 91 |
const float& b ) |
|---|
| 92 |
{ |
|---|
| 93 |
float size = b - a; |
|---|
| 94 |
result = a + (size * lerp); |
|---|
| 95 |
} |
|---|
| 96 |
|
|---|
| 97 |
template <typename DataType> |
|---|
| 98 |
bool vjIsEqual (const DataType& a, const DataType& b, const DataType& tolerance) |
|---|
| 99 |
{ |
|---|
| 100 |
return fabs(a - b) <= tolerance; |
|---|
| 101 |
} |
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
#endif |
|---|
| 105 |
|
|---|
| 106 |
#ifdef HAVE_UNISTD_H |
|---|
| 107 |
#include <unistd.h> |
|---|
| 108 |
#endif |
|---|
| 109 |
|
|---|
| 110 |
#ifdef HAVE_STRINGS_H |
|---|
| 111 |
#include <strings.h> |
|---|
| 112 |
#endif |
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
#ifndef HAVE_SLEEP |
|---|
| 118 |
# define sleep(x) (Sleep(x * 1000)) |
|---|
| 119 |
#endif |
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
#ifndef HAVE_USLEEP |
|---|
| 123 |
# define usleep(x) (Sleep(x / 1000)) |
|---|
| 124 |
#endif |
|---|
| 125 |
|
|---|
| 126 |
#ifndef HAVE_SINF |
|---|
| 127 |
# define sinf(x) ((float) sin(x)) |
|---|
| 128 |
#endif |
|---|
| 129 |
|
|---|
| 130 |
#ifndef HAVE_ASINF |
|---|
| 131 |
# define asinf(x) ((float) asin(x)) |
|---|
| 132 |
#endif |
|---|
| 133 |
|
|---|
| 134 |
#ifndef HAVE_COSF |
|---|
| 135 |
# define cosf(x) ((float) cos(x)) |
|---|
| 136 |
#endif |
|---|
| 137 |
|
|---|
| 138 |
#ifndef HAVE_ACOSF |
|---|
| 139 |
# define acosf(x) ((float) acos(x)) |
|---|
| 140 |
#endif |
|---|
| 141 |
|
|---|
| 142 |
#ifndef HAVE_ATAN2F |
|---|
| 143 |
# define atan2f(x, y) ((float) atan2(x, y)) |
|---|
| 144 |
#endif |
|---|
| 145 |
|
|---|
| 146 |
#ifndef HAVE_SQRTF |
|---|
| 147 |
# define sqrtf(x) ((float) sqrt(x)) |
|---|
| 148 |
#endif |
|---|
| 149 |
|
|---|
| 150 |
#ifndef HAVE_FABSF |
|---|
| 151 |
# define fabsf(x) ((float) fabs(x)) |
|---|
| 152 |
#endif |
|---|
| 153 |
|
|---|
| 154 |
#define VJ_EPS 1e-8 |
|---|
| 155 |
#define VJ_DEG2RAD(x) (x * 0.01745329252f) |
|---|
| 156 |
#define VJ_RAD2DEG(x) (x * 57.2957795131f) |
|---|
| 157 |
#define VJ_ZERO_CLAMP(x) ((fabs(x) < VJ_EPS)? 0.0f : x) |
|---|
| 158 |
#define VJ_IS_ZERO(x) (fabs(x) < VJ_EPS) |
|---|
| 159 |
#define VJ_CLAMP(x,y) ((x>y)? y : x) |
|---|
| 160 |
#define VJ_MIN2(x,y) ((x>y)? y : x) |
|---|
| 161 |
#define VJ_MIN3(x,y,z) VJ_MIN2(VJ_MIN2(x,y),z) |
|---|
| 162 |
#define VJ_MIN4(w,x,y,z) VJ_MIN2(VJ_MIN2(w,x), VJ_MIN2(y,z)) |
|---|
| 163 |
#define VJ_MAX2(x,y) ((x>y)? x : y) |
|---|
| 164 |
#define VJ_MAX3(x,y,z) VJ_MAX2(VJ_MAX2(x,y),z) |
|---|
| 165 |
#define VJ_MAX4(w,x,y,z) VJ_MAX2(VJ_MAX2(w,x),VJ_MAX2(y,z)) |
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 |
#endif |
|---|