Transform a set of angles anchored at specific locations. Parameters ---------- angles : (N,) array-like The angles to transform. pts : (N, 2) array-like The points where the angles are anchored. radians : bool, default: False
(self, angles, pts, radians=False, pushoff=1e-5)
| 1681 | return Path._fast_from_codes_and_verts(x, path.codes, path) |
| 1682 | |
| 1683 | def transform_angles(self, angles, pts, radians=False, pushoff=1e-5): |
| 1684 | """ |
| 1685 | Transform a set of angles anchored at specific locations. |
| 1686 | |
| 1687 | Parameters |
| 1688 | ---------- |
| 1689 | angles : (N,) array-like |
| 1690 | The angles to transform. |
| 1691 | pts : (N, 2) array-like |
| 1692 | The points where the angles are anchored. |
| 1693 | radians : bool, default: False |
| 1694 | Whether *angles* are radians or degrees. |
| 1695 | pushoff : float |
| 1696 | For each point in *pts* and angle in *angles*, the transformed |
| 1697 | angle is computed by transforming a segment of length *pushoff* |
| 1698 | starting at that point and making that angle relative to the |
| 1699 | horizontal axis, and measuring the angle between the horizontal |
| 1700 | axis and the transformed segment. |
| 1701 | |
| 1702 | Returns |
| 1703 | ------- |
| 1704 | (N,) array |
| 1705 | """ |
| 1706 | # Must be 2D |
| 1707 | if self.input_dims != 2 or self.output_dims != 2: |
| 1708 | raise NotImplementedError('Only defined in 2D') |
| 1709 | angles = np.asarray(angles) |
| 1710 | pts = np.asarray(pts) |
| 1711 | _api.check_shape((None, 2), pts=pts) |
| 1712 | _api.check_shape((None,), angles=angles) |
| 1713 | if len(angles) != len(pts): |
| 1714 | raise ValueError("There must be as many 'angles' as 'pts'") |
| 1715 | # Convert to radians if desired |
| 1716 | if not radians: |
| 1717 | angles = np.deg2rad(angles) |
| 1718 | # Move a short distance away |
| 1719 | pts2 = pts + pushoff * np.column_stack([np.cos(angles), |
| 1720 | np.sin(angles)]) |
| 1721 | # Transform both sets of points |
| 1722 | tpts = self.transform(pts) |
| 1723 | tpts2 = self.transform(pts2) |
| 1724 | # Calculate transformed angles |
| 1725 | d = tpts2 - tpts |
| 1726 | a = np.arctan2(d[:, 1], d[:, 0]) |
| 1727 | # Convert back to degrees if desired |
| 1728 | if not radians: |
| 1729 | a = np.rad2deg(a) |
| 1730 | return a |
| 1731 | |
| 1732 | def inverted(self): |
| 1733 | """ |