|
|
Sven Littkowski <I### [at] SvenLittkowskiname> wrote:
> Hi,
>
> if I want to distribute railing posts around the edge of a regular
> CYLINDER (scale 1.0) it is easy: I would use something like
>
> object
> {
> RailingPost
> translate < MyCylinderRadius, 0.0, 0.0 >
> rotate < 0.0, MyAngle, 0.0 >
> }
>
> But what would be the formula for distribution, if the cylinder has been
> scaled unevenly, like this:
>
> cylinder { < 0.0, 0.0, 0.0 > < 0.0, 1.0, 0.0 > scale < 0.5, 1.0, 1.0 > }
.....
At the Wikipedia page that Christoph linked to there is a method for a somewhat
even distribution of points around an ellipse:
https://en.wikipedia.org/wiki/Ellipse#Steiner_generation_of_an_ellipse
Try my code below to experiment with this method.
Tor Olav
http://subcube.com
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
#version 3.7;
#include "colors.inc"
global_settings { assumed_gamma 1.0 }
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
#declare A = 2; // Semi-major axis
#declare B = 1; // semi-minor axis
#declare R = 0.05;
#declare T = 0.20;
#declare D = 0.21;
cylinder {
-T*y, +T*y, 1
scale <A, 1, B>
pigment { color Blue }
}
#declare Nil = 1e-9;
#declare Spline1 =
spline {
linear_spline
0 , <+A, 0, 0>
10 , <+A, 0, +2*B>
20 - Nil, <-A, 0, +2*B>
20 , <-A, 0, +B> // or <-A, 0, -B>
20 + Nil, <-A, 0, -2*B>
30 , <+A, 0, -2*B>
40 , <+A, 0, 0>
}
#declare Spline2 =
spline {
linear_spline
0, <+A, 0, +2*B>
10, <-A, 0, +2*B>
20, <-A, 0, 0>
30, <-A, 0, -2*B>
40, <+A, 0, -2*B>
}
#declare Step = 1; // Also try 0.5 and 2
#declare I = 0;
#while (I < 40)
#declare p1 = Spline1(I);
#declare p2 = Spline2(I);
#declare E = (p1.x + A)*p2.z;
#declare F = (p2.x - A)*p1.z;
#declare pS = A/(E - F)*<E + F, 0, 2*p1.z*p2.z>;
cylinder {
-D*y, +D*y, R
translate pS
pigment { color White }
}
#declare I = I + Step;
#end // while
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
camera {
location 4*y
look_at 0*y
sky z
}
light_source {
100*y
color White
}
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
Post a reply to this message
|
|