gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz gfx/demo/buoydev.py gfx/demo/gldemo.py doc/...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz gfx/demo/buoydev.py gfx/demo/gldemo.py doc/...
Date: Thu, 12 Sep 2002 09:04:03 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/09/12 09:04:03

Modified files:
        gfx/demo       : buoydev.py gldemo.py 
Added files:
        doc/pegboard/1005: PEG_1005.txt 
        gzz/vob/buoy   : Buoy3Floater.java 

Log message:
        A new buoy layout idea tested...

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/doc/pegboard/1005/PEG_1005.txt?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/buoydev.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/gldemo.py.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/buoy/Buoy3Floater.java?rev=1.1

Patches:
Index: gzz/gfx/demo/buoydev.py
diff -c gzz/gfx/demo/buoydev.py:1.1 gzz/gfx/demo/buoydev.py:1.2
*** gzz/gfx/demo/buoydev.py:1.1 Wed Sep 11 11:25:10 2002
--- gzz/gfx/demo/buoydev.py     Thu Sep 12 09:04:03 2002
***************
*** 1,20 ****
  from __future__ import nested_scopes
  
  from gzz.vob.buoy import NadirAngler
  import math
  
  
  class BScene:
      def __init__(self):
        self.nadiry = [1200, 1800, 4800, 20000]
        self.fsz = [1, 0.5, 0.25, 0.1]
      def key(self, key):
        if key == "n":
            rotatelist(self.nadiry)
        elif key == "f":
            rotatelist(self.fsz)
      def sq(self, vs, key, x, y, sz, color):
-       q = coloredQuad(color)
        transaffine(vs, key+"_1", x, y, sz, 0, 0, sz)
        rotate(vs, key+"_2", 
            360 * self.nadir.getAngleRad(x, y) / 
--- 1,83 ----
  from __future__ import nested_scopes
  
  from gzz.vob.buoy import NadirAngler
+ from gzz.vob.buoy import Buoy3Floater
  import math
+ from java.util import Random
  
+ rng = Random()
+ def du():
+     return rng.nextDouble()
+ def ds():
+     return rng.nextDouble() * 2 - 1
+ 
+ linecon = GZZGL.createLineConnector(0, 0)
+ 
+ # Prototype: project to a semicircle 
+ # from a point.
+ class NadirCircleFloater(Buoy3Floater):
+     def __init__(self, vs, center, radius, p, nadir):
+       self.vs, self.c, self.r, self.p, self.nadir = vs, center, radius, p, 
nadir
+     def addBuoy(self, anchorX, anchorY, importance, key, buoy, w, h):
+       size = importance
+ 
+       # 1. find the projected buoy point
+ 
+       # Vector from center to projection point
+       AmC = (self.p[0] - self.c[0], self.p[1] - self.c[1])
+ 
+       # Vector from anchor to projection point
+       v = (anchorX - self.p[0], anchorY - self.p[1])
+ 
+       # Coefficients of the 2nd degree eq
+       a = v[0]*v[0] + v[1]*v[1]
+       b = 2*(v[0]*AmC[0] + v[1]*AmC[1])
+       c = AmC[0]*AmC[0] + AmC[1]+AmC[1] - self.r**2
+ 
+       print "S: ",v,AmC,self.r, a,b,c
+ 
+       # Determinant
+       det = b**2 - 4*a*c
+       if det <= 0:
+           # For now, ignore
+           print "Ignoring ",key
+           return
+ 
+       ans = (-b + math.sqrt(det)) / (2*a)
+       print "DA: ",det,ans
+ 
+       b = (self.p[0] + ans * v[0], self.p[1] + ans * v[1])
+       print "Buoy: (%s,%s): (%s,%s)\n"%(
+           anchorX, anchorY, b[0], b[1])
+ 
+       # Create the coordinate system
+ 
+       vs = self.vs
+       transaffine(vs, str(key)+"_1", b[0], b[1], size, 0, 0, size)
+       rotate(vs, str(key)+"_2", 360 * self.nadir.getAngleRad(b[0], b[1]) / 
+                                       (2 * math.pi), 0, 0, 1)
+       buoy.run()
+       poptrans(vs, str(key)+"_2")
+       poptrans(vs, str(key)+"_1")
+ 
+       ac = vs.coords.coordsys(0, str(key)+"_5", 10, anchorX, anchorY, 0, 0)
+       bc = vs.coords.coordsys(0, str(key)+"_6", 10, b[0], b[1], 0, 0)
+       vs.map.put(linecon, ac, bc)
  
  class BScene:
      def __init__(self):
        self.nadiry = [1200, 1800, 4800, 20000]
        self.fsz = [1, 0.5, 0.25, 0.1]
+       self.q = [
+           coloredQuad((du(), du(), du()))
+           for i in range(0,10)
+       ]
      def key(self, key):
        if key == "n":
            rotatelist(self.nadiry)
        elif key == "f":
            rotatelist(self.fsz)
      def sq(self, vs, key, x, y, sz, color):
        transaffine(vs, key+"_1", x, y, sz, 0, 0, sz)
        rotate(vs, key+"_2", 
            360 * self.nadir.getAngleRad(x, y) / 
***************
*** 52,58 ****
                for y in (200, 400, 600, 800):
                    self.sq(vs, str((x,y)), x, y, 
                        30 * self.fsz[0], (1,1,1))
!       else:
            nang = 20
            for a in range(0, nang):
                angle = a / (nang+0.0) * math.pi * 2
--- 115,121 ----
                for y in (200, 400, 600, 800):
                    self.sq(vs, str((x,y)), x, y, 
                        30 * self.fsz[0], (1,1,1))
!       elif 0:
            nang = 20
            for a in range(0, nang):
                angle = a / (nang+0.0) * math.pi * 2
***************
*** 60,66 ****
                    ctrx + rad * math.sin(angle),
                    ctry + rad * math.cos(angle),
                    30 * self.fsz[0], (1,1,1))
! 
  
        
  currentScene = BScene()
--- 123,143 ----
                    ctrx + rad * math.sin(angle),
                    ctry + rad * math.cos(angle),
                    30 * self.fsz[0], (1,1,1))
!       else:
!           f = NadirCircleFloater(vs, (ctrx, ctry), rad,
!                       (ctrx+1.5*rad, ctry), self.nadir)
!           class R(Runnable):
!               def run(rself):
!                   vs.put(self.q[self.i], "XXX", 10, -20, -20, 40, 40)
!           r = R()
!           sx = 100 * ds()
!           sy = 100 * ds()
!           lr = Random(764232934)
!           for i in range(0,len(self.q)):
!               self.i = i
!               f.addBuoy( ctrx + sx + (lr.nextDouble()-.5) * rad, 
!                           ctry + sy + (lr.nextDouble()-.5)*rad,
!                           du(), "X"+str(i), r, 20, 20)
  
        
  currentScene = BScene()
Index: gzz/gfx/demo/gldemo.py
diff -c gzz/gfx/demo/gldemo.py:1.11 gzz/gfx/demo/gldemo.py:1.12
*** gzz/gfx/demo/gldemo.py:1.11 Wed Sep 11 11:25:10 2002
--- gzz/gfx/demo/gldemo.py      Thu Sep 12 09:04:03 2002
***************
*** 13,18 ****
--- 13,19 ----
  import math
  import getopt
  import gzz.util
+ import traceback
  
  System.setProperty("gzzclient", "gl")
  
***************
*** 165,172 ****
  
  def loadScenes():
      print "RELOAD"
!     exec open(scenefile) \
!       in globals(), globals()
  
  def globalkey(k):
      pass
--- 166,178 ----
  
  def loadScenes():
      print "RELOAD"
!     try:
!       exec open(scenefile) in globals(), globals()
!     except:
!       typ, val, tra = sys.exc_info()
!       l = traceback.format_list(traceback.extract_tb(tra))
!       
!       print "ERROR WHILE LOADING! %s\n%s\n"%(str(typ),str(val)), l
  
  def globalkey(k):
      pass
***************
*** 195,200 ****
--- 201,209 ----
      def generate(self):
        print "GENERATE"
        vs = w.createVobScene()
+       if not currentScene:
+           print "No scene\n"
+           return vs
        currentScene.scene(vs)
        return vs
  




reply via email to

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