POV-Ray : Newsgroups : povray.text.scene-files : Gear macro Server Time
31 Oct 2024 21:30:40 EDT (-0400)
  Gear macro (Message 1 to 1 of 1)  
From:
Subject: Gear macro
Date: 17 May 2005 17:29:26
Message: <428a6236$1@news.povray.org>
One day I needed some gears in my scene, so I created a gear macro.  I want 
to share it with you great folks.  I hope to post some new macros soon, as 
I'm reading about gear theory and formulas.

Regards

Werner Vesteraas
Oslo, Norway
---
#version 3.6;

global_settings {
  assumed_gamma 1.0
}

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

camera {
  location  <-1, 1, -1>
  look_at   <0.0, 0.0,  0.0>
}

light_source {
  <0, 0, 0>            // light's position (translated below)
  color rgb <1, 1, 1>  // light's color
  translate <-30, 30, -60>
}


#macro Gear(NumTeeth, Diameter, Thickness)
  #macro Tooth()
    prism {
      linear_sweep
      linear_spline
      -1,
      1,
      7,
      <-1, -1.5>,
      <-1, 0>,
      <-0.5, 1>,
      <0.5, 1>,
      <1, 0>,
      <1, -1.5>,
      <-1, -1.5>
      rotate -90 * x
      scale 0.5
    }
  #end
  union {
    union {
      #declare T=NumTeeth;
      #declare A=0;
      #while (A < 360)
        object {
          Tooth()
          translate <0, T / pi, 0>
          rotate z * A
        }
        #declare A = A + 360 / T;
      #end
      scale 1 / (T / pi)
    }
    cylinder {
      <0, 0, -(1 / (T / pi) / 2)>,
      <0, 0, (1 / (T / pi) / 2)>,
      1 - (1 / (T / pi) / 2)
    }
    scale <0.5 * Diameter, 0.5 * Diameter, (T / pi) * 2 * Thickness>
  }
#end

object {
  Gear(84, 0.867, 0.01)
  pigment { color rgb <1, 1, 1> }
}

object {
  Gear(7, 0.0848, 0.05)
  pigment { color rgb <1, 1, 1> }
}


Post a reply to this message

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