Because any rotation can be expressed within 360 degrees
    of any given number, and since negative angles sometimes
    are one character longer than corresponding positive angle,
    we shorten the number to one in the range to [-90, 270[.
1500
def optimizeAngle(angle):
    
    # First, we put the new angle in the range ]-360, 360[.
    # The modulo operator yields results with the sign of the
    # divisor, so for negative dividends, we preserve the sign
    # of the angle.
    if angle < 0:
        angle %= -360
    else:
        angle %= 360
    # 720 degrees is unnecessary, as 360 covers all angles.
    # As "-x" is shorter than "35x" and "-xxx" one character
    # longer than positive angles <= 260, we constrain angle
    # range to [-90, 270[ (or, equally valid: ]-100, 260]).
    if angle >= 270:
        angle -= 360
    elif angle < -90:
        angle += 360
    return angle
1201068
def radang(x, y):
    ''''''
    if x == 0:
        if y == 0:
            return 0, 0
        return abs(y), 90+180*(y<0)
    if y == 0:
        return abs(x), 180*(x<0)

    r = math.sqrt(x*x+y*y)
    a = math.degrees(math.atan(y/x))
    if x < 0:
        a += 180
    elif y < 0:
        a += 360
    return r, a
613762
function DEGtoSEC(angle) {

  // Extract DMS
  const deg = parseInt(angle, 10);
  let min = parseInt((angle - deg) * 100, 10);
  let sec = (((angle - deg) * 100) - min) * 100;

  // Avoid rounding problems with seconds=0
  const parts = String(angle).split('.');
  if (parts.length == 2 && parts[1].length == 2) {
    min = Number(parts[1]);
    sec = 0;
  }

  // Result in degrees sex (dd.mmss)
  return sec + min * 60 + deg * 3600;

}
1230918
def normalise_angle(th):
    """"""
    return th - (2.0 * np.pi) * np.floor((th + np.pi) / (2.0 * np.pi))
67025
private int chn2Num(int chr){
		int temp;
		temp=this.strDigit.indexOf(chr);
		if(temp<0)
			return -1;
		if(temp<10)
			return temp/2+1;
		else if(temp<14)
			return temp-4;
		else return 0;
	}
1229431
private void rotateNeedle(double value) {
        double startOffsetAngle = 180 - startAngle;
        double targetAngle;
        if (NeedleBehavior.STANDARD == needleBehavior) {
            if (ScaleDirection.CLOCKWISE == gauge.getScaleDirection()) {
                targetAngle = startOffsetAngle + (value - minValue) * angleStep;
                targetAngle = Helper.clamp(startOffsetAngle, startOffsetAngle + angleRange, targetAngle);
            } else {
                targetAngle = startOffsetAngle - (value - minValue) * angleStep;
                targetAngle = Helper.clamp(startOffsetAngle - angleRange, startOffsetAngle, targetAngle);
            }
        } else {
            if (value < minValue) value = maxValue - minValue + value;
            if (value > maxValue) value = value - maxValue + minValue;
            if (ScaleDirection.CLOCKWISE == gauge.getScaleDirection()) {
                targetAngle = startOffsetAngle + (value - minValue) * angleStep;
                targetAngle = Helper.clamp(startOffsetAngle, startOffsetAngle + angleRange, targetAngle);
            } else {
                targetAngle = startOffsetAngle - (value - minValue) * angleStep;
                targetAngle = Helper.clamp(startOffsetAngle - angleRange, startOffsetAngle, targetAngle);
            }
        }

        needleRotate.setAngle(targetAngle);
        valueText.setText(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), value));
        if (gauge.isLcdVisible()) {
            valueText.setTranslateX((0.691 * size - valueText.getLayoutBounds().getWidth()));
        } else {
            valueText.setTranslateX((size - valueText.getLayoutBounds().getWidth()) * 0.5);
        }

        if (gauge.isAverageVisible()) drawAverage();
    }
1325594
def preRotate(self, theta):
        """"""
        while theta < 0: theta += 360
        while theta >= 360: theta -= 360
        epsilon = 1e-5
        if abs(0 - theta) < epsilon:
            pass

        elif abs(90.0 - theta) < epsilon:
            a = self.a
            b = self.b
            self.a = self.c
            self.b = self.d
            self.c = -a
            self.d = -b

        elif abs(180.0 - theta) < epsilon:
            self.a = -self.a
            self.b = -self.b
            self.c = -self.c
            self.d = -self.d

        elif abs(270.0 - theta) < epsilon:
            a = self.a
            b = self.b
            self.a = -self.c
            self.b = -self.d
            self.c = a
            self.d = b

        else:
            rad = math.radians(theta)
            s = round(math.sin(rad), 12)
            c = round(math.cos(rad), 12)
            a = self.a
            b = self.b
            self.a = c * a + s * self.c
            self.b = c * b + s * self.d
            self.c =-s * a + c * self.c
            self.d =-s * b + c * self.d

        return self
157218
def determine_rotation(rotation, mark):
    
    if isinstance(rotation, six.string_types) and rotation.lower() == 'r':
        rotation = random.randint(0, 359)
    else:
        rotation = _int(rotation)

    return rotation
1327187
private void rotateRight(int n) {
        final int l = left(n);
        final int rl = right(l);
        left(n, rl);
        if (rl != NIL) {
            parent(rl, n);
        }
        final int p = parent(n);
        parent(l, p);
        if (p == NIL) {
            root = l;
        } else if (right(p) == n) {
            right(p, l);
        } else {
            assert left(p) == n;
            left(p, l);
        }
        right(l, n);
        parent(n, l);
        fixAggregates(n);
        fixAggregates(parent(n));
    }
1350448
function setTextRotation($angle)
    {
        switch ($angle)
        {
            case 0:
                $this->_rotation = 0;
                break;
            case 90:
                if ($this->_BIFF_version == 0x0500) {
                $this->_rotation = 3;
                } elseif ($this->_BIFF_version == 0x0600) {
                    $this->_rotation = 180;
                }
                break;
            case 270:
                if ($this->_BIFF_version == 0x0500) {
                $this->_rotation = 2;
                } elseif ($this->_BIFF_version == 0x0600) {
                    $this->_rotation = 90;
                }
                break;
            case -1:
                if ($this->_BIFF_version == 0x0500) {
                $this->_rotation = 1;
                } elseif ($this->_BIFF_version == 0x0600) {
                    $this->_rotation = 255;
                }
                break;
            default :
                return $this->raiseError("Invalid value for angle.".
                                  " Possible values are: 0, 90, 270 and -1 ".
                                  "for stacking top-to-bottom.");
                $this->_rotation = 0;
                break;
        }
    }
1130666
public void rotate180() {
    int width = getWidth();
    int height = getHeight();
    BitArray topRow = new BitArray(width);
    BitArray bottomRow = new BitArray(width);
    for (int i = 0; i < (height + 1) / 2; i++) {
      topRow = getRow(i, topRow);
      bottomRow = getRow(height - 1 - i, bottomRow);
      topRow.reverse();
      bottomRow.reverse();
      setRow(i, bottomRow);
      setRow(height - 1 - i, topRow);
    }
  }
1255558
function getTargetAngle (projection, flipped) {
    const offset = flipped ? 180 : 0
    return Math.round((projection - offset - 1) / 360) * 360 + offset
  }
343167
public function rotate($angle, $x = -1, $y = -1)
    {
        if ($x == -1) {
            $x = $this->x;
        }
        if ($y == -1) {
            $y = $this->y;
        }
        if ($this->angle!=0) {
            $this->_out('Q');
        }
        $this->angle = $angle;
        if ($angle != 0) {
            $angle*=M_PI/180;
            $c=cos($angle);
            $s=sin($angle);
            $cx=$x*$this->k;
            $cy=($this->h-$y)*$this->k;
            $this->_out(sprintf(
                'q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',
                $c,
                $s,
                -$s,
                $c,
                $cx,
                $cy,
                -$cx,
                -$cy
            ));
        }
    }
876146
def _check_rot_sym(self, axis):
        
        min_set = self._get_smallest_set_not_on_axis(axis)
        max_sym = len(min_set)
        for i in range(max_sym, 0, -1):
            if max_sym % i != 0:
                continue
            op = SymmOp.from_axis_angle_and_translation(axis, 360 / i)
            rotvalid = self.is_valid_op(op)
            if rotvalid:
                self.symmops.append(op)
                self.rot_sym.append((axis, i))
                return i
        return 1
107833
public void setTheta(double theta) {
		// Next lines are to prevent numbers like -1.8369701E-16
		// when working with negative numbers
		if ((theta < -360) || (theta > 360)) {
			theta = theta % 360;
		}
		if (theta < 0) {
			theta = 360 + theta;
		}
		double oldTheta = getTheta();
		if ((theta < -360) || (theta > 360)) {
			oldTheta = oldTheta % 360;
		}
		if (theta < 0) {
			oldTheta = 360 + oldTheta;
		}

		float len = length();
		x = len * (float) FastTrig.cos(StrictMath.toRadians(theta));
		y = len * (float) FastTrig.sin(StrictMath.toRadians(theta));
		
//		x = x / (float) FastTrig.cos(StrictMath.toRadians(oldTheta))
//				* (float) FastTrig.cos(StrictMath.toRadians(theta));
//		y = x / (float) FastTrig.sin(StrictMath.toRadians(oldTheta))
//				* (float) FastTrig.sin(StrictMath.toRadians(theta));
	}
539829
function angle(a, b) {
    var tempA = fromValues(a[0], a[1], a[2])
    var tempB = fromValues(b[0], b[1], b[2])
 
    normalize(tempA, tempA)
    normalize(tempB, tempB)
 
    var cosine = dot(tempA, tempB)

    if(cosine > 1.0){
        return 0
    } else {
        return Math.acos(cosine)
    }     
}
1252997
public function getRotation()
    {
        $rotation = $this->getAttribute('Rotate');
        if (null === $rotation) {
            return 0;
        }

        $rotation = PdfNumeric::ensure(PdfType::resolve($rotation, $this->parser))->value % 360;

        if ($rotation < 0) {
            $rotation += 360;
        }

        return $rotation;
    }