chiark / gitweb /
better error handling and gsl stuff etc.
[moebius2.git] / project.c
index 521af66786895c6b7f5a51603a689cfe4db46b6a..b68e47393bb1b966579879cf0e54c0dd2513c764 100644 (file)
--- a/project.c
+++ b/project.c
@@ -15,11 +15,8 @@ static Triangle trisbuffer[MAXTRIS], *displaylist[MAXTRIS];
 static int ntris;
 static Vertices conformation;
 
-#define STATIC_MATRIX(x)                                       \
-  static double x[D3][D3];                                     \
-  static gsl_matrix x##_gsl= { D3,D3,D3,&x[0][0] };
-
-STATIC_MATRIX(transform);
+static double transform[D3][D3]= {{1,0,0}, {0,1,0}, {0,0,1}};
+STATIC_GSL_MATRIX(transform);
 
 const char *input_filename;
 
@@ -34,10 +31,16 @@ static void read_input(void) {
 }
 
 static void transform_coordinates(void) {
+  /*
+  static double result[D3];
+  static const gsl_vector result_gsl= { D3,1,&result[0]; }
+
   int v;
+  
 
   FOR_VERTEX(v) {
-  }
+    GA( gsl_blas_dgemv(CblasNoTrans,
+  }*/
 }
 
 static void addtriangle(int va, int vb, int vc) {
@@ -98,12 +101,6 @@ static double scale= 0.3;
 static double eye_z= -10, eye_x= 0;
 static double cut_z= -9;
 
-static void xdie(int l, const char *str) {
-  fprintf(stderr,"X library call failed, line %d: %s\n", l, str);
-}
-
-#define XA(w) ((w) ? (void)0 : xdie(__LINE__, #w))
-
 static void drawtriangle(const Triangle *t) {
   XPoint points[4];
   int i;
@@ -234,10 +231,14 @@ static void drag_rotate_delta(double dx, double dy) {
    * and then renormalise.
    */
 
-  STATIC_MATRIX(rotateby);
-  STATIC_MATRIX(qr);
+  static double rotateby[D3][D3]= {{1,0,0},{0,1,0},{-20,-20,1}};
+  STATIC_GSL_MATRIX(rotateby);
+
+  static double qr[D3][D3];
+  STATIC_GSL_MATRIX(qr);
+
   static double tau[D3];
-  static gsl_vector tau_gsl= { D3,1,&tau[0] };
+  STATIC_GSL_VECTOR(tau);
   
   int k;
   
@@ -245,11 +246,11 @@ static void drag_rotate_delta(double dx, double dy) {
   rotateby[0][2]= dx;
   rotateby[1][2]= dy;
   
-  gsl_blas_dgemm(CblasNoTrans,CblasNoTrans, 1.0,
-                &rotateby_gsl,&transform_gsl, 0.0,&qr_gsl);
-  gsl_linalg_QR_decomp(&qr_gsl, &tau_gsl);
-  gsl_linalg_QR_unpack(&qr_gsl, &tau_gsl,
-                      &transform_gsl, &rotateby_gsl /*dummy*/);
+  GA( gsl_blas_dgemm(CblasNoTrans,CblasNoTrans, 1.0,
+                    &rotateby_gsl,&transform_gsl, 0.0,&qr_gsl) );
+  GA( gsl_linalg_QR_decomp(&qr_gsl, &tau_gsl) );
+  GA( gsl_linalg_QR_unpack(&qr_gsl, &tau_gsl,
+                          &transform_gsl, &rotateby_gsl /*dummy*/) );
 
   printf("drag_rotate_delta...\n");
   show();
@@ -325,6 +326,7 @@ static void event_config(XConfigureEvent *e) {
 
 int main(int argc, const char *const *argv) {
   XEvent event;
+  int k;
   int motion_deferred=0, motion_x=-1, motion_y=-1;
   
   if (argc != 2 || argv[1][0]=='-') {
@@ -333,6 +335,7 @@ int main(int argc, const char *const *argv) {
   input_filename= argv[1];
 
   read_input();
+  K transform[k][k]= 1.0;
   display_prepare();
   show();