Posted by deckingman

Need expert help -my maths isn't up to this July 12, 2017 01:56PM |
Registered: 1 year ago Posts: 444 |

Hope someone can help me. Basically what I need to do is have a number of cylindrical objects, spaced evenly around a circle but angled out at 28 degrees from the vertical. So all pointing at some origin if you get my meaning. I've managed to crib the following snippets from browsing (but I have no idea how it works).

pathRadius=nnn;

num=5;

for (i=[1:num]) {

translate ([pathRadius*cos(i*(360/num)), pathRadius*sin(i*(360/num)), 0])

rotate ([??????]) // this is the bit I'm stuck with

}

So the translate with pathRadius thing puts them in a circle but my maths isn't good enough to work out what I need to do to rotate them so that they are 28 degrees off the vertical. Obviously they need to be rotated in both X and Y by some amount which varies according to placement around the circle but I'm not clever enough to know what the formula is.

Any help would be very much appreciated.

pathRadius=nnn;

num=5;

for (i=[1:num]) {

translate ([pathRadius*cos(i*(360/num)), pathRadius*sin(i*(360/num)), 0])

rotate ([??????]) // this is the bit I'm stuck with

}

So the translate with pathRadius thing puts them in a circle but my maths isn't good enough to work out what I need to do to rotate them so that they are 28 degrees off the vertical. Obviously they need to be rotated in both X and Y by some amount which varies according to placement around the circle but I'm not clever enough to know what the formula is.

Any help would be very much appreciated.

Re: Need expert help -my maths isn't up to this July 12, 2017 06:12PM |
Registered: 2 years ago Posts: 109 |

You do not need to do all those calculations.

Create an module of one object at the distance from center and angle you want.

Then rotate the number of modules you need using a for loop

SAMPLE CODE:

pathRadius=15;

num=5;

objHeight = 20;

objDia = 5;

module cylObj()

{

translate([pathRadius,0,objHeight/2]) //move out 15 from center

rotate([0,-28,0]) // rotate 28 degrees

cylinder(h = objHeight, d =objDia,center= true, $fn = 32); //object

}

//for(variable = [start : increment : end])

for(i = [1:1:num]) // 5 objects 1 to 5

{

rotate([0,0,i*(360/num)]) // rotate 360 degrees / 5 objects

cylObj(); // object to rotate

}

Create an module of one object at the distance from center and angle you want.

Then rotate the number of modules you need using a for loop

SAMPLE CODE:

pathRadius=15;

num=5;

objHeight = 20;

objDia = 5;

module cylObj()

{

translate([pathRadius,0,objHeight/2]) //move out 15 from center

rotate([0,-28,0]) // rotate 28 degrees

cylinder(h = objHeight, d =objDia,center= true, $fn = 32); //object

}

//for(variable = [start : increment : end])

for(i = [1:1:num]) // 5 objects 1 to 5

{

rotate([0,0,i*(360/num)]) // rotate 360 degrees / 5 objects

cylObj(); // object to rotate

}

Re: Need expert help -my maths isn't up to this July 13, 2017 12:11AM |
Registered: 1 year ago Posts: 444 |

Sorry, only registered users may post in this forum.