POV-Ray : Newsgroups : povray.advanced-users : Manipulator arm design : Re: Manipulator arm design Server Time
29 Jul 2024 00:26:58 EDT (-0400)
  Re: Manipulator arm design  
From: David Wallace
Date: 17 Jul 2003 23:38:12
Message: <3f176ba4@news.povray.org>
Here is an advanced example of what I'm after:

// Arm

#declare atabHgt = 0.035;
#declare atabHgtB = atabHgt+0.015;
#declare atabThk = 0.005;
#declare atabRadL = 0.055;
#declare atabRadH = 0.075;
#declare atabRadC = atabRadL-atabThk;

#declare ataRadO = atabRadC-atabThk;
#declare ataRadI = ataRadO-atabThk;

#declare ataBase = union {
 difference {
  cone { 0, atabRadH, y*atabHgt, atabRadL }
  cylinder { y*atabThk, y*atabHgtB, atabRadC }
 }
 cylinder { y*atabThk, y*atabHgtB, atabThk*2 }
 sphere { y*atabHgtB, ataRadI }
}

#macro atasLow(ht) difference {
 #local fg = ataRadI+atabThk;
 #local lp = (ataRadI+ataRadO)*0.5;
 union {
  cylinder { -y*fg, y*ht, ataRadO }
  torus { lp, atabThk translate -y*fg }
 }
 box { <-1, -1.1, -1>, <1, -.0, 1> scale <atabRadH, fg, atabThk*.5> }
 cylinder { 0, -y*fg*1.1, ataRadI }
} #end

#macro atasHighB(ht, nf)
 #local fw = ataRadO*2/nf;
 #local fh = ataRadI/fw;
 #local rc = fw*0.5*(nf-2);
 #local hc = ht+0.5*ataRadI;
 #local knob = union {
  cylinder { -x*rc, x*rc, fw }
  sphere { -x*rc, fw }
  sphere { x*rc, fw }
 }
 union {
  difference {
   box { <-1, 0, -1>, 1 }
   cylinder { -y, y*.4, 1 scale <1, 1, 0.3> translate -z }
   cylinder { -y, y*.4, 1 scale <1, 1, 0.3> translate z }
   sphere { 0, 1 scale <1, .4, .3> translate <0, .4,-1> }
   sphere { 0, 1 scale <1, .4, .3> translate <0, .4, 1> }
   scale <rc, hc, fw>
  }
  cylinder { 0, y*hc, fw translate x*rc }
  cylinder { 0, y*hc, fw translate -x*rc }
  object { knob }
  object { knob scale < 1, fh, 1> translate y*hc }
  scale < 1, 1, nf*.5>
 }
#end

#macro atasHighI(ht, nf) difference {
 #local fw = ataRadO/nf;
 atasHighB(ht, nf)
 #local ps = -1.5-nf*.5;
 #local nm = 0;
 #while (nm<nf)
  box {
   <-1.0, 0,-1.1>, < 1.0, 2.1, 1.1> scale <fw, ataRadI, ataRadO>
   translate <ps*fw, ht, 0>
  }
  #set ps = ps + 4;
  #set nm = nm + 2;
 #end
} #end

#macro atasHighO(ht, nf) difference {
 #local fw = ataRadO/nf;
 atasHighB(ht, nf)
 #local ps = 0.5-nf*.5;
 #local nm = 1;
 #while (nm<nf)
  box {
   <-1.0, 0,-1.1>, < 1.0, 2.1, 1.1> scale <fw, ataRadI, ataRadO>
   translate <ps*fw, ht, 0>
  }
  #set ps = ps + 4;
  #set nm = nm + 2;
 #end
} #end

#declare atasL = 0.16;
#declare atasH = 2*ataRadI+atasL;

#declare ataSectB = union {
 object { atasLow(atasL*.5) }
 object { atasHighO(atasL*.5,5) translate y*atasL*.5 }
 translate y*ataRadI
}

#declare ataSectM = union {
 object { atasHighI(atasL*.5,5) rotate x*180 }
 object { atasHighO(atasL*.5,5) }
 translate y*atasH*.5
}

#declare ataSectH = union {
 object { atasHighI(atasL*.5,5) rotate x*180 }
 object { atasHighI(atasL*.5,9) }
 translate y*atasH*.5
}

#declare ataObjs = array[6] { ataBase, ataSectB, ataSectM, ataSectM,
ataSectM, ataSectH }
#declare ataLens = array[6] { atabHgtB, atasH, atasH, atasH, atasH, atasH }
#declare ataAngles = array[5] { <-40, 20, 35>, x*26, x*30 , x*28, x*33 }
#declare ataMoves = array[5]

#macro ManipArm(Objects, Lengths, Joints, Moves)
 #local aSiz = dimension_size(Joints,1);
 #debug concat(str(aSiz,0,0), " objects.\n")
 #local ps = 0;
 #while (ps<aSiz)
  #local rt = ps;
  #declare Moves[ps] = transform {
   #while (rt>=0)
    rotate Joints[rt]
    translate y*Lengths[rt]
    #local rt = rt - 1;
   #end
  }
  #local ps = ps + 1;
 #end
 union {
  #set ps = 0;
  object { Objects[ps] }
  #while (ps<aSiz)
   #local ps = ps + 1;
   object { Objects[ps] transform { Moves[ps-1] } }
  #end
 }
#end

#declare atArm = object {
 ManipArm(ataObjs, ataLens, ataAngles, ataMoves)
}

Well, what do you think?


Post a reply to this message

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