gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] libvob/org/nongnu/libvob/impl OrthoCoorder.java


From: Matti Katila
Subject: [Gzz-commits] libvob/org/nongnu/libvob/impl OrthoCoorder.java
Date: Sat, 05 Apr 2003 03:56:41 -0500

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Changes by:     Matti Katila <address@hidden>   03/04/05 03:56:41

Modified files:
        org/nongnu/libvob/impl: OrthoCoorder.java 

Log message:
        start buoyOnCircle + add dbg for failing test

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/impl/OrthoCoorder.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: libvob/org/nongnu/libvob/impl/OrthoCoorder.java
diff -u libvob/org/nongnu/libvob/impl/OrthoCoorder.java:1.4 
libvob/org/nongnu/libvob/impl/OrthoCoorder.java:1.5
--- libvob/org/nongnu/libvob/impl/OrthoCoorder.java:1.4 Mon Mar 17 04:55:26 2003
+++ libvob/org/nongnu/libvob/impl/OrthoCoorder.java     Sat Apr  5 03:56:41 2003
@@ -35,10 +35,10 @@
  */
 
 public class OrthoCoorder extends VobCoorder {
-public static final String rcsid = "$Id: OrthoCoorder.java,v 1.4 2003/03/17 
09:55:26 benja Exp $";
+public static final String rcsid = "$Id: OrthoCoorder.java,v 1.5 2003/04/05 
08:56:41 mudyc Exp $";
     public static boolean dbg = false;
     private static void p(String s) { if(dbg) pa(s); }
-    private static void pa(String s) { System.err.println(s); }
+    private static void pa(String s) { System.out.println("OrthoCoorder::"+s); 
}
 
     public OrthoCoorder(float width, float height) {
         this.width = width; this.height = height;
@@ -91,6 +91,9 @@
            float x=sys.cx(cs), y=sys.cy(cs), 
                    w=sys.cw(cs)*sys.w[cs], 
                    h=sys.ch(cs)*sys.h[cs];
+
+           p("contains x: "+x+", y: "+y+", w: "+w+", h: "+h);
+
            if(px >= x && py >= y &&
                px < x + w && py < y + h) {
                if(internalcoords != null) {
@@ -126,6 +129,68 @@
        return orthoBox(into, depth, x, y, sx, sy, 1, 1);
     }
 
+    /** place buoys on circle
+     * @param into the cs where to make the translation and box.
+     * @param anchor the anchor of buoy.
+     * @param cx and cy are circle's center point
+     * @param rad radius from the x, y point
+     * @param px and py is the point for affine.
+     * @param min the size of min w/h box for buoy.
+     * @param max the size of max width/height of buoy
+     *
+     * @return boxCS for buoy fragment.
+     */
+    public int buoyOnCircle(int into, int anchor, float cx, float cy, float 
rad,
+                            float px, float py, float min, float max)
+    {
+       pa("buoy..");
+
+       // check how far from center point anchor is
+       float len = 0;
+       float [] size = new float[2];
+       getSqSize(anchor, size);
+
+       float[] pt = new float[3];
+       float[] xy = transformPoints3(anchor, pt, null);
+       
+       float x = xy[0] + size[0]/2;
+       float y = xy[1] + size[1]/2;
+
+       pa("anchor x/y: "+x+"/"+y);
+
+       len = (float)Math.sqrt( (x-cx)*(x-cx) + (y-cy)*(y-cy) );
+
+       pa("len: "+len+", rad: "+rad);
+
+       // if len is longer than rad - do nothing.
+       float wh = min;
+       int cs = anchor;
+       if (len <= rad || true) { 
+           pa("in buoyCS");
+
+           // project and translate buoy
+
+           // angular coefficient
+           float ac = 1;
+           if (px-x != 0) // tan a = y/x
+               ac = (py-y)/(px-x);
+
+           cs = translate(into, (float)Math.cos(ac)*rad/2, 
+                          (float)Math.sin(ac)*rad, (len/rad)*100 );
+
+           //cs = orthoBox(0, (len/rad)*100,cx + (float)Math.cos(ac)*rad/2,
+           cs = orthoBox(0, 10f,cx + (float)Math.cos(ac)*rad/2,
+                         cy + (float)Math.sin(ac)*rad, 1,1, 50,50 );
+           // box size not counted XXX XXX
+           
+       }
+       // proper box
+       //cs = orthoBox(cs, 0, -wh/2, -wh/2, 1,1, wh,wh);
+
+       // XXX macthing?
+       return cs;
+   }
+
 
     public void setOrthoBoxParams(int cs, float depth, float x, float y, float 
sx, float sy, float w, float h) {
        if(maxdepth < depth) maxdepth = depth;
@@ -158,9 +223,9 @@
        int nsorted = sys.sorter.nsorted;
 
        for(int i=0; i<nsorted; i++) {
-           if(sys.active[sorted[i]] &&
-               contains(sorted[i], x, y, internalcoords))
-               return sorted[i];
+           if(sys.active[sorted[i]] && 
+              contains(sorted[i], x, y, internalcoords))
+               return sorted[i];
        }
        return -1;
     }




reply via email to

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