environmentaltools.spatial.rotate_coords
- environmentaltools.spatial.rotate_coords(x, y, angle)[source]
Rotate coordinates by specified angle around the origin.
Performs 2D coordinate rotation transformation using angle specified in degrees. Rotation is counterclockwise for positive angles.
- Parameters:
x (float or np.ndarray) – X coordinate(s) to rotate
y (float or np.ndarray) – Y coordinate(s) to rotate
angle (float) – Rotation angle in degrees. Positive values rotate counterclockwise.
- Returns:
x_rot (float or np.ndarray) – Rotated X coordinate(s)
y_rot (float or np.ndarray) – Rotated Y coordinate(s)
Examples
>>> import numpy as np >>> x, y = 1.0, 0.0 >>> x_rot, y_rot = rotate_coords(x, y, 90) # Rotate 90 degrees >>> print(f"({x_rot:.2f}, {y_rot:.2f})") (0.00, 1.00)