gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/gfx/demo vpbuoy.py


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz/gfx/demo vpbuoy.py
Date: Mon, 16 Dec 2002 10:51:26 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/12/16 10:51:26

Modified files:
        gfx/demo       : vpbuoy.py 

Log message:
        Yes, getting there with buoy geometry\!

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/vpbuoy.py.diff?tr1=1.7&tr2=1.8&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/vpbuoy.py
diff -u gzz/gfx/demo/vpbuoy.py:1.7 gzz/gfx/demo/vpbuoy.py:1.8
--- gzz/gfx/demo/vpbuoy.py:1.7  Mon Dec 16 07:52:23 2002
+++ gzz/gfx/demo/vpbuoy.py      Mon Dec 16 10:51:25 2002
@@ -38,22 +38,39 @@
                    uniform float4 origin : C1
                    ) {
                outs o;
-               float rad = 400;
+               cfloat rad = 400;
                float2 anchor = anchorPlace(orig);
 
-               float2 ap = anchor.xy - origin.xy;
+               float2 ap = anchor.xy - p.xy;
+               float2 ao = anchor.xy - origin.xy;
                float aplen = length(ap);
+               float aolen = length(ao);
                float2 apnor = ap / aplen;
 
+               float vrad = rad * (1 - .5 * (1 - aolen/rad));
+
                float2 opnor = normalize(origin.xy - p.xy);
 
+               float a = dot(ap, ap);
+               float b = 2*dot(ap, ao);
+               float c = dot(ao, ao) - vrad * vrad;
+
+               float det = b*b - 4*a*c;
+
+               bool outside = aolen > rad;
+
+               float ans = (det > 0 ? (-b + sqrt(det)) / (2*a) : 0);
+
+
                float4 buoy;
-               buoy.xy = anchor + orig.z * (10 * opnor);
+               buoy.xy = anchor + 
+                   ( outside ? orig.z * opnor * 20 
+                             : orig.z * ((ans) * ap));
                buoy.z = 1-orig.z;
                buoy.w = 1;
 
                o.pos = mul(glstate.matrix.mvp, buoy);
-               o.pointsize = float4(4. + 4. * orig.z, 0, 0, 0);
+               o.pointsize = float4(3. + 20. * orig.z * max(1-aolen/rad, 0), 
0, 0, 0);
                o.color = color;
                return o;
            }
@@ -297,7 +314,7 @@
                        Vertex %(x)s %(y)s 1 1
                    """ % locals())
        else:
-           for i in range(0,500):
+           for i in range(0,200):
                x, y = [2*java.lang.Math.random()-1 for i in (0,1)]
                vert.append("""
                    Color %(x)s .0 %(y)s .6



reply via email to

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