remove unused stuff
This commit is contained in:
@@ -8,15 +8,12 @@
|
|||||||
*
|
*
|
||||||
****/
|
****/
|
||||||
|
|
||||||
// mathlib.c -- math primitives
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#pragma warning( disable : 4244 )
|
#pragma warning( disable : 4244 )
|
||||||
#pragma warning( disable : 4237 )
|
#pragma warning( disable : 4237 )
|
||||||
#pragma warning( disable : 4305 )
|
#pragma warning( disable : 4305 )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* #include "cmdlib.h" */
|
|
||||||
#ifndef true
|
#ifndef true
|
||||||
#define true 1
|
#define true 1
|
||||||
#endif /* true */
|
#endif /* true */
|
||||||
@@ -26,22 +23,6 @@
|
|||||||
|
|
||||||
#include "mathlib.h"
|
#include "mathlib.h"
|
||||||
|
|
||||||
//vec3_t vec3_origin = {0,0,0};
|
|
||||||
|
|
||||||
|
|
||||||
double VectorLength(vec3_t v)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
double length;
|
|
||||||
|
|
||||||
length = 0;
|
|
||||||
for (i=0 ; i< 3 ; i++)
|
|
||||||
length += v[i]*v[i];
|
|
||||||
length = sqrt (length); // FIXME
|
|
||||||
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int VectorCompare (vec3_t v1, vec3_t v2)
|
int VectorCompare (vec3_t v1, vec3_t v2)
|
||||||
{
|
{
|
||||||
@@ -56,57 +37,9 @@ int VectorCompare (vec3_t v1, vec3_t v2)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec_t Q_rint (vec_t in)
|
|
||||||
{
|
|
||||||
return floor (in + 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
void VectorMA (vec3_t va, double scale, vec3_t vb, vec3_t vc)
|
|
||||||
{
|
|
||||||
vc[0] = va[0] + scale*vb[0];
|
|
||||||
vc[1] = va[1] + scale*vb[1];
|
|
||||||
vc[2] = va[2] + scale*vb[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross)
|
|
||||||
{
|
|
||||||
cross[0] = v1[1]*v2[2] - v1[2]*v2[1];
|
|
||||||
cross[1] = v1[2]*v2[0] - v1[0]*v2[2];
|
|
||||||
cross[2] = v1[0]*v2[1] - v1[1]*v2[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
vec_t _DotProduct (vec3_t v1, vec3_t v2)
|
|
||||||
{
|
|
||||||
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
void _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out)
|
|
||||||
{
|
|
||||||
out[0] = va[0]-vb[0];
|
|
||||||
out[1] = va[1]-vb[1];
|
|
||||||
out[2] = va[2]-vb[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
void _VectorAdd (vec3_t va, vec3_t vb, vec3_t out)
|
|
||||||
{
|
|
||||||
out[0] = va[0]+vb[0];
|
|
||||||
out[1] = va[1]+vb[1];
|
|
||||||
out[2] = va[2]+vb[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
void _VectorCopy (vec3_t in, vec3_t out)
|
|
||||||
{
|
|
||||||
out[0] = in[0];
|
|
||||||
out[1] = in[1];
|
|
||||||
out[2] = in[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
void _VectorScale (vec3_t v, vec_t scale, vec3_t out)
|
|
||||||
{
|
|
||||||
out[0] = v[0] * scale;
|
|
||||||
out[1] = v[1] * scale;
|
|
||||||
out[2] = v[2] * scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
vec_t VectorNormalize (vec3_t v)
|
vec_t VectorNormalize (vec3_t v)
|
||||||
{
|
{
|
||||||
@@ -359,47 +292,4 @@ void QuaternionSlerp( const vec4_t p, vec4_t q, float t, vec4_t qt )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VecToAngles( const vec3_t value1, vec3_t angles )
|
|
||||||
{
|
|
||||||
float forward;
|
|
||||||
float yaw, pitch;
|
|
||||||
|
|
||||||
if ( value1[1] == 0 && value1[0] == 0 ) {
|
|
||||||
yaw = 0;
|
|
||||||
if ( value1[2] > 0 ) {
|
|
||||||
pitch = 90;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
pitch = 270;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if ( value1[0] ) {
|
|
||||||
yaw = ( atan2 ( value1[1], value1[0] ) * 180 / Q_PI );
|
|
||||||
}
|
|
||||||
else if ( value1[1] > 0 ) {
|
|
||||||
yaw = 90;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
yaw = 270;
|
|
||||||
}
|
|
||||||
if ( yaw < 0 ) {
|
|
||||||
yaw += 360;
|
|
||||||
}
|
|
||||||
|
|
||||||
forward = sqrt ( value1[0]*value1[0] + value1[1]*value1[1] );
|
|
||||||
pitch = ( atan2(value1[2], forward) * 180 / Q_PI );
|
|
||||||
if ( pitch < 0 ) {
|
|
||||||
pitch += 360;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
angles[0] = -pitch;
|
|
||||||
angles[1] = yaw;
|
|
||||||
angles[2] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
float AngleNormalize360 ( float angle )
|
|
||||||
{
|
|
||||||
return (360.0 / 65536) * ((int)(angle * (65536 / 360.0)) & 65535);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,23 +19,13 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DOUBLEVEC_T
|
|
||||||
typedef double vec_t;
|
|
||||||
#else
|
|
||||||
typedef float vec_t;
|
typedef float vec_t;
|
||||||
#endif
|
|
||||||
typedef vec_t vec3_t[3]; // x,y,z
|
typedef vec_t vec3_t[3]; // x,y,z
|
||||||
typedef vec_t vec4_t[4]; // x,y,z,w
|
typedef vec_t vec4_t[4]; // x,y,z,w
|
||||||
|
|
||||||
#define SIDE_FRONT 0
|
|
||||||
#define SIDE_ON 2
|
|
||||||
#define SIDE_BACK 1
|
|
||||||
#define SIDE_CROSS -2
|
|
||||||
|
|
||||||
#define Q_PI 3.14159265358979323846
|
#define Q_PI 3.14159265358979323846
|
||||||
|
|
||||||
//extern vec3_t vec3_origin;
|
|
||||||
|
|
||||||
// Use this definition globally
|
// Use this definition globally
|
||||||
#define ON_EPSILON 0.01
|
#define ON_EPSILON 0.01
|
||||||
#define EQUAL_EPSILON 0.001
|
#define EQUAL_EPSILON 0.001
|
||||||
@@ -43,25 +33,9 @@ typedef vec_t vec4_t[4]; // x,y,z,w
|
|||||||
int VectorCompare (vec3_t v1, vec3_t v2);
|
int VectorCompare (vec3_t v1, vec3_t v2);
|
||||||
|
|
||||||
#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
|
#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
|
||||||
#define VectorFill(a,b) { (a)[0]=(b); (a)[1]=(b); (a)[2]=(b);}
|
|
||||||
#define VectorAvg(a) ( ( (a)[0] + (a)[1] + (a)[2] ) / 3 )
|
|
||||||
#define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];}
|
|
||||||
#define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];}
|
|
||||||
#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];}
|
#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];}
|
||||||
#define VectorScale(a,b,c) {(c)[0]=(b)*(a)[0];(c)[1]=(b)*(a)[1];(c)[2]=(b)*(a)[2];}
|
|
||||||
|
|
||||||
vec_t Q_rint (vec_t in);
|
|
||||||
vec_t _DotProduct (vec3_t v1, vec3_t v2);
|
|
||||||
void _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out);
|
|
||||||
void _VectorAdd (vec3_t va, vec3_t vb, vec3_t out);
|
|
||||||
void _VectorCopy (vec3_t in, vec3_t out);
|
|
||||||
void _VectorScale (vec3_t v, vec_t scale, vec3_t out);
|
|
||||||
|
|
||||||
double VectorLength(vec3_t v);
|
|
||||||
|
|
||||||
void VectorMA (vec3_t va, double scale, vec3_t vb, vec3_t vc);
|
|
||||||
|
|
||||||
void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross);
|
|
||||||
vec_t VectorNormalize (vec3_t v);
|
vec_t VectorNormalize (vec3_t v);
|
||||||
void VectorInverse (vec3_t v);
|
void VectorInverse (vec3_t v);
|
||||||
|
|
||||||
@@ -81,9 +55,6 @@ void AngleQuaternion( const vec3_t angles, vec4_t quaternion );
|
|||||||
void QuaternionMatrix( const vec4_t quaternion, float (*matrix)[4] );
|
void QuaternionMatrix( const vec4_t quaternion, float (*matrix)[4] );
|
||||||
void QuaternionSlerp( const vec4_t p, vec4_t q, float t, vec4_t qt );
|
void QuaternionSlerp( const vec4_t p, vec4_t q, float t, vec4_t qt );
|
||||||
|
|
||||||
void VecToAngles( const vec3_t value1, vec3_t angles );
|
|
||||||
float AngleNormalize360 ( float angle );
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user