Author: paperwing
Date: 2012-03-01 14:54:07 -0800 (Thu, 01 Mar 2012)
New Revision: 28410
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindVisualLexicon.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/Vector3.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/GeometryToolkit.java
Log:
Added methods to interconvert between pitch-yaw-roll and direction-up vector
pairs to prepare for storing camera orientation as pitch/yaw/roll angles in the
CyNetworkView.
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindVisualLexicon.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindVisualLexicon.java
2012-03-01 22:01:21 UTC (rev 28409)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindVisualLexicon.java
2012-03-01 22:54:07 UTC (rev 28410)
@@ -4,6 +4,7 @@
import org.cytoscape.model.CyNode;
import org.cytoscape.view.model.NullDataType;
import org.cytoscape.view.model.VisualProperty;
+import org.cytoscape.view.presentation.property.BooleanVisualProperty;
import org.cytoscape.view.presentation.property.DoubleVisualProperty;
import org.cytoscape.view.presentation.property.NullVisualProperty;
import org.cytoscape.view.presentation.property.BasicVisualLexicon;
@@ -46,7 +47,11 @@
public static final VisualProperty<Double> CAMERA_ROLL_ANGLE = new
DoubleVisualProperty(
0.0, ARBITRARY_DOUBLE_RANGE, "CAMERA_ROLL_ANGLE",
"Camera Roll Angle", CyNetwork.class);
+ public static final VisualProperty<Boolean> SHOW_NODE_LABELS = new
BooleanVisualProperty(true, "SHOW_NODE_LABELS", "Show Node Labels",
CyNetwork.class);
+ public static final VisualProperty<Boolean> SHOW_EDGE_LABELS = new
BooleanVisualProperty(true, "SHOW_EDGE_LABELS", "Show Edge Labels",
CyNetwork.class);
+
+
/** Create a new WindVisualLexicon object */
public WindVisualLexicon() {
super(WIND_ROOT);
@@ -59,6 +64,9 @@
addVisualProperty(CAMERA_YAW_ANGLE, NETWORK);
addVisualProperty(CAMERA_ROLL_ANGLE, NETWORK);
+ addVisualProperty(SHOW_NODE_LABELS, NETWORK);
+ addVisualProperty(SHOW_EDGE_LABELS, NETWORK);
+
createLookupMap();
}
@@ -74,5 +82,8 @@
addIdentifierMapping(CyNetwork.class, "cameraPitch",
CAMERA_PITCH_ANGLE);
addIdentifierMapping(CyNetwork.class, "cameraYaw",
CAMERA_YAW_ANGLE);
addIdentifierMapping(CyNetwork.class, "cameraRoll",
CAMERA_ROLL_ANGLE);
+
+ addIdentifierMapping(CyNetwork.class, "showNodeLabels",
SHOW_NODE_LABELS);
+ addIdentifierMapping(CyNetwork.class, "showEdgeLabels",
SHOW_EDGE_LABELS);
}
}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/Vector3.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/Vector3.java
2012-03-01 22:01:21 UTC (rev 28409)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/Vector3.java
2012-03-01 22:54:07 UTC (rev 28410)
@@ -6,6 +6,15 @@
*/
public class Vector3 {
+ /** A unit vector representing the direction of the positive x-axis. */
+ public static final Vector3 POSITIVE_X_DIRECTION = new Vector3(1, 0, 0);
+
+ /** A unit vector representing the direction of the positive y-axis. */
+ public static final Vector3 POSITIVE_Y_DIRECTION = new Vector3(0, 1, 0);
+
+ /** A unit vector representing the direction of the positive z-axis. */
+ public static final Vector3 POSITIVE_Z_DIRECTION = new Vector3(0, 0, 1);
+
/** The x-coordinate */
private double x;
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/GeometryToolkit.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/GeometryToolkit.java
2012-03-01 22:01:21 UTC (rev 28409)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/GeometryToolkit.java
2012-03-01 22:54:07 UTC (rev 28410)
@@ -213,4 +213,65 @@
return (horizontalFieldOfView * 180 / Math.PI);
}
+
+ /**
+ * Assuming the initial direction is towards the negative z direction,
calculate what
+ * the direction would be given pitch and yaw angles. The rotations are
done by the right-hand rule.
+ *
+ * @param pitch The pitch angle
+ * @param yaw The yaw angle
+ * @return The direction vector corresponding to the given pitch and
yaw angles.
+ */
+ public static Vector3 findDirectionVector(double pitch, double yaw) {
+ Vector3 direction = new Vector3(0, 0, -1);
+
+ // Rotate about x-axis for pitch
+ direction = direction.rotate(new Vector3(1, 0, 0), pitch);
+
+ // Rotate about y-axis for yaw
+ direction = direction.rotate(new Vector3(0, 1, 0), yaw);
+
+ return direction;
+ }
+
+ /**
+ * Assuming the initial up vector is towards the positive y direction,
calculate what the
+ * up vector would be given the roll angle. The rotations are done by
the right-hand rule.
+ *
+ * @param roll The roll angle
+ * @return The up vector corresponding to the given roll angle.
+ */
+ public static Vector3 findUpVector(double roll) {
+ Vector3 up = (new Vector3(0, 1, 0)).rotate(new Vector3(0, 0,
1), roll);
+
+ return up;
+ }
+
+ /**
+ * Given the direction and up vectors, calculate the pitch, yaw, and
roll angles assuming
+ * the initial direction is towards the negative z direction and the
initial up vector
+ * is towards the positive y direction.
+ *
+ * @param direction The direction vector
+ * @param up The up vector
+ * @return A 3-vector in the form of (pitch, yaw, roll)
+ */
+ public static Vector3 findPitchYawRoll(Vector3 direction, Vector3 up) {
+
+ double pitch, yaw, roll;
+
+ Vector3 pitchProjection = direction.projectNormal(new
Vector3(0, 1, 0));
+ pitch = direction.angleAcute(pitchProjection);
+
+ Vector3 yawProjection = direction.projectNormal(new Vector3(1,
0, 0));
+ yaw = direction.angleAcute(yawProjection);
+
+ Vector3 rollProjection = up.projectNormal(new Vector3(0, 0, 1));
+ roll = up.angleAcute(rollProjection);
+
+ // TODO: At certain orientations, the values for pitch and yaw
may be indeterminate. If pitch is 90 degrees,
+ // then it doesn't matter what yaw is.
+
+ return new Vector3(pitch, yaw, roll);
+ }
}
--
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.