 
   float beta = angle; // i.e. user defined attributes for each tick
 
+  float axisAngle;
+  float clipAngle;
+  float flip;
+  
   if (enableAlign) {
-    float axisAngle = (isAxisTitle) ? HALF_PI :
+    axisAngle = (isAxisTitle) ? HALF_PI :
                       computeViewAngle(dataPosition, dataPosition + axis);
-    float clipAngle = computeViewAngle(dataPosition, dataPosition + alignDir);
+    clipAngle = computeViewAngle(dataPosition, dataPosition + alignDir);
 
     axisAngle += (sin(axisAngle) < 0.0) ? PI : 0.0;
     clipAngle += (sin(clipAngle) < 0.0) ? PI : 0.0;
 
-    float flip = (dot(vec2(cos(axisAngle), sin(axisAngle)),
+    flip = (dot(vec2(cos(axisAngle), sin(axisAngle)),
                       vec2(sin(clipAngle),-cos(clipAngle))) > 0.0) ? 1.0 : 0.0;
 
     beta += applyAlignOption(clipAngle, flip * PI);

int option = int(floor(alignOpt.x + 0.001));
float hv_ratio =       alignOpt.y;

float positive_angle(float a) {
  return (a < 0.0) ?
    a + TWO_PI :
    a;
}

float look_upwards(float a) {

}

float applyAlignOption(float rawAngle, float delta) {
  return
    (option >  2) ? look_round_n_directions(rawAngle + delta, option) :       // option 3-n: round to n directions
    (option == 2) ? look_horizontal_or_vertical(rawAngle + delta, hv_ratio) : // horizontal or vertical
    (option == 1) ? rawAngle + delta :       // use free angle, and flip to align with one direction of the axis
    (option == 0) ? look_upwards(rawAngle) : // use free angle, and stay upwards
    (option ==-1) ? 0.0 :                    // useful for backward compatibility, all texts remains horizontal
                    rawAngle;                // otherwise return back raw input angle
}

bool enableAlign = (alignDir.x != 0.0) || (alignDir.y != 0.0) || (alignDir.z != 0.0);
