summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/math.c75
1 files changed, 65 insertions, 10 deletions
diff --git a/src/math.c b/src/math.c
index 948ded8..ab4fa44 100644
--- a/src/math.c
+++ b/src/math.c
@@ -190,22 +190,24 @@ c3_s_t apply_group_relative(c3_s_t s,c3_group_rel_t *group_rel) {
//printf("# wtf?\n");
return s;
}
- if(s.len == 1) {//we're a circle. we /really/ have two points stored though.
- real dist=distance3(s.p[0],s.p[1]);
- s2.p[0]=s.p[0];
- s2.p[1]=c3_add(s.p[0],(c3_t){dist,0,0});
- }
- if(s.len > 1) {//we're a polygon.
+ //if(s.len == 1) {//we're a circle. we /really/ have two points stored though.
+ // //I'm a dummy. this was just breaking my assumptions.
+ // //real dist=distance3(s.p[0],s.p[1]);
+ // s2.p[0]=s.p[0];
+ // s2.p[1]=c3_add(s.p[0],(c3_t){dist,0,0});
+ //}
+ //if(s.len > 1) {//we're a polygon.
+ if(s.len > 0) {//we're a polygon.
for(i=0;i<s.len+(s.len==1);i++) {//apply the group's rotation and store in s2.
- if(!strcmp(s.id,global.user)) {//we need to rotate camera objects (an avatar maybe) only along the y axis, and in the opposite direction than everything else rotates
- s2.p[i]=c3_add(gr->p,rotate_c3_yr(s.p[i],(c3_t){0,0,0},d2r((degrees){0-(gr->r.y.d)})));
- } else {
+ //if(!strcmp(s.id,global.user)) {//we need to rotate camera objects (an avatar maybe) only along the y axis, and in the opposite direction than everything else rotates
+ // s2.p[i]=c3_add(gr->p,rotate_c3_yr(s.p[i],(c3_t){0,0,0},d2r((degrees){0-(gr->r.y.d)})));
+ //} else {
if(gr) {
s2.p[i]=point_apply_group_relative(s.p[i],gr);
} else {
s2.p[i]=s.p[i];
}
- }
+ //}
}
}
return s2;
@@ -325,3 +327,56 @@ int epoch_PnPoly( c2_t P, c2_t *V, int n ) {
}
return (P.x <= max.x && P.x >= min.x && P.y >= min.y && P.y <= max.y);
}
+
+/* the matrix stuff isn't actually used */
+typedef struct {
+ int h;
+ int w;
+ real d[16];//tee hee. don't make "large" matrices
+} m;
+
+void m_print(matrix m) {
+ int i,j;
+ printf("width: %d height: %d\n",m.w,m.h);
+ for(i=0;i<m.h;i++) {
+ printf("[ ");
+ for(j=0;j<m.w;j++) {
+ printf("%F ",m.d[i*m.w+j]);
+ }
+ printf("]\n");
+ }
+}
+
+///wew. I /way/ over-expanded stuff in here.
+matrix m_multiply(matrix a,matrix b) {
+ int i,j;
+ int ai,bi;
+ int ar,ac,br,bc;
+ int cr,cc;
+ if(a.w == b.h) {} else { return (matrix){-1,-1,{-1}}; }
+ matrix c={a.h,b.w,{0}};
+ int s=a.h * b.w;
+ for(i=0;i<s;i++) {
+ c.d[i]=0;
+ //printf("setting c: %d\n0 ",i);
+ for(j=0;j<a.w;j++) {//if i == 0 or 1, we want ai to be 1 2 3, if 2 3, we want ai to be 4 5 6
+
+ cr=i / c.w;
+ cc=i % c.w;
+
+ ar=cr;
+ ac=j;
+
+ br=j;
+ bc=cc;
+
+ ai=((a.w * ar) + ac);
+ bi=((b.w * br) + bc);
+
+ printf("+= a[%d] %F * b[%d] %F ",ai,a.d[ai],bi,b.d[bi]);
+ c.d[i] += a.d[ai] * b.d[bi];
+ }
+ printf("\n");
+ }
+ return c;
+}