2008-03-25 10:02:13 +00:00
|
|
|
|
|
|
|
#ifndef __DSC_H
|
|
|
|
#define __DSC_H
|
|
|
|
|
|
|
|
typedef unsigned long DWORD;
|
|
|
|
typedef unsigned char BYTE;
|
|
|
|
|
2008-03-28 10:00:37 +00:00
|
|
|
class Vector {
|
|
|
|
public:
|
2008-03-25 10:02:13 +00:00
|
|
|
double x, y, z;
|
2008-03-27 09:53:51 +00:00
|
|
|
|
2008-04-01 10:48:44 +00:00
|
|
|
Vector Plus(Vector b);
|
|
|
|
Vector Minus(Vector b);
|
|
|
|
Vector Negated(void);
|
2008-03-27 09:53:51 +00:00
|
|
|
Vector Cross(Vector b);
|
2008-04-01 10:48:44 +00:00
|
|
|
double Dot(Vector b);
|
|
|
|
Vector Normal(int which);
|
2008-03-27 09:53:51 +00:00
|
|
|
Vector RotatedAbout(Vector axis, double theta);
|
|
|
|
double Magnitude(void);
|
|
|
|
Vector ScaledBy(double v);
|
|
|
|
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
2008-04-01 10:48:44 +00:00
|
|
|
void glVertex3v(Vector u);
|
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2008-03-28 10:00:37 +00:00
|
|
|
class Point2d {
|
|
|
|
public:
|
2008-03-27 09:53:51 +00:00
|
|
|
double x, y;
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
2008-03-27 09:53:51 +00:00
|
|
|
|
2008-03-28 10:00:37 +00:00
|
|
|
template <class T, class H>
|
|
|
|
class IdList {
|
|
|
|
public:
|
2008-03-26 09:18:12 +00:00
|
|
|
typedef struct {
|
|
|
|
T v;
|
2008-03-28 10:00:37 +00:00
|
|
|
H h;
|
2008-03-26 09:18:12 +00:00
|
|
|
int tag;
|
|
|
|
} Elem;
|
|
|
|
|
2008-03-28 10:00:37 +00:00
|
|
|
Elem *elem;
|
2008-03-26 09:18:12 +00:00
|
|
|
int elems;
|
|
|
|
int elemsAllocated;
|
|
|
|
|
2008-03-28 10:00:37 +00:00
|
|
|
void AddAndAssignId(T *v) {
|
|
|
|
int i;
|
|
|
|
int id = 0;
|
|
|
|
|
|
|
|
for(i = 0; i < elems; i++) {
|
|
|
|
id = max(id, elem[i].h.v);
|
|
|
|
}
|
|
|
|
|
|
|
|
H h;
|
|
|
|
h.v = id + 1;
|
|
|
|
AddById(v, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddById(T *v, H h) {
|
|
|
|
if(elems >= elemsAllocated) {
|
|
|
|
elemsAllocated = (elemsAllocated + 32)*2;
|
|
|
|
elem = (Elem *)realloc(elem, elemsAllocated*sizeof(elem[0]));
|
|
|
|
if(!elem) oops();
|
|
|
|
}
|
|
|
|
|
|
|
|
elem[elems].v = *v;
|
|
|
|
elem[elems].h = h;
|
|
|
|
elem[elems].tag = 0;
|
|
|
|
elems++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RemoveTagged(void) {
|
|
|
|
int src, dest;
|
|
|
|
dest = 0;
|
|
|
|
for(src = 0; src < elems; src++) {
|
|
|
|
if(elem[src].tag) {
|
|
|
|
// this item should be deleted
|
|
|
|
} else {
|
|
|
|
if(src != dest) {
|
|
|
|
elem[dest] = elem[src];
|
|
|
|
}
|
|
|
|
dest++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elems = dest;
|
|
|
|
// and elemsAllocated is untouched
|
|
|
|
}
|
|
|
|
|
|
|
|
void Clear(void) {
|
|
|
|
elemsAllocated = elems = 0;
|
|
|
|
if(elem) free(elem);
|
|
|
|
}
|
2008-03-26 09:18:12 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
#endif
|