POV-Ray : Newsgroups : povray.general : ball bearing geometry => Re: Is there a math formula for making... Server Time
5 Aug 2024 00:20:07 EDT (-0400)
  ball bearing geometry => Re: Is there a math formula for making... (Message 1 to 1 of 1)  
From: argus
Subject: ball bearing geometry => Re: Is there a math formula for making...
Date: 2 Feb 2003 01:33:09
Message: <3e3cbba5@news.povray.org>
"Patrick Dugan" <pat### [at] netinsnet> wrote in message
news:3e3c554a@news.povray.org...
> I couldn't explain the request within the subject line so I'll try to
> explain it here.  I am trying to create several sets of cylinders. The
first
> cylinder is located dead center <0,0,0> and has a radius of 1.5.  I want
to
> place smaller (maybe 80% or so smaller) cylinders around the outside edge
so
> that the cylinders all touch each other and touch the middle cylinder.
> (perhaps nine or so.) Then I want to make another set outside the last of
> cylinders (a little smaller still) that all touch each other and the
> cylinders below them.  I want to get smaller and smaller cylinders until
> they are very small (perhaps 0.1 or so) at a distance of +6 from center.
I
> am including a small (very poor) drawing of what I'm trying to accomplish
> (although I want the cylinders to go all the way around.)
>
> Is there some math formula that would correctly create these?
>
> Patrick (math impaired) Dugan
>

This is fairly simple ...
You have three related variables that depend on each other.
Radius of the 'shaft', radius of each cylinder in the surrounding ring,
and - most importantly - the number of cylinders in the surrounding
ring.

I've appended a sample scene that sets N (number of cylinders in ring)
and the radius of each cylinder in the ring. Then, the shaft radius is
calculated.

You can re-write the order of things so that you set any other two variables
and calculate the third - but you will find these things are almost always
designed by setting N first.

Play with this code by changing N and r.

Adding a second ring of cylinders and changing the dependent variable
is left as an exercise to the reader because it's good for you.

Anyway -

// first just some scene basics

global_settings {  assumed_gamma 2.2 }

#include "colors.inc"
#include "functions.inc"
#include "math.inc"
#include "consts"
#ifndef(cam_loc) #declare cam_loc=<0.00, 0.00, -10.00>; #end
#ifndef(cam_look) #declare cam_look=<0.00, 0.00, 0.00>; #end
#ifndef(focal_length) #declare focal_length=1.00; #end
#declare focal_length = 30;
#declare origin       = <0.000, 0.000,  0.000>;
#declare cam_loc      = <1.000, 1.000, -1.000>;
#ifndef(scene_cam)
 #declare scene_cam=
  camera{
   location  cam_loc * focal_length
   look_at  cam_look
  }
#end
#ifndef(main_light)
 #declare main_light=
   light_source{
    cam_loc * focal_length, color rgb <1.000, 1.000, 1.000>
   }
#end
camera{scene_cam}
object{main_light translate <0.000, 10.000, 0.000>}

plane{ z,  30.000 pigment{color White}}
plane{ y, -30.000 pigment{color White}}

//light_source{< 10.00, 40.00, -20.00>, color rgb<0.00, 0.20, 0.70>
spotlight point_at origin}
//light_source{<-10.00, 40.00, -20.00>, color rgb<0.00, 0.70, 0.20>
spotlight point_at origin}


// main section defining objects

#declare N =32;
#declare r =0.5;
#ifndef(N)    #declare N = 12; #end
#ifndef(r)    #declare r =  1; #end
#ifndef(cylZ) #declare cylZ = 10.000; #end
#declare d = 360/N;
#declare sin_d = sin(radians(d/2));
#declare R = (r/sin_d) -r;

#declare core =
 cylinder{
  origin, <0.000, 0.000, cylZ>, R
  open
  pigment{color rgb Yellow}
 }
#declare ring_element =
 cylinder{
  origin, <0.000, 0.000, cylZ>, r
  open
  pigment{color rgb Orange}
 }

// make the objects

object{core         no_shadow}

#declare n = 0;
#while (n<N)
  object{
   ring_element
   no_shadow
   translate <R + r, 0.000, 0.000>
   rotate <0.000, 0.000, n * d>}
  #declare n = n +1;
#end


Post a reply to this message

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