Spur Gear

gear.png

// main variables
const int zNumber = 45;
const double module = 2;
const double diametD = 37.7;
const double diametE = 25;
const double angle = 14.5;
const double G = 23; // extrusion depth
const double dp = zNumber * module;
const int involutePtsNum = 10; //number of points for drawing the spline
double arcFilletRadius = 0.3;

// derived variables
double rp = dp / 2.0; //Primitive Radius
double p = module * Math.PI;
double dext = dp + 2 * module;
double dint = dp - (2 * 1.25 * module);

// pitch circle
Circle cr1 = new Circle(Plane.XY, (dp / 2.0));
// addendum circle
Circle cr2 = new Circle(Plane.XY, (dext / 2.0));
// dedendum circle
Circle cr3 = new Circle(Plane.XY, (dint / 2.0));
// line of action
Point3D pointB = new Point3D(0, (dp / 2.0));

double tanAngle = Math.Tan(Utility.DegToRad(angle));
Line l2 = new Line(-rp, (-rp * tanAngle + rp), rp, (rp * tanAngle + rp));

// base circle construction
double t;
l2.Project(cr1.Center, out t);
Point3D pointA = l2.PointAt(t);
Line l3 = new Line(0, 0, pointA.X, pointA.Y);
double len = l3.Length();

Circle cr4 = new Circle(Plane.XY, len);

Line segmentAB = new Line(pointA, pointB);
double refLen = segmentAB.Length() / (involutePtsNum + 1);
double tA;
cr4.Project(pointA, out tA);
double beta = 2 * Math.Asin(refLen / (2 * cr4.Radius));
Point3D[] tanPt = new Point3D[(involutePtsNum * 2) + 1];

int j = 0;
for (int i = -(involutePtsNum + 1); i < involutePtsNum; i++)
{
tanPt[j] = cr4.PointAt(tA + i * beta);
j++;
}

PointTangent[] involutePts = new PointTangent[involutePtsNum * 2 + 1];
Point3D pointC = tanPt[0];
involutePts[0] = new PointTangent(pointC.X, pointC.Y, 0, Vector3D.AxisY.Z, Vector3D.AxisY.Y, 0);

Transformation rot = new Rotation(-Math.PI / 2, Vector3D.AxisZ);

for (int i = 1; i < tanPt.Length; i++)
{
cr4.Project(tanPt[i], out t);
Vector3D tan = cr4.TangentAt(t);

Vector3D normal = (Vector3D) tan.Clone();
normal.TransformBy(rot);
normal.Normalize();

Line tanLine = new Line(tanPt[i], tanPt[i] - i * refLen * tan);
involutePts[i] = new PointTangent(tanLine.EndPoint.X, tanLine.EndPoint.Y, 0, normal.X, normal.Y, 0);
}

Curve involute = Curve.LocalApproximation(involutePts, 1e-3);

Point3D[] intrUp = Curve.Intersection(cr2, involute);

Curve involuteCopy = (Curve) involute.Clone();

double tB;
cr1.Project(pointB, out tB);
double tetha = 2 * Math.Asin(p / 4 / (2 * cr1.Radius));
Point3D constructionPoint = cr1.PointAt(tB - tetha);
Line intrLine = new Line(cr1.Center, constructionPoint);
Line constructLine = new Line(pointC - involute.StartTangent * (dp / 10), pointC);
intrUp = Curve.Intersection(cr3, intrLine);
Arc constructArc = new Arc(cr3.Center, new Point3D(0, cr3.Radius), intrUp[0]);
double distanceForArcFillet = len - (dint / 2);
if (distanceForArcFillet <= 0)
{
return;
}

if (arcFilletRadius > distanceForArcFillet)
{
arcFilletRadius = distanceForArcFillet;
}

Arc fillet1;
Curve.Fillet(constructLine, constructArc, arcFilletRadius, false, true, true, true, out fillet1);
constructArc.Domain = new Interval(constructArc.Domain.t0, constructArc.Domain.t0 + constructArc.Domain.Length * 2);
Curve toothDx = (Curve)involuteCopy.Clone();
toothDx.Rotate(-(p / 4) / cr1.Radius, cr1.Plane.AxisZ, cr1.Center);
Curve toothSx = (Curve)toothDx.Clone();
toothSx.TransformBy(new Mirror(new Plane(cr1.Center, cr1.Plane.AxisY, cr1.Plane.AxisZ)));
Arc toothArcTop = new Arc(cr2.Center, toothSx.EndPoint, toothDx.EndPoint);
constructArc.Rotate(-(p / 4) / cr1.Radius, cr1.Plane.AxisZ, cr1.Center);
fillet1.Rotate(-(p / 4) / cr1.Radius, cr1.Plane.AxisZ, cr1.Center);
constructLine.Rotate(-(p / 4) / cr1.Radius, cr1.Plane.AxisZ, cr1.Center);
Line constructLineSx = (Line)constructLine.Clone();
Arc fillet2 = (Arc)fillet1.Clone();

Transformation mirror = new Mirror(Plane.YZ);

constructLineSx.TransformBy(mirror);
fillet2.TransformBy(mirror);

CompositeCurve toothContour = new CompositeCurve(constructArc, fillet1, constructLine, toothDx, toothArcTop, toothSx, constructLineSx, fillet2);
toothContour.Reverse();

CompositeCurve gearContour = new CompositeCurve();
for (int i = 0; i < zNumber; i++)
{
CompositeCurve cc = (CompositeCurve)toothContour.Clone();
cc.Rotate(p / cr1.Radius * i, Vector3D.AxisZ);
gearContour.CurveList.AddRange(cc.CurveList);
}

devDept.Eyeshot.Entities.Region gearRegion = new devDept.Eyeshot.Entities.Region(gearContour);

// Extrusion
Circle ccE = new Circle(Plane.XY, diametE / 2.0);
devDept.Eyeshot.Entities.Region regionE1 = new devDept.Eyeshot.Entities.Region(ccE);
Circle ccD = new Circle(Plane.XY, diametD / 2.0);
double difD1 = (dint - diametD) / 1.15;
Circle ccD1 = new Circle(Plane.XY, (diametD + difD1) / 2.0);
Line constructLineBase = new Line(ccD.Radius, -4, ccD1.Radius, -4);
Line constructLineLeft = new Line(ccD.Radius, -4, ccD.Radius + 0.6, G / 3);

Arc fillet3;
Line constructLineRight = new Line(ccD1.Radius - 0.6, G / 3, ccD1.Radius, -4);
Arc fillet4;
Line constructClosingLine = new Line(constructLineLeft.EndPoint, constructLineRight.StartPoint);
Curve.Fillet(constructLineLeft, constructClosingLine, 1, false, false, true, true, out fillet3);
Curve.Fillet(constructClosingLine, constructLineRight, 1, false, false, true, true, out fillet4);

CompositeCurve conicToExclude = new CompositeCurve(constructLineLeft, fillet3, constructLineBase, fillet4, constructLineRight, constructClosingLine);
conicToExclude.Rotate(Utility.DegToRad(90), Vector3D.AxisX);
devDept.Eyeshot.Entities.Region regionToRevolve = new devDept.Eyeshot.Entities.Region(conicToExclude);
Solid3D gear = gearRegion.ExtrudeAsSolid3D(Vector3D.AxisZ * G);
Circle ccToReg = new Circle(cr1.Center, diametD / 2.0 + 2);
devDept.Eyeshot.Entities.Region ccToExcl = new devDept.Eyeshot.Entities.Region(ccToReg);
gear.ExtrudeRemove(ccToExcl, G / 8);
gear.RevolveRemove(regionToRevolve, Utility.DegToRad(360), Vector3D.AxisZ, cr1.Center);
ccToExcl.Translate(0, 0, G);
gear.ExtrudeAdd(ccToExcl, G / 6);
regionToRevolve.Rotate(Utility.DegToRad(180), Vector3D.AxisX);
regionToRevolve.Translate(Vector3D.AxisZ * (G + G / 8));
gear.RevolveRemove(regionToRevolve, Utility.DegToRad(360), Vector3D.AxisZ, cr1.Center);
gear.ExtrudeRemove(regionE1, G * 2);
viewportLayout1.Entities.Add(gear, 0, Color.LightGray);
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.