Esempio n. 1
0
        private void CreateDriveTrain(params int[] teeth)
        {
            var toothSideLength     = 1.0f;
            var halfToothSideLength = toothSideLength / 2.0f;
            var toothHeight         = (float)(halfToothSideLength * Math.Sqrt(3.0f));

            Gear gear = null;

            var direction = 1;

            for (var i = 0; i < teeth.Length; i++)
            {
                var x = 0.0f;
                if (gear != null)
                {
                    x = gear.Position.X;

                    // Place the gears so that they don't touch each other
                    x += gear.OutsideDiameter / 2.0f;
                    x += (GearDescription.GetRootDiameter(toothSideLength, teeth[i]) + 2 * toothHeight) / 2.0f;

                    // Then place then almost one tooth height closer to each other so that they nicely connect
                    x -= toothHeight * 0.80f;
                }


                gear = new Gear(this.Device, toothSideLength, teeth[i], new Vector3(x, 0, 0), direction);
                this.Gears.Add(gear);


                direction = -direction;
            }
        }
Esempio n. 2
0
        private void CreateDriveTrain(float toothHeight, float profileRatio, params int[] teeth)
        {
            // TODO: find the perfect
            var x = 0.0f;

            var toothBaseWidth = 1.0f;// (startDiameter * MathHelper.Pi) / teeth[0];
            var previousRadius = 0.0f;

            for (var i = 0; i < teeth.Length; i++)
            {
                var t = teeth[i];

                // omtrek = 2 * pi * straal
                // omtrek = 2 * straal * pi
                // omtrek = diameter * pi;
                // omtrek / pi = diameter
                // diameter = omtrek / pi;

                // toothBaseWidth * t = X * pi;
                // tbwt = X * pi
                // tbwt / pi = X;

                var diameter = (toothBaseWidth * t) / MathHelper.Pi;


                if (previousRadius != 0)
                {
                    x += previousRadius + ((diameter + toothHeight) / 2.0f) - (toothHeight / 3.0f); // 2.55
                }
                previousRadius = (diameter + toothHeight) / 2.0f;

                var description = GearDescription.DescribeGear(diameter + toothHeight, diameter, t, profileRatio);

                var position = new Vector3(x, 0, 0);
                this.Gears.Add(new Gear(this.Device, description, position, i % 2 == 0 ? 1.0f : -1.0f));
            }


            //var teethA = 24;
            //var teethB = 34;

            //var ratio = teethA / (float)teethB;

            //var sizeB = 10;
            //var sizeA = sizeB * ratio;
            //{
            //    new Gear(device, GearDescription.DescribeGear(sizeA, sizeA * 0.8f, teethA, 0.02f), Vector3.Zero, 1.0f),
            //    new Gear(device, GearDescription.DescribeGear(sizeB, sizeB * 0.8f, teethB, 0.02f), Vector3.Right * 8.0f, -1.0f),
            //};
        }
Esempio n. 3
0
        public Gear(GraphicsDevice device, float toothSideLength, int teeth, Vector3 position, float direction)
        {
            this.Lines = new List <Line>();
            this.Teeth = new List <Tooth>();

            this.Device              = device;
            this.ToothSideLength     = toothSideLength;
            this.ToothHalfSideLength = toothSideLength / 2.0f;
            this.NumberOfTeeth       = teeth;
            this.Position            = position;
            this.Direction           = direction;

            var description = GearDescription.DescribeGear(toothSideLength, teeth);

            this.OutsideDiameter = description.OutsideDiameter;
            this.RootDiameter    = description.RootDiameter;

            for (var i = 0; i < teeth; i++)
            {
                var cw = CreateLine(device, position, description.ClockwiseEdges[i], Color.Blue);
                this.Lines.Add(cw);

                var ccw = CreateLine(device, position, description.CounterClockwiseEdges[i], Color.Red);
                this.Lines.Add(ccw);


                this.Teeth.Add(new Tooth(cw, ccw));
            }

            var indicatorLine = new Line(device, Color.White, Vector2.Zero, new Vector2(description.OutsideDiameter * 0.5f, 0))
            {
                Position = position
            };

            indicatorLine.Update();
            this.Lines.Add(indicatorLine);

            this.TempLine = new Line(device, Color.Yellow, Vector2.Zero, Vector2.One * 0.05f)
            {
                Position = position
            };
            this.TempLine.Update();
            this.Lines.Add(this.TempLine);
        }
Esempio n. 4
0
        public Gear(GraphicsDevice device, GearDescription description, Vector3 position, float direction)
        {
            this.Teeth = description.Teeth;
            this.Lines = new List <Line>();

            for (var i = 0; i < description.ClockwiseEdges.Count; i++)
            {
                var edge = description.ClockwiseEdges[i];
                var line = new Line(device, Color.Blue, edge.A, edge.B);
                line.Position = position;
                line.Update();
                this.Lines.Add(line);
            }

            for (var i = 0; i < description.CounterClockwiseEdges.Count; i++)
            {
                var edge = description.CounterClockwiseEdges[i];
                var line = new Line(device, Color.Red, edge.A, edge.B)
                {
                    Position = position
                };
                line.Update();
                this.Lines.Add(line);
            }

            var indicatorLine = new Line(device, Color.White, Vector2.Zero, new Vector2(description.RootDiameter * 0.5f, 0))
            {
                Position = position
            };

            indicatorLine.Update();
            this.Lines.Add(indicatorLine);


            this.Device    = device;
            this.Direction = direction;
        }