POV-Ray : Newsgroups : povray.text.scene-files : Unknown pixelation at high quality. Server Time
28 Mar 2024 08:22:15 EDT (-0400)
  Unknown pixelation at high quality. (Message 1 to 1 of 1)  
From: Bald Eagle
Subject: Unknown pixelation at high quality.
Date: 31 Jul 2013 16:30:01
Message: <web.51f972ef7c2412d273fc9ebb0@news.povray.org>
It looked ok at Q=5 with DTA, but at Q=10 it has a lot of weird effects.
I'll look into some suggestions and see if that helps fix the problem.


//

global_settings{
assumed_gamma 2 // change if the image is too pale
radiosity{ recursion_limit 1 }
}


//  Include Files

#include "colors.inc"
#include "textures.inc"
#include "metals.inc"
#include "woods.inc"
#include "stones1.inc"
#include "debug.inc"
#include "shapes.inc"
#include "functions.inc"

Set_Debug (true)

// Light Sources

//light_source{ <0, 200, 100> color rgb<1, 1, 1>}

#declare Light1 = <0, 80, 10>;
#declare Target1 = <0, 24, -24>;
#declare Light2 = <0, 80, 60>;   // rotated 120
#declare Target2 = <10, 0, 12>;
#declare Light3 = <0, 80, 60>;  // rotated 240
#declare Target3 = <0, 0, 12>;
#declare Light4 = <-50, 80, 12>; // Highlight Coupling
#declare Target4 = <0, 40, 6>;

light_source{ Light1
color White
spotlight
radius 30
falloff 90
tightness 50
point_at Target1
}
//cylinder { Light1, Target1, 0.1 pigment {color Yellow transmit 0.8}}

light_source{ Light2
color White * 0.6
spotlight
radius 30
falloff 90
tightness 50
rotate y*120
point_at Target2
}
//cylinder { Light2, Target2, 0.5 rotate y*120 pigment {color Yellow transmit
0.8}}

light_source{ Light3
color White*0.6
spotlight
radius 30
falloff 90
tightness 50
rotate y*240
point_at Target3
}
//cylinder { Light3, Target3, 0.1 rotate y*240 pigment {color Yellow transmit
0.8}}

light_source{ Light4
color White
spotlight
radius 30
falloff 90
tightness 50
point_at Target4
//fade_distance 5
//fade_power 2
//circular
//orient
//adaptive 0
}
//cylinder { Light4, Target4, 0.1 pigment {color Yellow transmit 0.8}}

// An area light (creates soft shadows)
// WARNING: This special light can significantly slow down rendering times!
light_source {
  0*x                 // light's position (translated below)
  color rgb 1.0       // light's color
  area_light
  <8, 0, 0> <0, 0, 8> // lights spread out across this distance (x * z)
  4, 4                // total number of lights in grid (4x*4z = 16 lights)
  adaptive 0          // 0,1,2,3...
  jitter              // adds random softening of light
  circular            // make the shape of the light circular
  orient              // orient light
  translate <-40, 80, 0>   // <x y z> position of light
}


/* sky -------------------------------------------------------------------
sky_sphere{ pigment{ gradient <0,1,0>
                     color_map{ [0   color rgb<1,1,1>]
                                [0.4 color rgb<1,1,1>]
                                [0.6 color rgb<1,1,1>]
                                [1.0 color rgb<1,1,1>]
                              }
                     scale 2 }
           }  end of sky_sphere  */

  sky_sphere {
    pigment {
      gradient y
      color_map {
        [ 1.0  color White ]
        [ 0.5  color CornflowerBlue ]
      }
      scale 2
      translate -1
    }
  }


/*plane {y,0
pigment { color Gray90}
//pigment { color Cyan} normal {quilted .1 scale 20 }
//pigment{ brick White, Blue brick_size <10, 1, 10> mortar 0.5 }
}  */

cylinder { <0,0,0>, <0,-1,0>, 40 texture {pigment { color Gray90} normal
{granite 0.2}}}



//------------------------------------------------------------------------


// labeled axes

#declare dia = 20;
#declare len = 20;
#declare letters = 5;

#declare refs = union {
sphere {<0,0,0> 2}


torus { dia, 0.5}
cylinder { <0,0,0>, <0,0,dia>, 0.5}
text { ttf "arial.ttf" "0" 0.1, 0 scale letters translate <0, 0, dia+5>}

cylinder { <0,0,0>, <dia,0,0>, 0.5 rotate y*120}
text { ttf "arial.ttf" "120" 0.1, 0 scale letters translate <0, 0, dia+5> rotate
y*120}

cylinder { <0,0,0>, <dia,0,0>, 0.5 rotate y*240}
text { ttf "arial.ttf" "240" 0.1, 0 scale letters translate <0, 0, dia+5> rotate
y*240}

cylinder { <2*dia,0,0>, <2*dia+len,0,0>, 0.5}
cone { <2*dia+len,0,0>, 1, <2*dia+len+2,0,0>, 0}
text { ttf "arial.ttf" "+x"
0.1,    // extrusion depth
0     // spacing between characters (default = 0)
scale letters
rotate -y*45
translate <2*dia+len+5, 0, 0>
no_shadow
}

cylinder { <2*dia, 5, 0>, <2*dia, 5+len, 0>, 0.5 no_shadow}
cone { <2*dia, 5+len, 0>, 1, <2*dia, 5+len+2, 0>, 0}
text { ttf "arial.ttf" "+y"
0.1,    // extrusion depth
0     // spacing between characters (default = 0)
scale letters
rotate -y*45
translate <2*dia, 5+len+5, 0>
no_shadow
}

cylinder { <2*dia, 0, 5>, <2*dia, 0, 5+len>, 0.5}
cone { <2*dia, 0, 5+len>, 1, <2*dia, 0, 5+len+2>, 0}
text { ttf "arial.ttf" "+z"
0.1,    // extrusion depth
0     // spacing between characters (default = 0)
scale letters
rotate -y*45
translate <2*dia+5, 0, len>
no_shadow
}
}

//object {refs}

// Variables


#declare Frame_Width = 18;
#declare Frame_Height = 48;
#declare Frame_Depth = 24;
#declare Frame_Thickness = 0.75;
#declare Small_Radius = 2;
#declare Big_Radius = 9;
#declare Belt_width = 1;
#declare Top = Frame_Height- 2 - Small_Radius;
#declare Bottom = 18;

#declare Alternator_Dia = 4;
#declare Alternator_Offset =
Frame_Width/2+Alternator_Dia/2+Small_Radius+Belt_width/2;
#declare Alternator_height = Bottom+10;
#declare P = sqrt ((Top-Bottom)*(Top-Bottom) - (Alternator_Offset *
Alternator_Offset));
#declare theta = 2*acos ((Big_Radius - Small_Radius)/P);
#declare theta_d = degrees(theta);
#declare belt_length = 2*P*sin(theta/2);
#declare belt_angle = degrees(asin (Alternator_Offset/P));
#declare P2 = Top-(Bottom+5);
#declare theta2 = 2*acos ((Big_Radius - Small_Radius)/P2);
#declare theta2_d = degrees(theta2);
#declare belt_length2 = 2*P2*sin(theta2/2);

#declare rotation = clock*360;
#declare StepUp1 = rotation*(Big_Radius/Small_Radius);
#declare StepUp2 = StepUp1*(Big_Radius/Small_Radius);

#declare rotationAngle = radians(rotation);
#debug concat("  clock = ", str(clock, 3,4))
#debug "\n"
#debug concat("  rotation = ", str(rotation, 3,4))
#debug "\n"
#debug concat("  rotationAngle = ", str(rotationAngle, 3,4))
#debug "\n"
#declare Vertical_Displacement = 4/2;
#declare Inset = 1;
#declare PistonRod = (2*Vertical_Displacement)+Inset+4;
#declare CW_rad = Inset+Vertical_Displacement;

#declare rotation2 = rotation+90;
#declare rotation3 = rotation+180;
#declare rotation4 = rotation+270;

#declare rotationAngle =radians(rotation);
#declare rotationAngle2=radians(rotation2);
#declare rotationAngle3=radians(rotation3);
#declare rotationAngle4=radians(rotation4);

#declare rodRotation1 = asin(Vertical_Displacement*sin(rotationAngle
)/PistonRod);
#declare rodRotation2 =
asin(Vertical_Displacement*sin(rotationAngle2)/PistonRod);
#declare rodRotation3 =
asin(Vertical_Displacement*sin(rotationAngle3)/PistonRod);
#declare rodRotation4 =
asin(Vertical_Displacement*sin(rotationAngle4)/PistonRod);

#declare Inset1   = 0;//Inset*cos(rotationAngle );
#declare Inset2   = 0;//Inset*cos(rotationAngle2);
#declare Inset3   = 0;//Inset*cos(rotationAngle3);
#declare Inset4   = 0;//Inset*cos(rotationAngle4);

#declare stroke1 = Vertical_Displacement*-cos(rotationAngle );
#declare stroke2 = Vertical_Displacement*-cos(rotationAngle2);
#declare stroke3 = Vertical_Displacement*-cos(rotationAngle3);
#declare stroke4 = Vertical_Displacement*-cos(rotationAngle4);
#declare Treadle_thickness = 1.5;
#declare Pivot = Frame_Width/2-1;
#declare Pivot_Height =
5+Bottom-(Vertical_Displacement/2)-PistonRod-4-Treadle_thickness+2;
#declare Treadle_Height = Pivot_Height+0.5;
//Bottom+5-PistonRod-4+(stroke1+stroke4)/2;
#declare Treadle_Angle = degrees( atan2 (
(Bottom+5-PistonRod-4+stroke4)-(Pivot_Height+Treadle_thickness), Pivot ) );

#declare Battery_Size = <8, 7.75, 6.75>;

#declare length = 2;
#declare tpi = -1/5;
#declare OD = 0.25;
#declare ID = OD/3;
#declare nutsize = 1;

#declare Exploded1 = 0; // 0 = Normal View, 1 = Exploded diagram with arrows
#declare Exp_coupling = 8;
#declare Exp_nut = 2;
#declare Exp_bolt = 5;
#declare Exp_shaft = 12;
//  Camera Positions

#declare View = array[9][6]                                      // Array [Rows]
[Columns]
 {
  {-270, 80, 90, 50, 17, -12},                                        // CAMERA
[0] = View from LEFT FRONT
  {-5, 200, 4, 0, 50, 2},                                             // CAMERA
[1] = View from TOP
  {270, 80, -120, -50, 17, 12},                                       // CAMERA
[2] = View from Angle REAR
  {0, 60, 250, 0, Top, 0},                                     // CAMERA [3] =
View from TREADLE FRONT
  {Battery_Size.x*9, 100, -12, Battery_Size.x*1.5, 0, -12},      // CAMERA [4] =
Look at Battery
  {-40, 22, -6, 4, 25, -12},                                          // CAMERA
[5] = ZOOM into Engine
  {0, Top, -250, 0, Bottom, 0},                                    // CAMERA [6]
= View from TREADLE Rear
  {-60, 90, 65, 0, 45, 4}                                             // CAMERA
[7] = ZOOM onto Pulley connection
  {0, 60, 150, 0, 0, 10},                                     // CAMERA [8] =
Look at TOOLS
 }

#declare Camera = 0;

#declare Camera_Selected =
camera {
        angle 15
        location  <View [Camera] [0], View [Camera] [1], View [Camera] [2]>
        right     -x*image_width/image_height
        look_at   <View [Camera] [3], View [Camera] [4], View [Camera] [5]>}

camera { Camera_Selected }

#declare Angle2Origin = atan2d((View [Camera] [0] - View [Camera] [3]), (View
[Camera] [2] - View [Camera] [5]));
//#declare VAngle = atan2d((View [Camera] [0] - View [Camera] [3]), (View
[Camera] [1] - View [Camera] [4]));
#debug concat("  Camera Angle = ", str(Angle2Origin, 3,4))
#debug "\n"
#declare Text_size = 2.5;
#declare Text_line = Top+8;
text { ttf "arial.ttf" "Treadle Powered Generator" 0.1, 0 scale Text_size rotate
y*Angle2Origin translate <0, Text_line, 10>}
#declare Text_line = Text_line - Text_size;
text { ttf "arial.ttf" "Design by Pat Delany" 0.1, 0 scale Text_size rotate
y*Angle2Origin translate <0, Text_line, 10>}
#declare Text_line = Text_line - Text_size;
#declare Text_line = Text_line - Text_size;
text { ttf "arial.ttf" "Model and animation by" 0.1, 0 scale Text_size rotate
y*Angle2Origin translate <0, Text_line, 10>}
#declare Text_line = Text_line - Text_size;
text { ttf "arial.ttf" "Bill Walker" 0.1, 0 scale Text_size rotate
y*Angle2Origin translate <0, Text_line, 10>}
#declare Text_line = Text_line - Text_size;
text { ttf "arial.ttf" "using POV-Ray and" 0.1, 0 scale Text_size rotate
y*Angle2Origin translate <0, Text_line, 10>}
#declare Text_line = Text_line - Text_size;
text { ttf "arial.ttf" "Dave's Targa Animator" 0.1, 0 scale Text_size rotate
y*Angle2Origin translate <0, Text_line, 10>}
#declare Text_line = Text_line - Text_size;
#declare Text_line = Text_line - Text_size;
text { ttf "arial.ttf" "opensourcemachinetools.org" 0.1, 0 scale Text_size
rotate y*Angle2Origin translate <0, Text_line, 10>}
#declare Text_line = Text_line - Text_size;
#declare Text_line = Text_line - Text_size;
text { ttf "arial.ttf" "Special thanks to:" 0.1, 0 scale Text_size rotate
y*Angle2Origin translate <0, Text_line, 10>}
#declare Text_line = Text_line - Text_size;
text { ttf "arial.ttf" "Friederich A. Lohmueller" 0.1, 0 scale Text_size rotate
y*Angle2Origin translate <0, Text_line, 10>}
#declare Text_line = Text_line - Text_size;
text { ttf "arial.ttf" "Rune Skovbo Johansen" 0.1, 0 scale Text_size rotate
y*Angle2Origin translate <0, Text_line, 10>}
#declare Text_line = Text_line - Text_size;
text { ttf "arial.ttf" "Dave Mason" 0.1, 0 scale Text_size rotate y*Angle2Origin
translate <0, Text_line, 10>}
#declare Text_line = Text_line - Text_size;
text { ttf "arial.ttf" "                       Henry Walker" 0.1, 0 scale
Text_size rotate y*Angle2Origin translate <0, Text_line, 10>}
#declare Text_line = Text_line - Text_size;
text { ttf "arial.ttf" "                       Peter Walker" 0.1, 0 scale
Text_size rotate y*Angle2Origin translate <0, Text_line, 10>}
#declare Text_line = Text_line - Text_size;
text { ttf "arial.ttf" "                       Laura Simms" 0.1, 0 scale
Text_size rotate y*Angle2Origin translate <0, Text_line, 10>}
#declare Text_line = Text_line - Text_size;
text { ttf "arial.ttf" "                       Andrew Lagos" 0.1, 0 scale
Text_size rotate y*Angle2Origin translate <0, Text_line, 10>}
#declare Text_line = Text_line - Text_size;


/*box { <-50, 0, -50> <100, 100, -50>
pigment {
        image_map { "Background.bmp"} scale <100, 100, 1>} rotate -y*45}
*/

// Textures

#declare Board =
texture {
        pigment {
                wood
                color_map {
                        [.4 rgb <.84, .73, .6>]
                        [.6 rgb <.8, .7, .6>]
                        }
                        quick_color Brown
                }
                normal {
                        average
                        normal_map {
                                [1 wood .4
                                slope_map {
                                        [0.0 <0.0, 0>]
                                        [0.5 <0.5, 1>]
                                        [1.0 <1.0, 0>]
                                        }
                                turbulence .5
                                scale <10,10, 1>*10
                                rotate y*90]
                                [1 wood .6
                                slope_map {
                                        [0 <0,0>]
                                        [.5 <.5,1>]
                                        [1 <1,0>]
                                        }
                                turbulence .4
                                scale <10,10,2>*6]
                                }

                        }

        finish {
                specular 0
                roughness 1
                reflection 0
                ambient 0.1
                diffuse 0.5
                }
        }

#declare Board2 =
texture {
  pigment {
                wood
                color_map {
                        [.4 rgb <.84, .73, .6>]
                        [.6 rgb <.8, .7, .6>]
                        }
                        quick_color Brown
                }
                normal {
                        average
                        normal_map {
                                [1 wood .4
                                slope_map {
                                        [0.0 <0.0, 0>]
                                        [0.5 <0.5, 1>]
                                        [1.0 <1.0, 0>]
                                        }
                                turbulence .5
                                scale <10,10, 1>*10
                                rotate y*90]
                                [1 wood .6
                                slope_map {
                                        [0 <0,0>]
                                        [.5 <.5,1>]
                                        [1 <1,0>]
                                        }
                                turbulence .4
                                scale <10,10,2>*6]
                                }

                        }

        finish {
                specular 0
                roughness 1
                reflection 0
                ambient 0.1
                diffuse 0.5
                }
        scale 0.5
        rotate z*90
 }

#declare S = 100; // Variable S needed for Rust texture
#declare rust = texture {
                        pigment {
                                wrinkles
                                color_map {
                                // [ 0.0 rgbft <0.827451, 0.4, 0.113725, 0.0,
0.0> ]
                                [ 0.291815 rgbft <0.705882, 0.329412, 0.141176,
0.0, 0.0> ]
                                [ 0.569395 rgbft <0.929412, 0.490196, 0.207843,
0.0, 0.0> ]
                                // [ 0.761566 rgbft <0.729412, 0.462745,
0.207843, 0.0, 0.0> ]
                                [0.761566 color rgb <0.87451, 0.380392,
0.082353>]
                                [ 0.857651 rgbft <0.611765, 0.470588, 0.266667,
0.0, 0.0> ]
                                [ 1.0 rgbft <0.752941, 0.447059, 0.188235, 0.0,
0.0> ]
                                }
                                turbulence <0.9931, 0.4938, 0.0195>*S
                                octaves 8
                                omega 0.7132
                                lambda 2.2602
                                frequency 0.7355
                                phase 1.22
                                poly_wave 1.013
                                warp {
                                        turbulence <1.668, 1.522, 2.948>*S
                                        octaves 10
                                        omega 0.647
                                        lambda 2.035
                                        }
                                quick_color Red*0.5
                                }
                                normal {
                                        wrinkles, 1000
                                        scale 0.5*S
                                        normal_map {
                                        [0.3 granite , 0.85 scale 0.2*S]
                                        [1.0 bumps , 1.2 scale .7*S]
                                        }
                                        warp {
                                        turbulence <1.668, 1.522, 2.948>*S
                                        octaves 10
                                        omega 0.647
                                        lambda 2.035
                                        }
                                }
                                        finish {
                                        ambient 0
                                        diffuse 0.45
                                        specular .1
                                        roughness 0.5
                                        crand 0.015
                                }
}




#declare Pulley   = F_MetalC;
#declare Shaft    = F_MetalC;
#declare Belt     = texture {
                        pigment {
                                color Black
                                }
                        finish { phong .6}
                        }

#declare Alt      =     F_MetalB;
#declare Block    = texture {
                        pigment {
                        color Red
                        quick_color Yellow
                        transmit 0
                        }
                        finish {
                        specular 0
                        ambient 0.5
                        diffuse 0.2
                        reflection 0.1
                        phong 0.3
                        phong_size 1
                        }
                }

#declare Negative = texture { pigment { color Red } }

#declare Line = texture {
                        pigment {
                        color Green
                        }
                        finish {
                        specular 0.6
                        ambient 0.8
                        diffuse 0.1
                        reflection 0
                        phong 0.8
                        //phong_size 0.1
                        }
                }

#declare Pistons = F_MetalE;

#declare Yellowtex =
texture {
 pigment {
  color <1.0,1.0,0.0>
 }
 finish {phong 1}
}

#declare Leadtex =
texture {
 pigment {
  color <0.3,0.3,0.3>
 }
 finish {phong 1}
 }

#declare Penciltex =
texture {
 pigment {
  wood
  turbulence 0.0
  color_map {
   [0.0 color <0.7,0.6,0.4>]
   [1.0 color <0.8,0.7,0.6>]
  }
  scale 0.1
  rotate 88*x
  translate 0.5
 }
}

//#########################################################################################
// definition of scene objects

// #declare Spoke = cylinder { <-Big_Radius, 0, 0>, < Big_Radius, 0, 0>,
Belt_width/2 }

#declare Big_Pulley = union {
 union {
         difference {
                 torus {Big_Radius, Belt_width/2}
                 torus {Big_Radius+Belt_width/2, Belt_width/2}
                 }
         cylinder {<0, -Belt_width/2, 0>, <0, Belt_width/2, 0>, Big_Radius}
   //object {Spoke}
   //object {Spoke rotate y*120}
   //object {Spoke rotate y*-120}
  texture { Board2 }
 }
         sphere { <0, 0, -(Big_Radius-1)> .1 pigment { color Red}}  // Make
radius = Belt_width to see ref point

}

#declare Small_Pulley =
difference {
        cylinder { <0, -Belt_width/2, 0>, < 0, Belt_width/2, 0>, Small_Radius }
        torus { Small_Radius, Belt_width/2}
        cylinder { <0, -(Belt_width/2+0.5), 0>, < 0, Belt_width/2+0.1, 0>, 0.1
pigment { color Red}}
 }

#declare Counterweight =
difference {
        cylinder { <0, 0, 1>, <0, 0, 0.5>, CW_rad }
        cylinder { <-CW_rad, -CW_rad, 1.1>, <-CW_rad, -CW_rad, 0.4>, CW_rad*0.8
}
        cylinder { <CW_rad, -CW_rad, 1.1>, <CW_rad, -CW_rad, 0.4>, CW_rad*0.8 }
}

#declare Counterweights =
union {
        object { Counterweight }
        object { Counterweight translate -z*1.5}
        cylinder { <0, -CW_rad+Inset, 1.1>, <0, -CW_rad+Inset, -1.1>, 0.5 }
}

#declare Pistonrod =  cylinder { <0, 0, 0>, <0, PistonRod, 0>, 0.5 }

#declare Piston1 = union {
        object {Pistonrod rotate -z*degrees(rodRotation1) translate
<0,-PistonRod+stroke1,0>}
        cylinder { <0, 0, 0>, <0, -4, 0>, 1.5 rotate z*Treadle_Angle translate
<0,-PistonRod+stroke1,0>}
}

#declare Piston2 = union {
        object {Pistonrod rotate -z*degrees(rodRotation2) translate
<0,-PistonRod+stroke2,0>}
        cylinder { <0, 0, 0>, <0, -4, 0>, 1.5 rotate z*Treadle_Angle translate
<0, -PistonRod+stroke2,0> }
}

#declare Piston3 = union {
        object {Pistonrod rotate -z*degrees(rodRotation3) translate
<0,-PistonRod+stroke3,0>}
        cylinder { <0, 0, 0>, <0, -4, 0>, 1.5 rotate z*Treadle_Angle translate
<0,-PistonRod+stroke3,0>}
}

#declare Piston4 = union {
        object {Pistonrod rotate -z*degrees(rodRotation4) translate
<0,-PistonRod+stroke4,0>}
        cylinder { <0, 0, 0>, <0, -4, 0>, 1.5 rotate z*Treadle_Angle translate
<0,-PistonRod+stroke4,0>}
}


#declare Crankshaft =
union {
        object {Counterweights rotate z*rotation  translate <0, Bottom+5,
-(Frame_Depth/5)>}
        object {Counterweights rotate z*rotation2 translate <0, Bottom+5,
-(2*Frame_Depth/5)>}
        object {Counterweights rotate z*rotation3 translate <0, Bottom+5,
-(3*Frame_Depth/5)>}
        object {Counterweights rotate z*rotation4 translate <0, Bottom+5,
-(4*Frame_Depth/5)>}
//        object { Piston1 translate <0, Bottom+5, -(Frame_Depth/5)> }
//        object { Piston2 translate <0, Bottom+5, -(2*Frame_Depth/5)> }
//        object { Piston3 translate <0, Bottom+5, -(3*Frame_Depth/5)> }
        object { Piston4 translate <0, Bottom+5, -(4*Frame_Depth/5)> }
}

#declare EngineBlock = superellipsoid {<0.25, 0.25> scale <Frame_Width/4,
2*Vertical_Displacement+2, Frame_Depth/2> }

#declare Engine =
 difference{
         object { EngineBlock texture { Block } }
         object { EngineBlock scale 0.9 texture { Block } }
         plane {x, 0 texture { rust } }
         plane {y, -2*Vertical_Displacement texture { rust } }
 }

#declare Alternator = superellipsoid {<1, 0.25>}

#declare Post = superellipsoid {<1, 0.25> scale <1/2, 1/2, 1>}
#declare Battery = superellipsoid {<0.1, 0.1> scale Battery_Size/2 }
#declare Battery_position = <8, Battery_Size.y/2, Battery_Size.z*2+2>;

object { Battery translate <Battery_position.x*3, Battery_position.y,
Battery_position.x> texture { pigment {Gray10} } }
object { Post rotate x*90 translate <Battery_position.x*3.3, Battery_Size.y+1,
7> pigment {Gray40}}
object { Post rotate x*90 translate <Battery_position.x*2.7, Battery_Size.y+1,
7> pigment {Gray40}}

#declare Ground =
 sphere_sweep {
  cubic_spline
          11,
          <Alternator_Offset-(Alternator_Dia-2), Alternator_height, -4>, .25
//unplotted point
          <Alternator_Offset-(Alternator_Dia-2), Alternator_height, -8>, .25
//Back of alternator
          <Alternator_Offset-(Alternator_Dia-2), Alternator_height, -9>, .25
//extend back
          <Alternator_Offset+(Alternator_Dia/2), Alternator_height, -11>, .25
//center of bend
          <Alternator_Offset+(Alternator_Dia)  , Alternator_height+1, -0>, .25
//end of bend
          <Alternator_Offset+(Alternator_Dia)  , Alternator_height, 0>, .25 //to
front of alternator
          <Alternator_Offset+(Alternator_Dia)  , Alternator_height/2, 2>, .25
//control point 1/2 way down
          <Alternator_Offset+(Alternator_Dia)  , Battery_Size.y-1, 2>, .25 //on
ground over to battery post
          <Battery_position.x*3.3, Battery_Size.y+2, 4>, .25 //on ground over to
battery post
          <Battery_position.x*3.3, Battery_Size.y+1, 7>, .25 //on ground over to
battery post
          <Battery_position.x*3.3, Battery_Size.y+1, 8>, .25 //unplotted point
   }

#declare Neg =
 sphere_sweep {
  cubic_spline
          11,
          <Alternator_Offset+(Alternator_Dia-2), Alternator_height, -4>, .25
//unplotted point
          <Alternator_Offset+(Alternator_Dia-2), Alternator_height, -8>, .25
//Back of alternator
          <Alternator_Offset+(Alternator_Dia-2), Alternator_height, -9>, .25
//extend back
          <Alternator_Offset+(Alternator_Dia)  , Alternator_height, -10>, .25
//center of bend
          <Alternator_Offset+(Alternator_Dia+1), Alternator_height, -9>, .25
//end of bend
          <Alternator_Offset+(Alternator_Dia+1), Alternator_height-1, 0>, .25
//to front of alternator
          <Alternator_Offset+(Alternator_Dia+2), Alternator_height/2, 2>, .25
//control point 1/2 way down
          <Alternator_Offset+(Alternator_Dia+2), Battery_Size.y-1, 2>, .25 //on
ground over to battery post
          <Battery_position.x*2.9, Battery_Size.y+2, 4>, .25 //on ground over to
battery post
          <Battery_position.x*2.7, Battery_Size.y+1, 7>, .25 //on ground over to
battery post
          <Battery_position.x*2.7, Battery_Size.y+1, 8>, .25 //unplotted point
   }


//########################################[FRONT VIEW COMPONENTS]
#################################################

//############################################################################################
//     Alternator Belt
//############################################################################################


// -------------- dimensions -----------
#local R1 = Big_Radius;  // big wheel radius
#local R2 = Small_Radius; // small wheel radius
#local Dist = vlength (<0,Top,0>-<Alternator_Offset,Alternator_height,0>);//
axis distance

#local Link_N = 120;// number of links

// -------------- calculations ---------
#local Ri = R1-R2;
#local C_Angle = degrees(asin(Ri/Dist));
// chain linear length
#local LLen=sqrt(pow(Dist,2)-pow(Ri,2));
// segment angle and length
#local Ang1 = 180+2*C_Angle;
#local Ang2 = 180-2*C_Angle;
#local Len1 = Ang1/360*2*pi*R1;
#local Len2 = Ang2/360*2*pi*R2;
// total length
#local C_Len = 2*LLen+Len1+Len2;
#local Link_L  = C_Len / Link_N;

#declare Link =        // the chain link
cone{<0,-Belt_width/2,0>, Belt_width/4, <0,Belt_width/2,0>, Belt_width/2}
//Move texture down to loop and vary color with position along belt




/*  //Diagnostic references
sphere{<0,Top,0>,0.5 texture{pigment{color Red}}}
cylinder { <-Dist,0,0>, <0,0,0> , 0.25
 rotate
z*VAngleD(<-Dist,Top,0>-<0,Top,0>,<0,Top,0>-<Alternator_Offset,Alternator_height,0>)
 translate <0,Top,0>
 rotate y*180}
sphere{<Alternator_Offset,Alternator_height,0>,0.5 texture{pigment{color Red}}}
*/


#declare Sag = 1;


//--------------------------------------
#local Ani=clock*Link_L;// animation!

#declare Alternator_Belt =
union{ //-------------------------------
#local Nr = Link_N; // start loop
#while (Nr > 0)
 //#local Pos = mod(Nr*Link_L+Ani, C_Len);
#local Pos = mod(Nr*Link_L+(pi*2*R1*StepUp1), C_Len);    // Change code to move
link actual distance

  #if (Nr = Link_N)
  #local Link_texture = texture{pigment{color Gray30}}
  #else
  #local Link_texture = texture{pigment{color Black}}
  #end
 //-------------------------------------

 #if(Pos< Len1 ) // Counterclockwise around Big pulley
  #local Rot1 = Pos/Len1*Ang1;
  object{Link
   texture{Link_texture}
   translate<0, R1, 0>
        rotate<0, 0,-Rot1+C_Angle>
         }
//  text { ttf "arial.ttf" str(Nr, 3,0) 0.1, 0 scale Text_size translate <0,
Belt_width, 0> translate<0, R1, 0> rotate<0, 0,-Rot1+C_Angle>}

/*        #if (Nr = Link_N)
  sphere { <0,0,0>, Belt_width pigment {color Green} translate <0, Belt_width,
0>
       translate<0, R1, 0> rotate<0, 0,-Rot1+C_Angle>}
  #end
*/

 #end //--------------------------------
 #if((Pos>Len1) & (Pos<=Len1+LLen))
   #local LPos = Pos-Len1; // Counterclockwise from Big pulley to small pulley
   #local Linksag = Sag*sin((pi/LLen)*LPos);
   object{Link
    texture{Link_texture}
      rotate z*180

    translate<-LPos, -R1-Linksag, 0>

         rotate<0, 0,-C_Angle>
            }
//  text { ttf "arial.ttf" str(Nr, 3,0) 0.1, 0 scale Text_size translate <0,
Belt_width, 0> rotate z*180 translate<-LPos, -R1-Linksag, 0> rotate<0,
0,-C_Angle>}

 #end //--------------------------------


 #if((Pos>Len1+LLen )       // wrap around small pulley
      & (Pos<= Len1+LLen+Len2))
  #local Rot2 =
      (Pos-Len1-LLen)/Len2*Ang2;
  object{Link
 texture{Link_texture}
   translate<0,R2,0>
        rotate<0, 0, -Rot2-C_Angle-180>
        translate<-Dist,0,0>
              }
//  text { ttf "arial.ttf" str(Nr, 3,0) 0.1, 0 scale Text_size translate <0,
Belt_width, 0> translate<0,R2,0> rotate<0, 0, -Rot2-C_Angle-180>
translate<-Dist,0,0>}

 #end //--------------------------------
 #if((Pos>Len1+LLen+Len2) // Counterclockwise from Small pulley to big pulley
      & (Pos <= Len1+LLen+Len2+LLen))
  #local LPos = Pos-(Len1+LLen+Len2);
      #local Linksag = Sag*sin((pi/LLen)*LPos);  // Calculate chain sag
  object{Link
   texture{Link_texture}
   translate<LPos,R2-Linksag,0>   // Move link by sag amount
        rotate<0, 0, C_Angle>
        translate<-Dist, 0, 0>
              }
//  text { ttf "arial.ttf" str(Nr, 3,0) 0.1, 0 scale Text_size translate <0,
Belt_width, 0> translate<LPos,R2-Linksag,0> rotate<0, 0, C_Angle>
translate<-Dist, 0, 0>}

 #end //--------------------------------


#local Nr = Nr - 1;  // next Nr
#end // --------------- end of loop

 rotate
z*VAngleD(<-Dist,Top,0>-<0,Top,0>,<0,Top,0>-<Alternator_Offset,Alternator_height,0>)
 translate <0,Top,0>
 rotate y*180
}








// Nut and Bolt

#declare threads =
union {
        isosurface {
                function{
                        f_helix1( x,y,z,
                        1,                      // number of helixes, (1 =
single helix, 2 = double helix etc.)
                        5*2*pi,         // period,      turns on the length of
2*pi
                        ID,              // minor radius,
                        OD,                // major radius,
                        1,                      // shape parameter,
                        2.0,                    // cross section type,
                                                // (0.0 to 1.0 = square ...
rounded to circle
                                                // over 2.0 to 3.0 = rounded to
diamond and concave diamond
                        0 )                     // cross section rotation angle
    }
        contained_by {
                box {<-OD*2, 0, -OD*2> <OD*2, length, OD*2> }
                }
    threshold 0
    max_gradient 1.3
    accuracy 0.0001
    all_intersections
  }
  cylinder { <0, 0, 0>, <0, length, 0>, OD pigment {Gray20}}
 }

#declare nut_body = box {<-nutsize/2, 0.01, -nutsize/2> <nutsize/2, 0.25,
nutsize/2>}

object {threads
 translate y*Small_Radius/2
 rotate z*StepUp1      //Animation Rotation StepUp1
 translate <0, (Top)+Exploded1*Exp_bolt, 1.5+Belt_width*2>
 texture { Rust finish {ambient 0}}
 }

// Bolt Hex head
isosurface {function { f_hex_x (x,y,z, 1) }
        contained_by {
                box {<-1, -1, 0> <1, 1, -0.25> }
                }
                threshold 0.1
                scale <5, 5, 1>
                rotate x*90
                translate y*length
                texture { Rust finish {ambient 0}}
                translate y*Small_Radius/2
  rotate z*StepUp1     //Animation Rotation StepUp1
                translate <0, (Top)+Exploded1*Exp_bolt, 1.5+Belt_width*2>
}

// Square nut
difference {
        object {nut_body  texture { Rust finish {ambient 0}}}
        object {threads pigment { color Gray50}}
 translate y*Small_Radius/2
 rotate z*StepUp1      //Animation Rotation StepUp1
        translate <0, (Top)+Exploded1*Exp_nut, 1.5+Belt_width*2>
}

// Big pulley turning alternator
object {Big_Pulley
 rotate x*90
 rotate z*StepUp1      //Animation Rotation StepUp1
 translate <0, Top, 1.5> }


// Wooden part on Big wheel For Coupling to Big pulley
#declare Coupling_shaft =
difference{
 cylinder {  <0, -Belt_width*2, 0>, < 0, Belt_width*2, 0>, Small_Radius
   rotate x*90
   texture { Board2 translate y*10}
   }
 object { nut_body scale 1.2
   translate <0, Small_Radius-0.25, 0>}
 }

object { Coupling_shaft
 rotate z*StepUp1      //Animation Rotation StepUp1
 translate <0, Top, (1.5+Belt_width*2)>
 }

#declare coupling_thickness = Small_Radius+0.5;
#declare coupling =
difference {
        cylinder { <0, -Belt_width*2, 0>, < 0, Belt_width*2, 0>,
coupling_thickness }
        cylinder { <0, -(Belt_width*2+1), 0>, < 0, Belt_width*2+1, 0>,
Small_Radius }
        cylinder { <0, 0, 0>, < 0, 0, -(coupling_thickness+1)>, 0.5 pigment
{color White} }
        rotate x*90
}

object { coupling
 rotate z*StepUp1           //Animation Rotation StepUp1
 translate <0, Top, (1.5+Belt_width*2)+Exploded1*Exp_coupling>
 texture {Shaft}
 }


//########################################[START ELPLODED VIEW COMPONENTS]
#################################################
// exploded view additions
#if ( Exploded1 = 1 )
// yellow assembly line
//cylinder { <0, Top, (1.5+Belt_width*2)>, <0,
(Top+Small_Radius+Belt_width/2)+Exploded1*Exp_bolt, (1.5+Belt_width*2)>, 0.125
pigment { color Yellow}}

#declare Bolt_line =   sphere_sweep {
        linear_spline
        8,
        <0, Top, (1.5+Belt_width*2)>, .125
               // Shaft
        <0, Top+Small_Radius+2, (1.5+Belt_width*2)>, .125
               // Up out of hole
        <0, Top+Small_Radius+2, 1.5+Belt_width*2+Exploded1+2.5>, .125
               // To shaft flat
        <0, Top+Small_Radius+.25, 1.5+Belt_width*2+Exploded1+2.5>, .125
               // Down toward shaft
        <0, Top+Small_Radius+.25, (1.5+Belt_width*2)+Exploded1*Exp_coupling>,
..125              // To Coupling hole
        <0, Top+Small_Radius+3, (1.5+Belt_width*2)+Exploded1*Exp_coupling>, .125
               // Up out of coupling hole
        <0, Top+Small_Radius+3, (1.5+Belt_width*2)>, .125
               // Back to wheel
        <0, (Top+Small_Radius+Belt_width/2)+Exploded1*Exp_bolt,
(1.5+Belt_width*2)>,  .125      // Up to Bolt
  }

object {Bolt_line texture { Line} no_shadow no_reflection}

//object { coupling_exp texture {pigment {color Yellow } }}

#declare coupling_exp =
difference {
        cylinder { <0, 0, 1.5>, < 0, 0, 1.5+Exploded1*Exp_coupling>,
Small_Radius+0.01 }
        cylinder { <0, 0, 1.5>, < 0, 0, 1.5+Exploded1*Exp_coupling>,
Small_Radius }
        plane {x, 0}
        rotate -z*30
        translate y*Top
}

#declare coupling_arrow = union {
cylinder { <0, Top, (1.5+Belt_width*2)+Exploded1*Exp_coupling>, <0, Top,
(1.5+Belt_width*2)>, .125}
cone { <0, Top, (1.5+Belt_width*2)>, 0.25, <0, Top, 1.5>, 0}
}

object { coupling_arrow translate -x*Small_Radius texture { Line } }

difference{
cylinder { <0, Top, 6+Exploded1*Exp_shaft>, <0, Top, -(Frame_Depth+4)>, 0.5 }
box { <-1, Top+0.25, 1.5+Belt_width*2+Exploded1+2> <1, Top+1,
1.5+Belt_width*2+Exploded1+3> pigment { color White} }
texture { Shaft }
}
#else

// Draw regular length top shaft
cylinder { <0, Top, 6+Exploded1*Exp_shaft>, <0, Top, -(Frame_Depth+4)>, 0.5
texture { Shaft } }

#end
//########################################[END ELPLODED VIEW COMPONENTS]
#################################################





// Alternator components

object {Alternator scale <Alternator_Dia, Alternator_Dia, 4> translate
<Alternator_Offset, Alternator_height, -4> texture { Alt }}

cylinder { <0, 0, -2>, <0, 0, 2>, 0.5
 rotate x*90
 rotate z*StepUp2       //Animation Rotation StepUp2
 translate <Alternator_Offset,Alternator_height,1>
 texture { Shaft }
 }

object {Small_Pulley
 rotate x*90
 rotate z*StepUp2       //Animation Rotation StepUp2
 translate <Alternator_Offset, Alternator_height, 1.5>
 texture { Pulley }
 }


object {Alternator_Belt translate z*1.5}





//########################################[CENTER SECTION COMPONENTS]
#################################################
box      { <-Frame_Width/2, 0, -Frame_Thickness/2>, < Frame_Width/2,
Frame_Height, Frame_Thickness/2> texture{ Board } }


object {Engine translate <0, Bottom+5, -Frame_Depth/2> }
// Crankshaft axis
cylinder { <0,Bottom+5,3>, <0,Bottom+5,-(Frame_Depth+3)>, 0.5 texture { Shaft }}

object {Crankshaft texture {Shaft} }

#declare Treadle =
box      { <-Frame_Width*2, 0, -Frame_Thickness/2>, < Frame_Width*2, 1.5,
-Frame_Depth> }

object {Treadle
        translate x*Pivot       // Moves pivot point to origin
        rotate z*Treadle_Angle  // Rotates around origin
        translate <-Pivot, Treadle_Height, 0>
        texture{ Board rotate y*90 }
        }

//Treadle pivot
cylinder { <-Pivot, 0, 3>, <-Frame_Width/2+2, 0, -(Frame_Depth+3)>, 0.5
translate <0, Pivot_Height, 0> texture { Shaft } }








// Rear ####################################################
box      { <-Frame_Width/2, 0, -Frame_Depth>, < Frame_Width/2, Frame_Height,
-Frame_Depth+0.75> texture{ Board } }

object {Big_Pulley
 rotate x*90 rotate z*90
 rotate z*rotation
 translate <0, Bottom+5, -(Frame_Depth+1.5)>
 texture { Board2 }
 }

object {Small_Pulley
 rotate x*90
 rotate z*StepUp1
 translate <0, Top, -(Frame_Depth+1.5)>
 texture { Board2 }
 }

//############################################################################################
//     Drive Belt
//############################################################################################



// -------------- dimensions -----------
#local R1 = Big_Radius;  // big wheel radius
#local R2 = Small_Radius; // small wheel radius
#local Dist = vlength (<0,Top,0>-<0,Bottom+5,0>);// axis distance

#local Link_N = 120;// number of links

// -------------- calculations ---------
#local Ri = R1-R2;
#local C_Angle = degrees(asin(Ri/Dist));
// chain linear length
#local LLen=sqrt(pow(Dist,2)-pow(Ri,2));
// segment angle and length
#local Ang1 = 180+2*C_Angle;
#local Ang2 = 180-2*C_Angle;
#local Len1 = Ang1/360*2*pi*R1;
#local Len2 = Ang2/360*2*pi*R2;
// total length
#local C_Len = 2*LLen+Len1+Len2;
#local Link_L  = C_Len / Link_N;
#declare Link =        // the chain link
cone{<0,-Belt_width/2,0>, Belt_width/4, <0,Belt_width/2,0>, Belt_width/2
       texture{pigment{color Black}}}

/*
sphere{<0,Top,0>,0.5 texture{pigment{color Red}}}
cylinder { <-Dist,0,0>, <0,0,0> , 0.25
 rotate z*VAngleD(<-Dist,Top,0>-<0,Top,0>,<0,Top,0>-<0,Bottom+5,0>)
 translate <0,Top,0>
 rotate y*180}
sphere{<0,Bottom+5,0>,0.5 texture{pigment{color Red}}}
*/

//--------------------------------------
#local Ani=clock*Link_L;// animation!

#declare Drive_Belt =
union{ //-------------------------------
#local Nr = 0; // start loop
#while (Nr < Link_N)
//#local Pos = mod(Nr*Link_L+Ani,C_Len);
#local Pos = mod(Nr*Link_L+(pi*2*R1*StepUp1), C_Len);    // Change code to move
link actual distance

  #if (Nr = Link_N)
  #local Link_texture = texture{pigment{color Gray30}}
  #else
  #local Link_texture = texture{pigment{color Black}}
  #end
 //-------------------------------------

 #if(Pos< Len1 ) // front down
  #local Rot1 = Pos/Len1*Ang1;
  object{Link translate<0,R1,0>
         rotate<0,0,-Rot1 +C_Angle>
         }
 #end //--------------------------------
 #if((Pos>Len1) & (Pos<=Len1+LLen))
  #local LPos = Pos-Len1; // clockwise from small pulley to big pulley
  object{Link
    rotate z*180
  translate<-LPos,-R1,0>
            rotate<0,0,-C_Angle>
            }
 #end //--------------------------------
 #if((Pos>Len1+LLen )       // wrap around small pulley
      & (Pos<= Len1+LLen+Len2))
  #local Rot2 =
      (Pos-Len1-LLen)/Len2*Ang2;
  object{Link

  translate<0,R2,0>
          rotate<0,0,-Rot2-C_Angle-180>
              translate<-Dist,0,0>
              }
 #end //--------------------------------
 #if((Pos>Len1+LLen+Len2) // clockwise from big pulley to small pulley
      & (Pos <= Len1+LLen+Len2+LLen))
  #local LPos = Pos-(Len1+LLen+Len2);
  object{Link

  translate<LPos,R2,0>
              rotate<0,0,C_Angle>
              translate<-Dist,0,0>
              }
 #end //--------------------------------
#local Nr = Nr + 1;  // next Nr
#end // --------------- end of loop

 rotate -z*VAngleD(<-Dist,Top,0>-<0,Top,0>,<0,Top,0>-<0,Bottom+5,0>)
 translate <0,Bottom+5,-(Frame_Depth+1.5)>
}


//
###########################################################################################

object {Drive_Belt}

//####################################################
object {Ground texture {Belt} }
object {Neg texture {Negative} }

#declare Speedsquare = difference {
union {
 box { <0,0,8> <8,1,8.2>}
 box { <0,0.4,0> <8,0.6,8>}
 }
 plane { z, 0 rotate -y*45}
 cylinder {<1,0,3>, <1,1,3>, 0.25}
 cylinder {<5,0,7>, <5,1,7>, 0.25}
 box { <0,0,0.25> <sqrt(32),1,-0.25> rotate -y*45 translate <1,0,3>}
 }

object {Speedsquare rotate -y*30 translate z*15 texture { pigment { color
Gray70} } }

#declare Pencil =
intersection {
   union {
      cone {
         <0,0,0> 0.5 <0,1.6,0> 0.1
      }
      cone {
         <0,1.6,0> 0.1 <0,2.0,0> 0
         texture {Leadtex}
      }
      cylinder {
         <0,0.2,0> <0,-13,0> 0.5
      }
      texture {Penciltex}
   }
   box {<0.35,2,1> <-0.35,-14,-1> rotate 000*y texture {Yellowtex}}
   box {<0.35,2,1> <-0.35,-14,-1> rotate 120*y texture {Yellowtex}}
   box {<0.35,2,1> <-0.35,-14,-1> rotate 240*y texture {Yellowtex}}
   translate 13*y
}

object {Pencil
 rotate x*90 rotate -y*120 translate <3,0.5,10>}



#declare Plastic =
material { texture {pigment {color transmit 0.9} normal { granite .05}} interior
{ior 1.5}}


#declare Screwdriver = union {
sphere { 0.0, 7/8
        scale x*0.6
        material {Plastic}
        translate -x*0.25
}

difference{
 prism {
   linear_sweep  // or conic_sweep for tapering to a point
   linear_spline // linear_spline | quadratic_spline | cubic_spline |
bezier_spline
   -1.25,         // height 1
    1.25,         // height 2
   7,           // number of points
   // (--- the <u,v> points ---)x,z
   < cosd(  0), sind(  0)>,
   < cosd( 60), sind( 60)>,
   < cosd(120), sind(120)>,
   < cosd(180), sind(180)>,
   < cosd(240), sind(240)>,
   < cosd(300), sind(300)>,
   < cosd(360), sind(360)>
    material {Plastic}}
 sphere { <0,0,0>, 1.45 inverse  material {Plastic}}
 box { <0.99*cosd( 0),-1.25, 0.99*sind( 0)>, <0.99*cosd( 60), 1.25, 0.99*sind(
60)> pigment {color Red}}
 box { <0.99*cosd( 120),-1.25, 0.99*sind( 120)>, <0.99*cosd( 180), 1.25,
0.99*sind( 180)> pigment {color Red}}
 box { <0.99*cosd( 240),-1.25, 0.99*sind( 240)>, <0.99*cosd( 300), 1.25,
0.99*sind( 300)> pigment {color Red}}

 rotate z*90
 translate x*1.25
}

#declare Blue_part =
difference{
        cylinder {<0,-.625,0>, <0,.625,0> 1}
        torus { 3, 2.3}
                        rotate z*90
         translate x*(2.5+.625)
          }
object { Blue_part texture { pigment {Blue} finish { specular 0.6 } } }
#declare Ring_1 = trace (Blue_part, <(2.5+.625+(0.625/6)*1), 1, 0>,
-<(2.5+.625+(0.625/6)*1), 1, 0>+<(2.5+.625+(0.625/6)*1),-1,0>);
#declare Ring_2 = trace (Blue_part, <(2.5+.625+(0.625/6)*2), 1, 0>,
-<(2.5+.625+(0.625/6)*2), 1, 0>+<(2.5+.625+(0.625/6)*2),-1,0>);
#declare Ring_3 = trace (Blue_part, <(2.5+.625+(0.625/6)*3), 1, 0>,
-<(2.5+.625+(0.625/6)*3), 1, 0>+<(2.5+.625+(0.625/6)*3),-1,0>);
#declare Ring_4 = trace (Blue_part, <(2.5+.625+(0.625/6)*4), 1, 0>,
-<(2.5+.625+(0.625/6)*4), 1, 0>+<(2.5+.625+(0.625/6)*4),-1,0>);

difference {
object { Blue_part }
cylinder { <(2.5+.625+(0.625/6)*4), 0, 0>, <(2.5+1.75),0,0>,
Ring_4.y+(Ring_4.y-Ring_3.y) inverse}
texture { pigment {Blue} finish { specular 0.6 } }
}

torus { Ring_1.y, .05 rotate z*90 translate x*(2.5+.625+(0.625/6)*1) texture {
pigment {Blue} finish { specular 0.6 } }}
torus { Ring_2.y, .05 rotate z*90 translate x*(2.5+.625+(0.625/6)*2) texture {
pigment {Blue} finish { specular 0.6 } }}
torus { Ring_3.y, .05 rotate z*90 translate x*(2.5+.625+(0.625/6)*3) texture {
pigment {Blue} finish { specular 0.6 } }}
torus { Ring_4.y, .05 rotate z*90 translate x*(2.5+.625+(0.625/6)*4) texture {
pigment {Blue} finish { specular 0.6 } }}

box{<-1.5,-.125,-.125> <4,0.25,0.25>
rotate x*45
translate x*(2.5+1.5-.625)
        texture {
                pigment {Gray70}
                normal { bumps .5}
                finish{specular 0.6}

                }
    }
} // End Union

object { Screwdriver rotate y*90 translate <5, 0.5, 20> }


#declare Hole =
union {
cylinder {<0.5,-1, 0>, <0.5, 1.1, 0>, 0.5}
box {<0, -1, 0>, <1, 1.1, 3>}
cylinder {<0.5,-1, 3>, <0.5, 1.1, 3>, 0.5}
}

#declare HandSaw = union {
difference{
box { <0,0,0>, <6,1,6> texture {pigment{Brown}}}
plane {x,0 rotate y*10}
plane {x,5 rotate y*10 inverse}
plane {z,0 rotate -y*7}
object {Hole rotate y*10 translate <2,0,1.5> }
object {Hole rotate y*10 translate <-0.1,0,1.5> }
object {Hole scale x*2 translate <5,0,.5> }
sphere { <3,0.6,2.6> 3.7 inverse}
}

difference{
box { <5,0.5-(1/32),0>, <25,0.5+(1/32),6> texture {pigment{Gray50}}}
plane {z,0 rotate -y*7}
cylinder {<24,-1, 5>, <24, 1.1, 5>, 0.25}
}


blob{ cylinder {<5,-0.1, 4.5>, <5, 1.1, 4.5>, 0.25, 1} threshold 0 texture
{pigment{Gray50}}}
blob{ cylinder {<4.5,-0.1, 3>, <4.5, 1.1, 3>, 0.25, 1} threshold 0 texture
{pigment{Gray50}}}
blob{ cylinder {<4.5,-0.1, 1.5>, <4.5, 1.1, 1.5>, 0.25, 1} threshold 0 texture
{pigment{Gray50}}}
}
object {HandSaw  rotate y*100 translate <10, 0.5, 30>}

//####################################################
/*
// Y-axis dimensions
cylinder { <-Frame_Width/2, 0 ,0>, <-Frame_Width/2, Frame_Height, 0>, 0.25
pigment { color Yellow}}
cylinder { <-Frame_Width/2, Bottom+5, 0>, <0, Bottom+5, 0>, 0.25 pigment {color
Yellow}}
cylinder { <-Frame_Width/2, Pivot_Height, 0>, <-Pivot, Pivot_Height, 0>, 0.25
pigment {color Yellow}}
cylinder { <-Frame_Width/2, Bottom, 0>, <Alternator_Offset, Bottom, 0>, 0.25
pigment {color Yellow}}
cylinder { <-Frame_Width/2, (Bottom+5-PistonRod-4+stroke4), 0>, <0,
(Bottom+5-PistonRod-4+stroke4), 0>, 0.25 pigment {color Yellow}}
cylinder { <-Frame_Width/2, (Pivot_Height+Treadle_thickness), 0>, <0,
(Pivot_Height+Treadle_thickness), 0>, 0.25 pigment {color Yellow}}


// Z-axis dimensions
cylinder { <0, Top+Big_Radius, 0>, <0, Top+Big_Radius, 1.5+Belt_width>, 0.25
pigment { color Red}}
cylinder { <Battery_Size.x*2.5, .5, 0>, <Battery_Size.x*2.5, .5, -16>, 0.25
pigment { color Red}}
cylinder { <Battery_Size.x*3, .5, 0>, <Battery_Size.x*3, .5, -Battery_Size.z*2>,
0.25 pigment { color Red}}
cylinder { <Battery_Size.x*3.5, .5, 0>, <Battery_Size.x*3.5, .5,
-Battery_Size.z>, 0.25 pigment { color Red}}

*/
//object {Piston3 translate y*Bottom+5}


// Debugging information

#debug "####################################################"
#debug "###########  Debuggung Information #################"
#debug "\n"
#debug concat("  Pivot = ", str(Pivot, 3,4))
#debug "\n"
#debug concat("  Pivot_Height = ", str(Pivot_Height, 3,0))
#debug "\n"
#debug concat("  Treadle_Height = ", str(Treadle_Height, 3,0))
#debug "\n"
#debug concat("  Bottom = ", str(Bottom, 3,0))
#debug "\n"
#debug concat("  (Bottom+5-PistonRod-4+stroke4) = ",
str((Bottom+5-PistonRod-4+stroke4), 3,0))
#debug "\n"
#debug concat("  (Pivot_Height+Treadle_thickness) = ",
str((Pivot_Height+Treadle_thickness), 3,0))
#debug "\n"
#debug concat("  Treadle_Angle = ", str(Treadle_Angle, 3,0))
#debug "\n"

#debug "####################################################"
#debug "\n"





/*


#declare Wedge2 =
difference {
        sphere {<0,0,0>, 1+Big_Radius+Belt_width/2}
        plane {x,0 rotate y*(theta2_d/2) inverse}
        plane {x,0 rotate -y*(theta2_d/2) }
        }
//object {Wedge2}


cylinder { <Alternator_Offset+Alternator_Dia, Bottom, -2>,
<5+Alternator_Offset+Alternator_Dia, Bottom, -2>, 0.5 }
difference {
        cone{<5+Alternator_Offset+Alternator_Dia, Bottom, -2>, 2,
<10+Alternator_Offset+Alternator_Dia/2, Bottom, -2>, 0 }
        box {<0.5, -3, 3> <1, 3, -3> translate
x*(5+Alternator_Offset+Alternator_Dia) translate y*Bottom translate z*-2}
        box {<1.5, -3, 3> <2, 3, -3> translate
x*(5+Alternator_Offset+Alternator_Dia) translate y*Bottom translate z*-2}
no_shadow
no_reflection
}





#declare Bolt_Head =
intersection {
    difference {
        sphere { <0,0,0>, 1
                texture { Rust
                        finish {ambient 0}
                        }
                }
        box { <-1.1, -0.15, -1.1> <-0.15, 0.15, 1.1> }
        }
    box {<-1,-1,-1><0.35, 1, 1>}
    scale <0.75, 1.5, 1.5>
    rotate -x*45
}

#declare Bolt_Shaft =
union {
        object { Disk_X scale <2.5, 0.75, 0.75 > }
        cone { <2.5, 0,0>, 0.75, <2.65,0,0>,0.55 }
        }


#declare TW=0.5;

#declare Thread =
union {
        cone { <-TW/2,0,0>, 0.75, <0,0,0>,1 }
        cone { < 0.0,0,0>, 1.00, <TW/2,0,0>,0.75 }
        rotate z*7
    }

#declare Bolt =
union {
        object { Bolt_Head translate -x*2.5 }
        intersection {
                union {
                        object { Bolt_Shaft }
                        object { Thread translate  x * 4.5 * TW }
                        object { Thread translate  x * 4.0 * TW }
                        object { Thread translate  x * 3.5 * TW }
                        object { Thread translate  x * 3.0 * TW }
                        object { Thread translate  x * 2.5 * TW }
                        object { Thread translate  x * 2.0 * TW }
                        object { Thread translate  x * 1.5 * TW }
                        object { Thread translate  x * 1.0 * TW }
                        object { Thread translate  x * 0.5 * TW }
                        object { Thread translate  x * 0.0 * TW }
                        object { Thread translate -x * 0.5 * TW }
                        object { Thread translate -x * 1.0 * TW }
                        object { Thread translate -x * 1.5 * TW }
                        object { Thread translate -x * 2.0 * TW }
                        object { Thread translate -x * 2.5 * TW }
                        object { Thread translate -x * 3.0 * TW }
                        object { Thread translate -x * 3.5 * TW }
                        object { Thread translate -x * 4.0 * TW }
                        scale <1, 0.85, 0.85>
                        }
                cylinder {<-3.5, 0, 0> <2.75, 0, 0>, 0.83  }
                }
        texture { Rust finish {ambient 0}}
        bounded_by { cylinder {<-3.45, 0,0> <2.5,0,0>,1.5 } }
        }

//-------------------------------------------------------------------

//#declare BoltHead = 0.25;
//#declare Corner = radians(72.5);
#declare Bolt =
prism { linear_spline
        Small_Radius, 2*coupling_thickness, 7,
        <BoltHead*cos (0*Corner), BoltHead*sin (0*Corner)>,
        <BoltHead*cos (1*Corner), BoltHead*sin (1*Corner)>,
        <BoltHead*cos (2*Corner), BoltHead*sin (2*Corner)>,
        <BoltHead*cos (3*Corner), BoltHead*sin (3*Corner)>,
        <BoltHead*cos (4*Corner), BoltHead*sin (4*Corner)>,
        <BoltHead*cos (5*Corner), BoltHead*sin (5*Corner)>,
        <BoltHead*cos (6*Corner), BoltHead*sin (6*Corner)>
}

//object {Bolt  scale 0.5 rotate -z*90 translate <0,
(Top+Small_Radius+Belt_width/2)+Exploded1*4, 1.5+Belt_width*2>}

// OLD Alternator Belt

union {
        difference {
                torus {Big_Radius+Belt_width/2, Belt_width/2}
                box{ <0, -(1+Belt_width/2), 1+Big_Radius+Belt_width/2>
<1+Big_Radius+Belt_width/2, 1+Belt_width/2, -0.5> }
                box{ <0,-(1+Belt_width/2), 1+Big_Radius+Belt_width/2>
<1+Big_Radius+Belt_width/2, 1+Belt_width/2, -0.5> rotate -y*(theta_d-90)*0.97}
                }
        difference {
                torus {Small_Radius+Belt_width/2, Belt_width/2}
                box{ <-1, -(1+Belt_width/2), 1+Small_Radius+Belt_width/2>
<1+Small_Radius+Belt_width/2, 1+Belt_width/2, 0> }
                box{ <-1,-(1+Belt_width/2), 1+Small_Radius+Belt_width/2>
<1+Small_Radius+Belt_width/2, 1+Belt_width/2, 0> rotate y*(theta_d-90)*1.1}
                rotate -y*belt_angle rotate y*180 translate
<Alternator_Offset,0,Top-Bottom>
                }
        cylinder { <Big_Radius+Belt_width/2, 0, -1>,
<Alternator_Offset+Small_Radius+Belt_width/2, 0, Top-Bottom>, Belt_width/2}
        cylinder { <(Big_Radius+Belt_width/2)*cos(-theta_d*2), 0,
(Big_Radius+Belt_width/2)*sin(-theta_d*2)>,
<Alternator_Offset-(Small_Radius+Belt_width/2)+0.15, 0, Top-Bottom+1.1>,
Belt_width/2}
}

// OLD Drive Belt
union {
        difference {
                torus {Big_Radius+Belt_width/2, Belt_width/2}
                object {Wedge2}
                }
        difference {
                torus {Small_Radius+Belt_width/2, Belt_width/2}
                object {Wedge2 inverse}
                translate z*(Top-(Bottom+5))
                }
        cylinder { <-(Big_Radius+(Belt_width/2))*sin(theta2_d/2), 0,
(Big_Radius+(Belt_width/4))*cos(theta2_d/2)>,
<-(Small_Radius+Belt_width/4)*sin(theta2_d/2), 0,
(Top-(Bottom+5))+((Small_Radius-Belt_width/2)*sin(theta2_d/2))>, Belt_width/2 }
        cylinder { <(Big_Radius+Belt_width/2)*sin(theta2_d/2), 0,
(Big_Radius+(Belt_width/4))*cos(theta2_d/2)>,
<(Small_Radius+Belt_width/4)*sin(theta2_d/2), 0,
(Top-(Bottom+5))+((Small_Radius-Belt_width/2)*sin(theta2_d/2))>, Belt_width/2}
}

##############################################################################################
// -------------- dimensions -----------
#local R1 = 0.15;  // big wheel radius
#local R2 = 0.075; // small wheel radius
#local Dist = 0.30;// axis distance
#local Link_N = 30;// number of links
// -------------- calculations ---------
#local Ri = R1-R2;
#local C_Angle = degrees(asin(Ri/Dist));
// chain linear length
#local LLen=sqrt(pow(Dist,2)-pow(Ri,2));
// segment angle and length
#local Ang1 = 180+2*C_Angle;
#local Ang2 = 180-2*C_Angle;
#local Len1 = Ang1/360*2*pi*R1;
#local Len2 = Ang2/360*2*pi*R2;
// total length
#local C_Len = 2*LLen+Len1+Len2;
#local Link_L  = C_Len / Link_N;
#declare Link =        // the chain link
sphere{<0,0,0>,0.0075
       texture{Chrome_Metal}}
//--------------------------------------
#local Ani=clock*Link_Len;// animation!
union{ //-------------------------------
#local Nr = 0; // start loop
#while (Nr < Link_N)
 #local Pos = mod(Nr*Link_L+Ani,C_Len);
 //-------------------------------------
 #if(Pos< Len1 ) // front down
  #local Rot1 = Pos/Len1*Ang1;
  object{Link translate<0,R1,0>
         rotate<0,0,-Rot1 +C_Angle>}
 #end //--------------------------------
 #if((Pos>Len1) & (Pos<=Len1+LLen))
  #local LPos = Pos-Len1; // base side
  object{Link translate<-LPos,-R1,0>
            rotate<0,0,-C_Angle>}
 #end //--------------------------------
 #if((Pos>Len1+LLen )       // back up
      & (Pos<= Len1+LLen+Len2))
  #local Rot2 =
      (Pos-Len1-LLen)/Len2*Ang2;
  object{Link translate<0,R2,0>
          rotate<0,0,-Rot2-C_Angle-180>
              translate<-Dist,0,0>}
 #end //--------------------------------
 #if((Pos>Len1+LLen+Len2) // up forward
      & (Pos <= Len1+LLen+Len2+LLen))
  #local LPos = Pos-(Len1+LLen+Len2);
  object{Link translate<LPos,R2,0>
              rotate<0,0,C_Angle>
              translate<-Dist,0,0>}
 #end //--------------------------------
#local Nr = Nr + 1;  // next Nr
#end // --------------- end of loop
}

*/


Post a reply to this message


Attachments:
Download 'treadle.pov.txt' (58 KB)

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.