You are here

protected function PositionedRectangle::rotatePoint in Image Effects 8.3

Same name and namespace in other branches
  1. 8 src/Component/PositionedRectangle.php \Drupal\image_effects\Component\PositionedRectangle::rotatePoint()
  2. 8.2 src/Component/PositionedRectangle.php \Drupal\image_effects\Component\PositionedRectangle::rotatePoint()

Rotates a point, by a rotation angle.

Parameters

array $point: An array of x, y coordinates.

float $angle: Rotation angle.

Return value

$this

1 call to PositionedRectangle::rotatePoint()
PositionedRectangle::rotate in src/Component/PositionedRectangle.php
Rotates the rectangle and any additional point.

File

src/Component/PositionedRectangle.php, line 324

Class

PositionedRectangle
Rectangle algebra class.

Namespace

Drupal\image_effects\Component

Code

protected function rotatePoint(array &$point, $angle) {
  $rad = deg2rad($angle);
  $sin = sin($rad);
  $cos = cos($rad);
  list($x, $y) = $point;
  $tx = round($x * $cos + $y * -$sin, 3);
  $ty = round($y * $cos - $x * -$sin, 3);
  $point[0] = $tx >= 0 ? ceil($tx) : -ceil(-$tx);
  $point[1] = $ty >= 0 ? ceil($ty) : -ceil(-$ty);
  return $this;
}