From 933f216f1101506f159cc4cb3fb484ed2892a18e Mon Sep 17 00:00:00 2001
From: Sven Buijssen <sven.buijssen@tu-dortmund.de>
Date: Mon, 13 Sep 2010 14:48:08 +0200
Subject: [PATCH 1/3] BUG: Axis of symmetry claimed to be the global z axis, but was the y-axis.

     Additionally, the code to change the axis of symmetry to be aligned with
     the global x-axis had the correct rotation formula z->x, but used the
     faulty y-axis based input and consequently did not yield a superquadric
     with an axis aligned to the global x-axis.
---
 Graphics/vtkSuperquadricSource.cxx |   30 ++++++++++++++++--------------
 1 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/Graphics/vtkSuperquadricSource.cxx b/Graphics/vtkSuperquadricSource.cxx
index 366a04e..a437150 100644
--- a/Graphics/vtkSuperquadricSource.cxx
+++ b/Graphics/vtkSuperquadricSource.cxx
@@ -274,7 +274,7 @@ int vtkSuperquadricSource::RequestData(
             thetaOffset =  0.0;
             }
 
-          //This give you superquadric with axis of symmetry: z
+          // This gives a superquadric with axis of symmetry: z
           evalSuperquadric(theta, phi,
                            thetaOffset, phiOffset,
                            this->ThetaRoundness, this->PhiRoundness,
@@ -282,16 +282,16 @@ int vtkSuperquadricSource::RequestData(
           switch (this->AxisOfSymmetry)
             {
             case 0:
-              //x-axis
-              tmp = pt[0];
+              // x-axis
+              tmp   = pt[0];
               pt[0] = pt[2];
               pt[2] = tmp;
               pt[1] = -pt[1];
 
-              tmp = nv[0];
-              nv[0]=nv[2];
-              nv[2]=tmp;
-              nv[1]=-nv[1];
+              tmp   = nv[0];
+              nv[0] = nv[2];
+              nv[2] = tmp;
+              nv[1] = -nv[1];
               break;
             case 1:
               //y-axis
@@ -315,7 +315,7 @@ int vtkSuperquadricSource::RequestData(
             // (the superquadric evaluation is numerically unstable
             // at the poles)
 
-            pt[0] = pt[2] = 0.0;
+            pt[0] = pt[1] = 0.0;
           }
 
           pt[0] += this->Center[0];
@@ -416,16 +416,18 @@ static void evalSuperquadric(double theta, double phi,  // parametric coords
                              double xyz[3],      // output coords
                              double nrm[3])      // output normals
 {
+  // axis of symmetry: z
+
   double cf1, cf2;
 
   cf1 = cf(phi, rphi, alpha);
-  xyz[0] = dims[0] * cf1 * sf(theta, rtheta);
-  xyz[1] = dims[1]       * sf(phi, rphi);
-  xyz[2] = dims[2] * cf1 * cf(theta, rtheta);
+  xyz[0] =  dims[0] * cf1 * cf(theta, rtheta);
+  xyz[1] =  dims[1] * cf1 * sf(theta, rtheta);
+  xyz[2] =  dims[2]       * sf(phi, rphi);
 
   cf2 = cf(phi+dphi, 2.0-rphi);
-  nrm[0] = 1.0/dims[0] * cf2 * sf(theta+dtheta, 2.0-rtheta);
-  nrm[1] = 1.0/dims[1]       * sf(phi+dphi, 2.0-rphi);
-  nrm[2] = 1.0/dims[2] * cf2 * cf(theta+dtheta, 2.0-rtheta);
+  nrm[0] = 1.0/dims[0] * cf2 * cf(theta+dtheta, 2.0-rtheta);
+  nrm[1] = 1.0/dims[1] * cf2 * sf(theta+dtheta, 2.0-rtheta);
+  nrm[2] = 1.0/dims[2]       * sf(phi+dphi, 2.0-rphi);
 }
 
-- 
1.7.2.2

