/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk

« back to all changes in this revision

Viewing changes to libssts/vec.c

  • Committer: Gustav Hartvigsson
  • Date: 2015-10-19 12:14:54 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20151019121454-aebtki6anzpc18vt
* Finnished the Vectors... For the moment.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include "vec.h"
2
2
 
3
 
Vec3 *
4
 
vec3_new (sint a, sint b, sint c) {
5
 
  Vec3 * self = malloc (sizeof (Vec3));
6
 
  self->a = a;
7
 
  self->b = b;
8
 
  self->c = c;
9
 
  return self;
10
 
}
11
 
 
12
 
Vec3_16 *
13
 
vec3_16_new (sshort a, sshort b, sshort c) {
14
 
  Vec3_16 * self = malloc (sizeof (Vec3_16));
15
 
  self->a = a;
16
 
  self->b = b;
17
 
  self->c = c;
18
 
  return self;
19
 
}
20
 
 
21
 
Vec3_f *
22
 
vec3_f_new (sfloat a, sfloat b, sfloat c) {
23
 
  Vec3_f * self = malloc (sizeof (Vec3_f));
24
 
  self->a = a;
25
 
  self->b = b;
26
 
  self->c = c;
27
 
  return self;
28
 
}
 
3
/* **************************************************************************
 
4
   **************** VEC3 (32bit int) ****************************************
 
5
   ************************************************************************** */
 
6
 
 
7
#define _V_NEW_M_(TYPE) {\
 
8
  TYPE * self = malloc (sizeof (TYPE));\
 
9
  self->a = a;\
 
10
  self->b = b;\
 
11
  self->c = c;\
 
12
  return self;\
 
13
}
 
14
 
 
15
#define _V_ADD_M_(TYPE) {\
 
16
  TYPE * new_v = malloc (sizeof (TYPE));\
 
17
  new_v->a = a->a + b->a;\
 
18
  new_v->b = a->b + b->b;\
 
19
  new_v->c = a->c + b->c;\
 
20
  return new_v;\
 
21
}
 
22
 
 
23
Vec3 *
 
24
vec3_new (sint a,
 
25
          sint b,
 
26
          sint c) {
 
27
  _V_NEW_M_(Vec3);
 
28
}
 
29
 
 
30
Vec3 *
 
31
vec3_add_vec3 (Vec3 * a,
 
32
               Vec3 * b) {
 
33
  _V_ADD_M_(Vec3);
 
34
}
 
35
 
 
36
Vec3 *
 
37
vec3_add_vec3_16 (Vec3 * a,
 
38
                  Vec3_16 * b) {
 
39
  _V_ADD_M_(Vec3);
 
40
}
 
41
 
 
42
Vec3 *
 
43
vec3_16_add_vec3 (Vec3_16 * a,
 
44
                  Vec3 * b) {
 
45
  _V_ADD_M_(Vec3);
 
46
}
 
47
 
 
48
/* **************************************************************************
 
49
   **************** VEC3_16 (16bit int) *************************************
 
50
   ************************************************************************** */
 
51
 
 
52
Vec3_16 *
 
53
vec3_16_new (sshort a,
 
54
             sshort b,
 
55
             sshort c) {
 
56
  _V_NEW_M_(Vec3_16);
 
57
}
 
58
 
 
59
Vec3_16 *
 
60
vec3_16_add_vec3_16 (Vec3_16 * a,
 
61
                     Vec3_16 * b) {
 
62
  _V_ADD_M_(Vec3_16);
 
63
}
 
64
 
 
65
 
 
66
/* **************************************************************************
 
67
   **************** VEC3_f (Float) ******************************************
 
68
   ************************************************************************** */
 
69
 
 
70
Vec3_f *
 
71
vec3_f_new (sfloat a,
 
72
            sfloat b,
 
73
            sfloat c) {
 
74
  _V_NEW_M_(Vec3_f);
 
75
}
 
76
 
 
77
Vec3_f *
 
78
vec3_f_add_vec3_f (Vec3_f * a,
 
79
                   Vec3_f * b) {
 
80
  _V_ADD_M_(Vec3_f);
 
81
}
 
82
 
 
83
Vec3_f *
 
84
vec3_f_add_vec3 (Vec3_f * a,
 
85
                 Vec3 * b) {
 
86
  _V_ADD_M_(Vec3_f);
 
87
}
 
88
 
 
89
Vec3_f *
 
90
vec3_f_add_vec3_16 (Vec3_f * a,
 
91
                    Vec3_16 * b) {
 
92
  _V_ADD_M_(Vec3_f);
 
93
}
 
94
 
 
95
Vec3_f *
 
96
vec3_add_vec3_f (Vec3 * a,
 
97
                Vec3_f * b) {
 
98
  _V_ADD_M_(Vec3_f);
 
99
}
 
100
 
 
101
Vec3_f *
 
102
vec3_16_add_vec3_f (Vec3_16 * a,
 
103
                   Vec3_f * b) {
 
104
  _V_ADD_M_(Vec3_f);
 
105
}
 
106