chiark / gitweb /
scale 125 seems to work ish although could be more bowl-like
[moebius2.git] / common.c
index 32701815aa753bcd1e43a4e71ee5d1cd1c43214b..bfe11b7dc23851e0e427f45533a86d9df2f0b112 100644 (file)
--- a/common.c
+++ b/common.c
@@ -5,14 +5,7 @@
 #include "common.h"
 
 double magnD(const double pq[D3]) {
-  gsl_vector v;
-
-  v.size= D3;
-  v.stride= 1;
-  v.data= (double*)pq;
-  /* owner and block ought not to be used */
-
-  return gsl_blas_dnrm2(&v);
+  return sqrt(magnD2(pq));
 }
 
 double magnD2(const double pq[D3]) {
@@ -51,12 +44,16 @@ void xprod(double r[D3], const double a[D3], const double b[D3]) {
   r[2]= a[0]*b[1] - a[1]*b[0];
 }
 
-void xprod_norm(double r[D3], const double a[D3], const double b[D3],
-               double absepsilon, double one) {
+void normalise(double v[D3], double one, double absepsilon) {
   int k;
+  double multby= one/(magnD(v) + absepsilon);
+  K v[k] *= multby;
+}
+
+void xprod_norm(double r[D3], const double a[D3], const double b[D3],
+               double one, double absepsilon) {
   xprod(r,a,b);
-  double multby= one/(magnD(r) + absepsilon);
-  K r[k] *= multby;
+  normalise(r, absepsilon, one);
 }
 
 double dotprod(const double a[D3], const double b[D3]) {
@@ -78,4 +75,4 @@ void gsldie(int l, const char *what, int status) {
 
 void diee(const char *what) { perror(what); exit(16); }
 void fail(const char *emsg) { fputs(emsg,stderr); exit(12); }
-void flushoutput(void) { if (fflush(stdout)||ferror(stdout)) diee("stdout"); }
+void flushoutput(void) { if (ferror(stdout)||fflush(stdout)) diee("stdout"); }