001: /*
002: * $RCSfile: SpurGearThinBody.java,v $
003: *
004: * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: *
010: * - Redistribution of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: *
013: * - Redistribution in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in
015: * the documentation and/or other materials provided with the
016: * distribution.
017: *
018: * Neither the name of Sun Microsystems, Inc. or the names of
019: * contributors may be used to endorse or promote products derived
020: * from this software without specific prior written permission.
021: *
022: * This software is provided "AS IS," without a warranty of any
023: * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
024: * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
025: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
026: * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
027: * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
028: * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
029: * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
030: * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
031: * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
032: * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
033: * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
034: * POSSIBILITY OF SUCH DAMAGES.
035: *
036: * You acknowledge that this software is not designed, licensed or
037: * intended for use in the design, construction, operation or
038: * maintenance of any nuclear facility.
039: *
040: * $Revision: 1.2 $
041: * $Date: 2007/02/09 17:21:39 $
042: * $State: Exp $
043: */
044:
045: package org.jdesktop.j3d.examples.gears;
046:
047: import java.lang.Math.*;
048: import javax.media.j3d.*;
049: import javax.vecmath.*;
050:
051: public class SpurGearThinBody extends SpurGear {
052:
053: /**
054: * Construct a SpurGearThinBody;
055: * @return a new spur gear that conforms to the input paramters
056: * @param toothCount number of teeth
057: * @param pitchCircleRadius radius at center of teeth
058: * @param shaftRadius radius of hole at center
059: * @param addendum distance from pitch circle to top of teeth
060: * @param dedendum distance from pitch circle to root of teeth
061: * @param gearThickness thickness of the gear
062: */
063: public SpurGearThinBody(int toothCount, float pitchCircleRadius,
064: float shaftRadius, float addendum, float dedendum,
065: float gearThickness) {
066: this (toothCount, pitchCircleRadius, shaftRadius, addendum,
067: dedendum, gearThickness, gearThickness, 0.25f, null);
068: }
069:
070: /**
071: * Construct a SpurGearThinBody;
072: * @return a new spur gear that conforms to the input paramters
073: * @param toothCount number of teeth
074: * @param pitchCircleRadius radius at center of teeth
075: * @param shaftRadius radius of hole at center
076: * @param addendum distance from pitch circle to top of teeth
077: * @param dedendum distance from pitch circle to root of teeth
078: * @param gearThickness thickness of the gear
079: * @param look the gear's appearance
080: */
081: public SpurGearThinBody(int toothCount, float pitchCircleRadius,
082: float shaftRadius, float addendum, float dedendum,
083: float gearThickness, Appearance look) {
084: this (toothCount, pitchCircleRadius, shaftRadius, addendum,
085: dedendum, gearThickness, gearThickness, 0.25f, look);
086: }
087:
088: /**
089: * Construct a SpurGearThinBody;
090: * @return a new spur gear that conforms to the input paramters
091: * @param toothCount number of teeth
092: * @param pitchCircleRadius radius at center of teeth
093: * @param shaftRadius radius of hole at center
094: * @param addendum distance from pitch circle to top of teeth
095: * @param dedendum distance from pitch circle to root of teeth
096: * @param gearThickness thickness of the gear
097: * @param toothTipThickness thickness of the tip of the tooth
098: * @param look the gear's appearance
099: */
100: public SpurGearThinBody(int toothCount, float pitchCircleRadius,
101: float shaftRadius, float addendum, float dedendum,
102: float gearThickness, float toothTipThickness,
103: Appearance look) {
104: this (toothCount, pitchCircleRadius, shaftRadius, addendum,
105: dedendum, gearThickness, toothTipThickness, 0.25f, look);
106: }
107:
108: /**
109: * Construct a SpurGearThinBody;
110: * @return a new spur gear that conforms to the input paramters
111: * @param toothCount number of teeth
112: * @param pitchCircleRadius radius at center of teeth
113: * @param shaftRadius radius of hole at center
114: * @param addendum distance from pitch circle to top of teeth
115: * @param dedendum distance from pitch circle to root of teeth
116: * @param gearThickness thickness of the gear
117: * @param toothTipThickness thickness of the tip of the tooth
118: * @param toothToValleyRatio ratio of tooth valley to circular pitch
119: * (must be <= .25)
120: * @param look the gear's appearance object
121: */
122: public SpurGearThinBody(int toothCount, float pitchCircleRadius,
123: float shaftRadius, float addendum, float dedendum,
124: float gearThickness, float toothTipThickness,
125: float toothToValleyAngleRatio, Appearance look) {
126:
127: this (toothCount, pitchCircleRadius, shaftRadius, addendum,
128: dedendum, gearThickness, toothTipThickness, 0.25f,
129: look, 0.6f * gearThickness,
130: 0.75f * (pitchCircleRadius - shaftRadius));
131: }
132:
133: /**
134: * Construct a SpurGearThinBody;
135: * @return a new spur gear that conforms to the input paramters
136: * @param toothCount number of teeth
137: * @param pitchCircleRadius radius at center of teeth
138: * @param shaftRadius radius of hole at center
139: * @param addendum distance from pitch circle to top of teeth
140: * @param dedendum distance from pitch circle to root of teeth
141: * @param gearThickness thickness of the gear
142: * @param toothTipThickness thickness of the tip of the tooth
143: * @param toothToValleyRatio ratio of tooth valley to circular pitch
144: * (must be <= .25)
145: * @param look the gear's appearance object
146: * @param bodyThickness the thickness of the gear body
147: * @param crossSectionWidth the width of the depressed portion of the
148: * gear's body
149: */
150: public SpurGearThinBody(int toothCount, float pitchCircleRadius,
151: float shaftRadius, float addendum, float dedendum,
152: float gearThickness, float toothTipThickness,
153: float toothToValleyAngleRatio, Appearance look,
154: float bodyThickness, float crossSectionWidth) {
155:
156: super (toothCount, pitchCircleRadius, addendum, dedendum,
157: toothToValleyAngleRatio);
158:
159: float diskCrossSectionWidth = (rootRadius - shaftRadius - crossSectionWidth) / 2.0f;
160: float outerShaftRadius = shaftRadius + diskCrossSectionWidth;
161: float innerToothRadius = rootRadius - diskCrossSectionWidth;
162:
163: // Generate the gear's body disks, first by the shaft, then in
164: // the body and, lastly, by the teeth
165: addBodyDisks(shaftRadius, outerShaftRadius, gearThickness, look);
166: addBodyDisks(innerToothRadius, rootRadius, gearThickness, look);
167: addBodyDisks(outerShaftRadius, innerToothRadius, bodyThickness,
168: look);
169:
170: // Generate the gear's "shaft" equivalents the two at the teeth
171: // and the two at the shaft
172: addCylinderSkins(innerToothRadius, gearThickness,
173: InwardNormals, look);
174: addCylinderSkins(outerShaftRadius, gearThickness,
175: OutwardNormals, look);
176:
177: // Generate the gear's interior shaft
178: addCylinderSkins(shaftRadius, gearThickness, InwardNormals,
179: look);
180:
181: // Generate the gear's teeth
182: addTeeth(pitchCircleRadius, rootRadius, outsideRadius,
183: gearThickness, toothTipThickness,
184: toothToValleyAngleRatio, look);
185: }
186:
187: }
|