From: Bill Kuker Date: Tue, 8 Sep 2009 21:22:54 +0000 (+0000) Subject: Added offset X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=2286af9d5ec9ea2b11e647418dfda056a926e77e;p=sw%2Fmotorsim Added offset --- diff --git a/src/com/billkuker/rocketry/motorsim/grain/CSlot.java b/src/com/billkuker/rocketry/motorsim/grain/CSlot.java index aa9fd62..c3154c5 100644 --- a/src/com/billkuker/rocketry/motorsim/grain/CSlot.java +++ b/src/com/billkuker/rocketry/motorsim/grain/CSlot.java @@ -22,7 +22,8 @@ public class CSlot extends ExtrudedShapeGrain implements Validating { private Amount iD = Amount.valueOf(0, SI.MILLIMETER); private Amount slotWidth = Amount.valueOf(5, SI.MILLIMETER); private Amount slotDepth = Amount.valueOf(15, SI.MILLIMETER); - + private Amount slotOffset = Amount.valueOf(0, SI.MILLIMETER); + public CSlot(){ try { setLength(Amount.valueOf(70, SI.MILLIMETER)); @@ -59,8 +60,14 @@ public class CSlot extends ExtrudedShapeGrain implements Validating { generateGeometry(); } + public Amount getSlotOffset() { + return slotOffset; + } - + public void setSlotOffset(Amount slotOffset) { + this.slotOffset = slotOffset; + generateGeometry(); + } private void generateGeometry() { double odmm = oD.doubleValue(SI.MILLIMETER); @@ -71,15 +78,17 @@ public class CSlot extends ExtrudedShapeGrain implements Validating { xsection.add(outside); xsection.inhibit(outside); - double ymm = odmm/2.0 - wmm/2.0; //The Y position of the slot - double xmm = odmm - dmm; + double offmm = slotOffset.doubleValue(SI.MILLIMETER); + + double ymm = odmm/2.0 - wmm/2.0 - offmm; //The Y position of the slot + double xmm = odmm - dmm; //X pos of slot Rectangle2D.Double slot; slot = new Rectangle2D.Double(xmm, ymm, dmm, wmm); xsection.subtract(slot); double idmm = iD.doubleValue(SI.MILLIMETER); - double idymm = odmm/2.0 - idmm/2.0; - double idxmm = xmm - idmm/2.0; + double idymm = odmm/2.0 - idmm/2.0 - offmm; //y pos of id + double idxmm = xmm - idmm/2.0; //x pos of id Ellipse2D.Double id = new Ellipse2D.Double(idxmm, idymm, idmm, idmm); xsection.subtract(id);