POV-Ray : Newsgroups : povray.advanced-users : Manipulator arm design : Re: Manipulator arm design Server Time
29 Jul 2024 00:32:14 EDT (-0400)
  Re: Manipulator arm design  
From: Mike Williams
Date: 18 Jul 2003 02:28:41
Message: <L+GBwEAwL5F$Ewe4@econym.demon.co.uk>
Wasn't it David Wallace who wrote:
>Well, what do you think?

I think:

global_settings { assumed_gamma 1.0 }
camera { location  <10,20,-60> look_at <20, 20, 0>}
light_source {<-1000,1000,-1000> colour rgb 1}
plane {y,0 pigment {rgb 0.8}}
box {<-4,0,-4>,<4,3,4> pigment {rgb <0.45, 0.49, 0.60>}}

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

// Hand unit
#declare Hand = union {
  cylinder {<0,0,-1><0,0,1>,1}
  cylinder {<0,0,-1.1><0,0,1.1>,0.5 pigment {rgb 1}}
  difference {box {<-3,0,-0.7>,<0,3,0.7> rotate -z*45}  
    plane {x,0}
    scale <0.5,1,1>
    rotate -z*10
  } 
  difference {box {<-3,0,-0.7>,<0,3,0.7> rotate -z*45}  
    plane {-x,0}
    scale <0.5,1,1>
    rotate z*10
  } 
  pigment {rgb 0.7}
}

// Subsection
#macro maSection (Length)
union {
    box { <-2, 0, -1>, <-1, Length-1, 1> }
    cylinder { x*-2, x*-1, 1 }
    box { < 1, 0, -1>, < 2, Length-1, 1> }
    cylinder { x*2, x*1, 1 }
    box { <-1, 1, -1>, <1, Length, 1> }
    cylinder { <-1, Length, 0>, <1, Length, 0>, 1 }
    cylinder { <-2.2, 0, 0>,<2.2,0,0>, 0.5 pigment {rgb 1}}
    texture { pigment { rgb <0.45, 0.49, 0.60> } }
}
#end

#declare Unit1 = union {
  box {<-1.5,1,-1.5>,<1.5,2,1.5>}
  box {<-2,0,-1>,<-1,1,1>}
  box {<1,0,-1>,<2,1,1>}
  cylinder {<-2,0,0><-1,0,0>,1}
  cylinder {<2,0,0><1,0,0>,1}
  cylinder {<-2.2,0,0><2.2,0,0>,0.5 pigment {rgb 1}}
}

#declare Unit2 = union {
  box {<-1.5,1,-1.5>,<1.5,2,1.5>}
  box {<-1,0,-1>,<1,1,1>}
  cylinder {<-1,0,0><1,0,0>,1}
}


#macro Section (Length,Shaft,Start,End)
union {
  #switch (Shaft)
    #case (1)
      box {<-1.5,2,-1.5><1.5,Length-2,1.5>}
    #break
    #case (2)
      cylinder {<0,2,0>,<0,Length-2,0>,1.2 pigment {rgb 1}}
    #break
    #case (3)
      cylinder {<0.5,2,0>,<0.5,Length-2,0>,1 pigment {rgb 1}}
      cylinder {<-0.5,2,0>,<-0.5,Length-2,0>,1 pigment {rgb 1}}
    #break
    #case (4)
      cylinder {<0,2,0.5>,<0,Length-2,0.5>,1 pigment {rgb 1}}
      cylinder {<0,2,-0.5>,<0,Length-2,-0.5>,1 pigment {rgb 1}}
    #break
  #end
  #switch (Start)
    #case (1)
      object {Unit1}
    #break
    #case (2)
      object {Unit2}
    #break
  #end
  #switch (End)
    #case (1)
      object {Unit1 scale <1,-1,1> translate y*Length}
    #break
    #case (2)
      object {Unit2 scale <1,-1,1> translate y*Length}
    #break
  #end
  texture { pigment { rgb <0.45, 0.49, 0.60> } }
}
#end


// Array for 6 subunits
// Each subunit has: [0] Length
//                   [1] Angle
//                   [3] Shaft type
//                   [4] Start type
//                   [5] End type
// The final section is different. The hand has:
//                   [0] scale
//                   [1] Angle
//                   [2] Rotation
#declare maInfo = array [6][5] {
 // Len Ang Shf Str End
    {10,-10, 1,  1,  2},
    {15, 45, 2,  1,  2},
    {8,  29, 4,  1,  1},
    {8, -10, 2,  2,  1},
    {7,  15, 3,  2,  1},
 // Siz Ang Rot
    {1.5, 0,45,  0,  0}  // Hand section
 }       


//Connection macro
#macro ManipArm(Info)
 #local ps = dimension_size(Info,1) - 1;
 #local Arm = object {Hand 
     scale Info[ps][0] 
     rotate y*Info[ps][2] 
     rotate x*Info[ps][1]
 }
 #local ps=ps-1;
 #while (ps>=0)
   #local Arm = union {
     object {Arm 
       translate y*Info[ps][0]
     }
     object {Section(Info[ps][0], Info[ps][2], Info[ps][3],
Info[ps][4],)}
     rotate x*Info[ps][1]
   }
   #local ps = ps-1;
 #end
 object {Arm}
#end

//Invocation
object {ManipArm(maInfo) 
  rotate y*140
}


Post a reply to this message

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