Added offset
authorBill Kuker <bkuker@billkuker.com>
Tue, 8 Sep 2009 21:22:54 +0000 (21:22 +0000)
committerBill Kuker <bkuker@billkuker.com>
Tue, 8 Sep 2009 21:22:54 +0000 (21:22 +0000)
src/com/billkuker/rocketry/motorsim/grain/CSlot.java

index aa9fd62831146e103d0be8a7ab7f12f75a3b4cf5..c3154c5dd320dfcc9b2c83d54398c8cf0a8622cf 100644 (file)
@@ -22,7 +22,8 @@ public class CSlot extends ExtrudedShapeGrain implements Validating {
        private Amount<Length> iD = Amount.valueOf(0, SI.MILLIMETER);\r
        private Amount<Length> slotWidth = Amount.valueOf(5, SI.MILLIMETER);\r
        private Amount<Length> slotDepth = Amount.valueOf(15, SI.MILLIMETER);\r
-       \r
+       private Amount<Length> slotOffset = Amount.valueOf(0, SI.MILLIMETER);\r
+\r
        public CSlot(){\r
                try {\r
                        setLength(Amount.valueOf(70, SI.MILLIMETER));\r
@@ -59,8 +60,14 @@ public class CSlot extends ExtrudedShapeGrain implements Validating {
                generateGeometry();\r
        }\r
 \r
+       public Amount<Length> getSlotOffset() {\r
+               return slotOffset;\r
+       }\r
 \r
-\r
+       public void setSlotOffset(Amount<Length> slotOffset) {\r
+               this.slotOffset = slotOffset;\r
+               generateGeometry();\r
+       }\r
 \r
        private void generateGeometry() {\r
                double odmm = oD.doubleValue(SI.MILLIMETER);\r
@@ -71,15 +78,17 @@ public class CSlot extends ExtrudedShapeGrain implements Validating {
                xsection.add(outside);\r
                xsection.inhibit(outside);\r
                \r
-               double ymm = odmm/2.0 - wmm/2.0; //The Y position of the slot\r
-               double xmm = odmm - dmm;\r
+               double offmm = slotOffset.doubleValue(SI.MILLIMETER);\r
+               \r
+               double ymm = odmm/2.0 - wmm/2.0 - offmm; //The Y position of the slot\r
+               double xmm = odmm - dmm; //X pos of slot\r
                Rectangle2D.Double slot;\r
                slot = new Rectangle2D.Double(xmm, ymm, dmm, wmm);\r
                xsection.subtract(slot);\r
                \r
                double idmm = iD.doubleValue(SI.MILLIMETER);\r
-               double idymm = odmm/2.0 - idmm/2.0;\r
-               double idxmm = xmm - idmm/2.0;\r
+               double idymm = odmm/2.0 - idmm/2.0 - offmm; //y pos of id\r
+               double idxmm = xmm - idmm/2.0; //x pos of id\r
                Ellipse2D.Double id = new Ellipse2D.Double(idxmm, idymm, idmm, idmm);\r
                xsection.subtract(id);\r
                \r