summaryrefslogtreecommitdiff
path: root/graphics/asymptote/GUI/xasyTransform.py
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /graphics/asymptote/GUI/xasyTransform.py
Initial commit
Diffstat (limited to 'graphics/asymptote/GUI/xasyTransform.py')
-rw-r--r--graphics/asymptote/GUI/xasyTransform.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/graphics/asymptote/GUI/xasyTransform.py b/graphics/asymptote/GUI/xasyTransform.py
new file mode 100644
index 0000000000..928e9011f0
--- /dev/null
+++ b/graphics/asymptote/GUI/xasyTransform.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python3
+import xasy2asy as x2a
+import PyQt5.QtGui as Qg
+import PyQt5.QtCore as Qc
+import numpy as np
+import math
+
+
+class xasyTransform:
+ @classmethod
+ def makeRotTransform(cls, theta, origin):
+ if isinstance(origin, Qc.QPointF) or isinstance(origin, Qc.QPoint):
+ origin = (origin.x(), origin.y())
+ rotMat = (math.cos(theta), -math.sin(theta), math.sin(theta), math.cos(theta))
+ shift = x2a.asyTransform((0, 0, 1 - rotMat[0], -rotMat[1], -rotMat[2], 1 - rotMat[3])) * origin
+ return x2a.asyTransform((shift[0], shift[1], rotMat[0], rotMat[1], rotMat[2], rotMat[3]))
+
+ @classmethod
+ def makeScaleTransform(cls, sx, sy, origin):
+ if isinstance(origin, Qc.QPointF) or isinstance(origin, Qc.QPoint):
+ origin = (origin.x(), origin.y())
+ shiftMat = x2a.asyTransform((0, 0, 1 - sx, 0, 0, 1 - sy)) * origin
+ return x2a.asyTransform((shiftMat[0], shiftMat[1], sx, 0, 0, sy))
+