Keywords: AnimatedGears.gif en Two sets of gears z<sub>1</sub> 14 red ; z<sub>2</sub> 42 blue ; z<sub>3</sub> 14 yellow ; z<sub>4</sub> 28 green de Zwei Getriebestufen mit Zahnrädern z<sub>1</sub> 14 rot ; z<sub>2</sub> 42 blau ; z<sub>3</sub> 14 gelb ; z<sub>4</Sub> 28 grün <br /> Antrieb links Abtrieb rechts<br /> i<sub>Stufe1</sub> z<sub>2</sub> / z<sub>1</sub> 42 / 14 3<br /> i<sub>Stufe2</sub> z<sub>4</sub> / z<sub>3</sub> 24 / 14 2<br /> i<sub>Ges</sub> i<sub>Stufe1</sub> · i<sub>Stufe2</sub> 6 2016-12-05 own Jahobr other versions <gallery caption> File AnimatedGears Frame1 svg static SVG version </gallery> cc-zero Jahobr function animatedGears source code for drawing gears the shape of the gears is not precise It is a hack job that produces a GIF and a SVG 2016-12-05 Jahobr teeth 14 3 14 14 2 14; modul 16 16 24 24; greenRGB 0 1 0 7 0 1; yellowRGB 1 0 7 0 ; blueRGB 0 2 0 2 1 ; redRGB 1 0 2 0 2; violetRGB 0 6 0 2 0 8; diameter modul teeth; center1 0 0; center2 diameter 1 +diameter 2 /2 0; center3 center2 1 + diameter 3 +diameter 4 /2 0; figHandle figure 15674459 ; clf axesHandle axes; hold axesHandle 'on' set figHandle 'Units' 'pixel' ; xlimValues -220 1410; ADJUST ylimValues -420 420; ADJUST set figHandle 'position' 1 1 sum abs xlimValues sum abs ylimValues ; big start image for antialiasing later x y width hight set axesHandle 'position' -0 05 -0 05 1 1 1 1 ; stetch axis bigger as figure easy way to get rid of ticks x y width hight xlim xlimValues ; ylim ylimValues ; axis equal; drawnow; nFrames 80; maxMovementOfTheSlowestTooth 2 pi/teeth 4 ; angelsSlow linspace 0 maxMovementOfTheSlowestTooth nFrames+1 ; angelsSlow angelsSlow 1 end-1 ; remove last frame it would be double secondRatio teeth 4 /teeth 3 ; angelsMedium angelsSlow secondRatio; angelsMedium angelsMedium + 2 pi/teeth 3 0 5; ALLIGNMENT; THIS MAY NEED MANUAL ADJUSTMENT firstRatio teeth 2 /teeth 1 ; angelsFast angelsMedium firstRatio; angelsFast angelsFast + 2 pi/teeth 1 0 5; ALLIGNMENT; THIS MAY NEED MANUAL ADJUSTMENT for iFrame 1 nFrames cla axesHandle drawCogWheel axesHandle center1 teeth 1 modul 1 redRGB -angelsFast iFrame ; left cogwheel fast drawCogWheel axesHandle center2 teeth 2 modul 2 blueRGB angelsMedium iFrame ; cogwheel 2 center drawCogWheel axesHandle center2 teeth 3 modul 3 yellowRGB angelsMedium iFrame ; cogwheel 3 center drawCogWheel axesHandle center3 teeth 4 modul 4 greenRGB -angelsSlow iFrame ; right cogwheel slow drawnow pause 0 01 f getframe figHandle ; f cdata imresize f cdata 0 5 ; the size reduction adds antialiasing if iFrame 1 im map rgb2ind f cdata 32 'nodither' ; 32 colores create color map im imresize im 1 ; im 1 1 1 nFrames 0; allocate plot2svg 'animatedGears_Frame1 svg' figHandle by Juerg Schwizer See http //www zhinst com/blogs/schwizer/ else imtemp rgb2ind f cdata map 'nodither' ; im 1 iFrame imtemp; end end imwrite im map 'animatedGears gif' 'DelayTime' 1/25 'LoopCount' inf save gif return function drawCogWheel axesHandle center toothNumber modul colFilling startOffset DRAWTOOTHEDWHEEL - draw a simple Toothed Wheel Input axesHandle center x y toothNumber scalar modul scalar tooth size col color of line r g b colFilling color of filling r g b startOffset start rotation scalar rad effectiveRadius modul toothNumber/2; effective effectiveRadius outsideRadius effectiveRadius+1 modul; +---+ +---+ upperRisingRadius effectiveRadius+0 5 modul; / \ / \ effective Radius / \ / \ lowerRisingRadius effectiveRadius-0 5 modul; I I I I rootRadius effectiveRadius-1 1 modul; + - - - + + - - - + + angleBetweenTeeth 2 pi/toothNumber; angle between 2 teeth angleOffPoints 0 angleBetweenTeeth/16 2 pi ; angleOffPoints angleOffPoints+startOffset; apply rotation offset angleOffPoints 7 16 end angleOffPoints 7 16 end + 1/toothNumber 1 2; hack to create smaller tooth tip angleOffPoints 11 16 end angleOffPoints 11 16 end - 1/toothNumber 1 2; hack to create smaller tooth tip angleOffPoints 8 16 end angleOffPoints 7 16 end + angleOffPoints 9 16 end /2; shift the neighbouring tip point in accordingly angleOffPoints 10 16 end angleOffPoints 11 16 end + angleOffPoints 9 16 end /2; shift the neighbouring tip point in accordingly angleOffPoints 6 16 end angleOffPoints 6 16 end + 1/toothNumber 1 7; hack to create slender upperRisingRadius angleOffPoints 12 16 end angleOffPoints 12 16 end - 1/toothNumber 1 7; hack to create slender upperRisingRadius radiusOffPoints angleOffPoints; allocate with correct site radiusOffPoints 1 16 end rootRadius; center bottom I radiusOffPoints 2 16 end rootRadius; left bottom I radiusOffPoints 3 16 end rootRadius; left bottom corner + radiusOffPoints 4 16 end lowerRisingRadius; lower rising bottom \ radiusOffPoints 5 16 end effectiveRadius; rising edge \ radiusOffPoints 6 16 end upperRisingRadius; upper rising edge \ radiusOffPoints 7 16 end outsideRadius; right top corner + radiusOffPoints 8 16 end outsideRadius; right top I radiusOffPoints 9 16 end outsideRadius; center top I radiusOffPoints 10 16 end outsideRadius; left top I radiusOffPoints 11 16 end outsideRadius; left top corner + radiusOffPoints 12 16 end upperRisingRadius; upper falling edge / radiusOffPoints 13 16 end effectiveRadius; falling edge / radiusOffPoints 14 16 end lowerRisingRadius; lower falling edge / radiusOffPoints 15 16 end rootRadius; right bottom corner + radiusOffPoints 16 16 end rootRadius; right bottom I X Y pol2cart angleOffPoints radiusOffPoints ; X X+center 1 ; center offset Y Y+center 2 ; center offset patch X Y colFilling 'EdgeColor' 0 0 0 'LineWidth' 1 0 plot axesHandle X Y '-x' 'linewidth' 2 'color' 0 0 0 ; effective Radius X Y pol2cart angleOffPoints effectiveRadius ; X X+center 1 ; center offset Y Y+center 2 ; center offset plot axesHandle X Y '- ' 'color' 0 0 0 ; shaft shaftRadius modul 6 /2; small radius assuming the effective radius a 6-tooth wheel would have X Y pol2cart angleOffPoints shaftRadius ; X X+center 1 ; center offset Y Y+center 2 ; center offset plot axesHandle X Y 'linewidth' 2 'color' 0 0 0 ; plot axesHandle center 1 center 2 ' ' 'color' 0 0 0 Animations of gears and gearboxes Animations on white background Blue green red yellow |