/**************************************************************** * DIODES include file for the Persistance of Vision Ray Tracer * * part of the ELECTRONICS set * **************************************************************** * * Created by Mark Hanford, December 2001 * * * Diode1() * Diode2() * * Dependencies * electronics.inc - mainly for some constants * colors.inc * glass.inc * * Optimisation options: * There's not much to optimise on this object yet, this may change... * * Base units: millimetres * Diode 1 Length - 5mm * Diode 2 Length - 3.8mm ***************************************************************/ /******************************************** * Check for and set some default variables * ********************************************/ #ifdef(View_POV_Include_Stack) #debug "including diodes.inc\n" #end #ifdef (MH_Diodes_Inc_Temp) //do nothing #else #declare MH_Diodes_Inc_Temp=1; #include "electronics.inc" #include "connections.inc" #include "colors.inc" #include "glass.inc" /************ * Textures * ************/ #declare T_Diode2Shell = texture{Glass3} #declare T_Diode2Core = texture{pigment{color rgb <255/255, 104/255, 13/255>}} #declare T_Diode1 = texture{ pigment{ gradient z color_map{ [0.000 color Gray30] [0.001 color Gray30] [0.010 color Gray70] [0.250 color Gray70] [0.254 color Gray30] [1.000 color Gray30] } scale <1, 1, 5> translate 2.5*z } finish{phong 1} normal{bumps 0.05 scale 0.1} } texture{ pigment{ image_map{ gif "images\dio_1N4001.gif" transmit 0, 1 map_type 2 interpolate 4 once } //scale 0.5 rotate <-90, 0, -90> translate -0.3*z } } /************* * Constants * *************/ #declare Diode1Length = 5; #declare Diode2Length = 3.8; #declare Diode1Radius = 2.6/2; #declare Diode2Radius = 1.5/2; /************************** * This is a simple diode * **************************/ #macro Diode1() cylinder{ <0, 0, -Diode1Length/2>, <0, 0, Diode1Length/2>, Diode1Radius texture{T_Diode1} } #end /************************************************ * This is a diode covered with a glass coating * ************************************************/ #macro Diode2() #local GlassThickness = 0.1; union{ merge{ sphere{<0, 0, (-Diode2Length/2)+Diode2Radius>, Diode2Radius} cylinder{<0, 0, (-Diode2Length/2)+Diode2Radius>,<0, 0, (Diode2Length/2)-Diode2Radius>,Diode2Radius} sphere{<0, 0, ( Diode2Length/2)-Diode2Radius>, Diode2Radius} texture{T_Diode2Shell} } union{ sphere{<0, 0, (-Diode2Length/2)+Diode2Radius+GlassThickness>, Diode2Radius-GlassThickness} cylinder{<0, 0, (-Diode2Length/2)+Diode2Radius+GlassThickness>,<0, 0, (Diode2Length/2)-Diode2Radius-GlassThickness>,Diode2Radius-GlassThickness} sphere{<0, 0, ( Diode2Length/2)-Diode2Radius-GlassThickness>, Diode2Radius-GlassThickness} texture{T_Diode2Core} } } #end /******************************** * Put diode together with wire * ********************************/ #macro Diode(DType, Type, PinPitch, Depth) #if (DType=1) #local CurrentDiode = Diode1(); #local CurrentLength = Diode1Length; #local CurrentRadius = Diode1Radius; #else #local CurrentDiode = Diode2(); #local CurrentLength = Diode2Length; #local CurrentRadius = Diode2Radius; #end // Work out which way up the diode is, and which wire mount to use // --------------------------------------------------------------- // there are four types of resistor: // 0 - horizontal with no wire // 1 - horizontal with a straight wire // 2 - horizontal with a bent wire // 3 - vertical with a recurved wire #switch (Type) #case (0) object{ CurrentDiode translate CurrentLength/2*z translate CurrentRadius*y } #break #case (1) union{ object{CurrentDiode} object{WireStraight(PinPitch)} translate CurrentLength/2*z translate CurrentRadius*y } #break #case (2) union{ object{CurrentDiode} object{WireBent(PinPitch, Depth)} translate ((PinPitch/2))*z translate CurrentRadius*y } #break #case (3) union{ object{CurrentDiode} object{WireRecurve(PinPitch, Depth)} rotate 90*x translate CurrentLength/2*y } #break #end #end /************* * Finish up * *************/ #end