home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Boldly Go Collection
/
version40.iso
/
TS
/
17A
/
DRWIN101.ZIP
/
LINUTIL.H
< prev
next >
Wrap
C/C++ Source or Header
|
1991-01-04
|
3KB
|
84 lines
#ifndef __LINUTIL_H
#define __LINUTIL_H
#include <math.h>
#include <mem.h>
#ifndef PI
#define PI 3.1415926535898
#endif
typedef double vec3[3]; /*3d vector*/
typedef vec3 bas3[3]; /*3d normalized basis*/
#define EQU(a,b) memcpy((a),(b),sizeof(a)) /*c won't do vec3s*/
#define VSET(u,a,b,c) { u[0]=a; u[1]=b; u[2]=c; } /*set value of vector*/
#define DOT(u,v) (u[0]*v[0]+u[1]*v[1]+u[2]*v[2]) /*dot product of 2 vecs*/
#define NORM(u) sqrt(DOT(u,u))
#define VADD(u,v,w) /*add two vectors*/ \
{ \
w[0]=u[0]+v[0]; \
w[1]=u[1]+v[1]; \
w[2]=u[2]+v[2]; \
}
#define VSUB(u,v,w) /*subtract two vectors*/ \
{ \
w[0]=u[0]-v[0]; \
w[1]=u[1]-v[1]; \
w[2]=u[2]-v[2]; \
}
#define VNEG(u,v) /*negate a vector*/ \
{ \
v[0]=-u[0]; \
v[1]=-u[1]; \
v[2]=-u[2]; \
}
#define VMUL(a,u,v) /*multiply vector by scalar*/ \
{ \
v[0]=a*u[0]; \
v[1]=a*u[1]; \
v[2]=a*u[2]; \
}
#define VADD(u,v,w) /*add two vectors*/ \
{ \
w[0]=u[0]+v[0]; \
w[1]=u[1]+v[1]; \
w[2]=u[2]+v[2]; \
}
#define VSUB(u,v,w) /*subtract two vectors*/ \
{ \
w[0]=u[0]-v[0]; \
w[1]=u[1]-v[1]; \
w[2]=u[2]-v[2]; \
}
#define VNEG(u,v) /*negate a vector*/ \
{ \
v[0]=-u[0]; \
v[1]=-u[1]; \
v[2]=-u[2]; \
}
double *vset(vec3 u,double a,double b,double c);/*sets vector's components*/
double dot(vec3 u,vec3 v); /*returns scalar dot product*/
double *vadd(vec3 u,vec3 v,vec3 w); /*add two vectors*/
double *vsub(vec3 u,vec3 v,vec3 w); /*subtract two vectors*/
double *vneg(vec3 u,vec3 v); /*negate vector*/
double *vmul(double a,vec3 u,vec3 v); /*multiply vector by scalar*/
vec3 *rotb(double deg,int axis,bas3 b);/*rotates basis around axis*/
double *vdotb(vec3 v,bas3 b,vec3 d); /*dots v against each vector in b*/
int vangles(vec3 r,double *a1,double *a2,bas3 b); /*angles of x to y,z*/
void vcross(vec3 u,vec3 v,vec3 w); /*cross u and v into w*/
void vnormalize(vec3 v); /*normalizes to |v|=1*/
void vlookback(vec3 p,vec3 z,bas3 b); /*sets up basis to look on v, up=z*/
extern bas3 eucl3; /*euclidean 3-d basis*/
extern vec3 zero3; /*zero vector*/
#endif /*if file not already included*/