// Do the trigonometry, applying imprecision fixes where needed.
$rad =
deg2rad($angle);
$cos =
cos($rad);
$sin =
sin($rad);
$a =
$this->width *
$cos;
$b =
$this->height *
$sin +
$correction;
$c =
$this->width *
$sin;
$d =
$this->height *
$cos +
$correction;
if ((int) $angle ==
$angle &&
in_array($angle,
[60, 150, 300
])) { $a =
$this->
fixImprecision($a,
$imprecision);
$b =
$this->
fixImprecision($b,
$imprecision);
$c =
$this->
fixImprecision($c,
$imprecision);
$d =
$this->
fixImprecision($d,
$imprecision);
} // This is how GD on PHP5.5 calculates the new dimensions.
$this->boundingWidth =
abs((int) $a) +
abs((int) $b);
$this->boundingHeight =
abs((int) $c) +
abs((int) $d);
return $this;
}