Author: paperwing
Date: 2012-01-27 13:24:23 -0800 (Fri, 27 Jan 2012)
New Revision: 28135

Modified:
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
Log:
working coordinate generation for circular arc edges completed

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
        2012-01-27 21:06:11 UTC (rev 28134)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
        2012-01-27 21:24:23 UTC (rev 28135)
@@ -254,7 +254,9 @@
                
                double edgeRadialAngle = (double) (edgeNumber - 
Math.pow(edgeLevel, 2)) / edgesInLevel * Math.PI * 2;
 
-               return generateArcCoordinates(start, end, curvedEdgeRadius, 
edgeRadialAngle, NUM_SEGMENTS);
+               // return generateArcCoordinates(start, end, curvedEdgeRadius, 
edgeRadialAngle, NUM_SEGMENTS);
+               
+               return generateSparseArcCoordinates(start, end, 
curvedEdgeRadius, edgeRadialAngle, 0.05);
        }
        
        /**
@@ -287,10 +289,11 @@
                double rotation = arcAngle / segments;
                
                for (int i = 0; i < segments; i++) {
-                       arcCoordinates[i] = startOffset.rotate(rotationNormal, 
rotation * i);
+                       arcCoordinates[i] = 
circleCenter.plus(startOffset.rotate(rotationNormal, rotation * i));
                }
                
-               arcCoordinates[segments + 1] = end.copy();
+               arcCoordinates[arcCoordinates.length - 1] = end.copy();
+
                
                return arcCoordinates;
        }
@@ -298,7 +301,33 @@
        // Generate points along the arc, governed by the distance between 
points on the arc
        private Vector3[] generateSparseArcCoordinates(Vector3 start, Vector3 
end,
                        double radius, double angle, double distance) {
-               return new Vector3[1];
+               
+               Vector3 circleCenter = findCircleCenter(start, end, radius, 
angle);
+               Vector3 startOffset = start.subtract(circleCenter);
+               Vector3 endOffset = end.subtract(circleCenter);
+               double offsetLength = startOffset.magnitude();
+               
+               // The angular increment to achieve the desired distance 
between points on the
+               // arc. This increment is found by applying the cosine law
+               double segmentAngle = GeometryToolkit.saferArcCos(
+                               (2 * offsetLength * offsetLength - distance * 
distance) / (2 * offsetLength * offsetLength));
+               
+               double arcAngle = startOffset.angle(endOffset);
+               
+               int increments = (int) (arcAngle / segmentAngle);
+               
+               // Add 1 to include the end point
+               Vector3[] arcCoordinates = new Vector3[increments + 1]; 
+               Vector3 rotationNormal = startOffset.cross(endOffset);
+               
+               for (int i = 0; i < increments; i++) {
+                       arcCoordinates[i] = 
circleCenter.plus(startOffset.rotate(rotationNormal, segmentAngle * i));
+               }
+               
+               // Include the end point
+               arcCoordinates[arcCoordinates.length - 1] = end.copy();
+               
+               return arcCoordinates;
        }
        
        /**

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to