question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Affinity rotate changes angle in place

See original GitHub issue

version/platform

All from Anaconda main channel

  • Shapely 1.6.4
  • Geo’s 3.8.0
  • Python 3.7 x64
  • Windows 10 x64

Expected behavior and actual behavior.

When applying affinity rotate to line string with an angle in degrees, afterwards the variable containing angle has been permanently changed to radians.

If angle is already in radians, and use_radians=True then works as expected

Steps to reproduce the problem.

from shapely import affinity
from shapely.geometry import LineString
L = 1.6
P = 5
tracker_theta = 129.7  # degrees
tracker1 = LineString([(-L/2, 0), (L/2, 0)])
tracker1rot = affinity.rotate(
    tracker1, tracker_theta)
# tracker_theta has been permanently converted to radians
tracker2 = LineString([(P-L/2, 0), (P+L/2, 0)])
tracker2rot = affinity.rotate(
    tracker2, tracker_theta)

# tracker2rot is incorrect because use_radians is false by default, but tracker theta had been converted in place unexpectedly

Operating system

(For example, Mac OS X 10.12.3)

Shapely version and provenance

(For example, 1.6b4 installed from PyPI using pip)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sgilliescommented, Nov 22, 2019

@mikofski thanks for coming back with the crucial detail. I hadn’t considered the array.

0reactions
mikofskicommented, Nov 22, 2019

Ah, it happens when the variable is a numpy array.

try this:

>>> from shapely import affinity
>>> from shapely.geometry import LineString
>>> import numpy as np

>>> L = 1.6
>>> P = 5
>>> tracker_theta = np.array([129.7])  # degrees
>>> tracker1 = LineString([(-L/2, 0), (L/2, 0)])
>>> tracker1rot = affinity.rotate(tracker1, tracker_theta)

>>> tracker_theta
# array([2.26369204])
Read more comments on GitHub >

github_iconTop Results From Across the Web

Snap to certain angle on rotate - Affinity | Forum
Is there a way to use certain angle to snap on rotate other than every 15 ... There is no way to change...
Read more >
Rotate document view - affinity.help
-click in the Document View, then select Rotate Left or Rotate Right. The document view will be rotated in 15° increments. Alternatively, use...
Read more >
Affinity rotate changes angle in place · Issue #793 - GitHub
When applying affinity rotate to line string with an angle in degrees, afterwards the variable containing angle has been permanently changed ...
Read more >
Rotate, Zoom, Move your Canvas - Affinity Photo Tutorial
Learn to Zoom, Move and Rotate the Canvas in Affinity PhotoBuy me a Coffee: https://gumroad.com/l/coffeeforolivioMy Facebook group: ...
Read more >
Affinity Photo Turn Off Rotate Document/Canvas - YouTube
I happen to rotate the Document in Affinity Photo and did not know how to get the regular view back. After some searching...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found