/[gzz]/gzz/lava/test/gzz/loom/WheelView.test
ViewVC logotype

Diff of /gzz/lava/test/gzz/loom/WheelView.test

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by benja, Wed Feb 26 21:32:54 2003 UTC revision 1.5 by humppake, Thu Feb 27 10:18:28 2003 UTC
# Line 55  def distance(p1, p2): Line 55  def distance(p1, p2):
55  def angle(p1, p2):  def angle(p1, p2):
56      """      """
57      If p1 is the origin, return the angle between a      If p1 is the origin, return the angle between a
58      line from p1 to p2 and the x axis.      line from p1 to p2 and the x axis. The zero angle is
59        at the clock three and expands clockwise.
60      """      """
61      x, y = (p2.x-p1.x) * 1.0, (p2.y-p1.y) * 1.0      x, y = (p2.x-p1.x) * 1.0, (p2.y-p1.y) * 1.0
62      if x == 0: return math.pi/2      if x == 0 and y < 0: return math.pi * 1.5
63      return math.asin(y/x)      elif x == 0 and y == 0: return 0.0
64        elif x == 0 and y > 0: return math.pi/2
65        elif x > 0 and y < 0: return math.pi * 1.5 + math.atan(-y/x)
66        elif x > 0 and y == 0: return 0.0
67        elif x > 0 and y > 0: return math.atan(y/x)
68        elif x < 0 and y < 0: return math.pi + math.atan(-y/-x)
69        elif x < 0 and y == 0: return math.pi
70        elif x < 0 and y > 0: return math.pi/2 + math.atan(y/-x)
71    
72  def testWheel():  def testWheel():
73      r.addProperty(p, s)      r.addProperty(p, s)
# Line 82  def testWheel(): Line 89  def testWheel():
89          [vs.coords.transformPoint(cs, 0, 0, None)          [vs.coords.transformPoint(cs, 0, 0, None)
90           for cs in [cs_r, cs_s, cs_t, cs_u, cs_v, cs_w]]           for cs in [cs_r, cs_s, cs_t, cs_u, cs_v, cs_w]]
91    
92        # Check that selected nodes are drawn on same level
93    
94      assert pw.y == pr.y == ps.y      assert pw.y == pr.y == ps.y
95    
96        # Check that the positive side of the wheel seem to turn right
97    
98      assert pt.y < ps.y < pv.y      assert pt.y < ps.y < pv.y
99      assert pt.x < ps.x > pv.x      assert pt.x < ps.x > pv.x
100    
# Line 92  def testWheel(): Line 104  def testWheel():
104      for px in (pt, pu, pv, pw):      for px in (pt, pu, pv, pw):
105          assert abs(distance(pr,ps) - distance(pr,px)) < 1          assert abs(distance(pr,ps) - distance(pr,px)) < 1
106    
107      # Check the angles XXX      # Check the angles
     # This code doesn't seem to work right? XXX  
108    
109      assert angle(pr, ps) == 0      assert angle(pr, ps) == 0
110      assert angle(pr, pw) == 0      assert angle(pr, pv) == 2*math.pi/8
111      print angle(pr, pt), angle(pr, pu), angle(pr, pv)      assert angle(pr, pu) == 2*math.pi/8*2
112        assert angle(pr, pw) == math.pi
113        assert angle(pr, pt) == 2*math.pi - angle(pr, pv)
114    
115      # Test that WheelView calls its NodeView      # Test that WheelView calls its NodeView
116      # with all the correct parameters.      # with all the correct parameters.

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26