gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/lava/test/gzz/loom WheelView.test


From: Asko Soukka
Subject: [Gzz-commits] gzz/lava/test/gzz/loom WheelView.test
Date: Thu, 27 Feb 2003 05:18:29 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Asko Soukka <address@hidden>    03/02/27 05:18:28

Modified files:
        lava/test/gzz/loom: WheelView.test 

Log message:
        WheelView testangles

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/test/gzz/loom/WheelView.test.diff?tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: gzz/lava/test/gzz/loom/WheelView.test
diff -u gzz/lava/test/gzz/loom/WheelView.test:1.4 
gzz/lava/test/gzz/loom/WheelView.test:1.5
--- gzz/lava/test/gzz/loom/WheelView.test:1.4   Wed Feb 26 16:32:54 2003
+++ gzz/lava/test/gzz/loom/WheelView.test       Thu Feb 27 05:18:28 2003
@@ -55,12 +55,19 @@
 def angle(p1, p2):
     """
     If p1 is the origin, return the angle between a
-    line from p1 to p2 and the x axis.
+    line from p1 to p2 and the x axis. The zero angle is
+    at the clock three and expands clockwise.
     """
     x, y = (p2.x-p1.x) * 1.0, (p2.y-p1.y) * 1.0
-    if x == 0: return math.pi/2
-    return math.asin(y/x)
-
+    if x == 0 and y < 0: return math.pi * 1.5
+    elif x == 0 and y == 0: return 0.0
+    elif x == 0 and y > 0: return math.pi/2
+    elif x > 0 and y < 0: return math.pi * 1.5 + math.atan(-y/x)
+    elif x > 0 and y == 0: return 0.0
+    elif x > 0 and y > 0: return math.atan(y/x)
+    elif x < 0 and y < 0: return math.pi + math.atan(-y/-x)
+    elif x < 0 and y == 0: return math.pi
+    elif x < 0 and y > 0: return math.pi/2 + math.atan(y/-x)
 
 def testWheel():
     r.addProperty(p, s)
@@ -82,7 +89,12 @@
         [vs.coords.transformPoint(cs, 0, 0, None)
          for cs in [cs_r, cs_s, cs_t, cs_u, cs_v, cs_w]]
 
+    # Check that selected nodes are drawn on same level
+
     assert pw.y == pr.y == ps.y
+
+    # Check that the positive side of the wheel seem to turn right
+
     assert pt.y < ps.y < pv.y
     assert pt.x < ps.x > pv.x
 
@@ -92,12 +104,13 @@
     for px in (pt, pu, pv, pw):
         assert abs(distance(pr,ps) - distance(pr,px)) < 1
 
-    # Check the angles XXX
-    # This code doesn't seem to work right? XXX
+    # Check the angles
 
     assert angle(pr, ps) == 0
-    assert angle(pr, pw) == 0
-    print angle(pr, pt), angle(pr, pu), angle(pr, pv)
+    assert angle(pr, pv) == 2*math.pi/8
+    assert angle(pr, pu) == 2*math.pi/8*2
+    assert angle(pr, pw) == math.pi
+    assert angle(pr, pt) == 2*math.pi - angle(pr, pv)
 
     # Test that WheelView calls its NodeView
     # with all the correct parameters.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]