-
Notifications
You must be signed in to change notification settings - Fork 0
/
vector.h
39 lines (31 loc) · 860 Bytes
/
vector.h
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
35
36
37
38
39
#ifndef VECTOR_H
#define VECTOR_H
#include "object.h"
#include "array.h"
#include <stdlib.h>
enum {
VEC_AXIS_X = 0,
VEC_AXIS_Y,
VEC_AXIS_Z,
VEC_AXIS_LAST,
};
extern size_t VEC_AXIS[VEC_AXIS_LAST];
typedef struct _VectorIF {
double (*calcDotP)(void* vec1, void* vec2);
void (*rotate3D)(void* obj, double angle, size_t axis); //3D only
void (*rotate2D)(void* obj, double angle); //2D only
double (*getLength)(void* obj);
double (*getAngle)(void* vec1, void* vec2);
}VectorIF;
typedef struct _Vector {
void* super;
void* self;
VectorIF* _VectorIF;
ArrayIF* _ArrayIF;
ObjectIF* o_IF;
}Vector;
Vector* Vector_ctor(size_t data_type, size_t dim, ...);
Vector* Vector_sum(size_t data_type, void* vec1, void* vec2);
/* MACROS */
#define _getV(data_type, ptr, index) *((data_type*)(((Vector*)ptr)->_ArrayIF->get(ptr, index)))
#endif // !VECTOR_H