POV-Ray : Newsgroups : povray.general : HELP - Rotating Railing Posts around Scaled Cylinder Edge Server Time
28 Mar 2024 18:09:05 EDT (-0400)
  HELP - Rotating Railing Posts around Scaled Cylinder Edge (Message 7 to 16 of 16)  
<<< Previous 6 Messages Goto Initial 10 Messages
From: Sven Littkowski
Subject: Re: HELP - Rotating Railing Posts around Scaled Cylinder Edge
Date: 29 Mar 2018 19:55:36
Message: <5abd7cf8$1@news.povray.org>
GREAT WORK!

Thanks, well-appreciated. This formula will help me a lot to develop my
ship!

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

From: Sven Littkowski
Subject: Re: HELP - Rotating Railing Posts around Scaled Cylinder Edge
Date: 29 Mar 2018 19:59:24
Message: <5abd7ddc$1@news.povray.org>
Thanks a lot! I admit, I did not even know, how to search for this topic
(what search phrase to use). This helps me a lot.

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: HELP - Rotating Railing Posts around Scaled Cylinder Edge
Date: 29 Mar 2018 21:30:00
Message: <web.5abd9109862735803f1561fd0@news.povray.org>
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

From: Thomas de Groot
Subject: Re: HELP - Rotating Railing Posts around Scaled Cylinder Edge
Date: 30 Mar 2018 02:44:48
Message: <5abddce0$1@news.povray.org>
It took me a while to find what I was looking for. I think this would 
help: vaxis_rotate. See test file.

-- 
Thomas


Post a reply to this message


Attachments:
Download 'vaxis_rotate_test.pov.txt' (2 KB)

From: Bald Eagle
Subject: Re: HELP - Rotating Railing Posts around Scaled Cylinder Edge
Date: 30 Mar 2018 09:30:01
Message: <web.5abe3ac186273580c437ac910@news.povray.org>
That's a very nice construction, TOK!  :)
It took me a minute look it all over and see what was going on - the diagram and
animation on that page really help.
It's so nice to have many different ways to construct the same shape, but with
different results in the point-by-point details.

I'll need to look at TdG's code, but it seems to be very similar to a way I was
thinking of that would show how the ellipse is the uneven scaling of a circle.

With radius and angle, use transforms to "move" a vector to a place on the
circle, then using scaling transforms, adjust it to be elliptical.
Then an "overall scaling" transform could be applied after that as well.


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: HELP - Rotating Railing Posts around Scaled Cylinder Edge
Date: 30 Mar 2018 11:20:00
Message: <web.5abe546386273580e891b8fb0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> That's a very nice construction, TOK!  :)

Thank you Bill :)


> It took me a minute look it all over and see what was going on - the diagram and
> animation on that page really help.

Yes, that animation helped me much too.


> It's so nice to have many different ways to construct the same shape, but with
> different results in the point-by-point details.

I Agree. And as you have probably noticed, I'm find it interesting when problems
like these can be solved without trigonometry.


> I'll need to look at TdG's code, but it seems to be very similar to a way I was
> thinking of that would show how the ellipse is the uneven scaling of a circle.
>
> With radius and angle, use transforms to "move" a vector to a place on the
> circle, then using scaling transforms, adjust it to be elliptical.
> Then an "overall scaling" transform could be applied after that as well.

Yes, that is a possible way of doing it. But if Sven wants to place the fence
posts evenly along his elliptic shape, then that way is more problematic,
because the distances between the posts will then wary quite much.

I see now that it was you that linked to the Wikipedia page. Christoph linked to
a StackExchange page. Sorry about that.

And on that StackExchange page Dr. Martin von Gagern mentions that a way to
calculate the coordinates of such evenly distributed points is to calculate
complete and incomplete elliptic integrals of the second kind and then do some
numerical solving (and more). I started to make code for that, but before I
finished it I found that an it could be done with much less effort in POV-Ray
with some more linear splines. (My way may not be not as good as MvG's solution,
but I suspect that it is good enough for Sven's purpose.) See the code below for
this.

Tor Olav
http://subcube.com

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Distributing points evenly around an ellipse
// By Tor Olav Kristensen
// ===== 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 T = 0.010; // Height of elliptic cylinder
#declare D = 0.011; // Height of the small sylinders
#declare R = 0.04; // Radius of the small cylinders

#declare A = 2; // Semi-major axis
#declare B = 1; // Semi-minor axis

cylinder {
    -T*y, +T*y, 1
    scale <A, 1, B>
    pigment { color Blue }
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare Nil = 1e-9;
#declare Spline1 =
    spline {
        linear_spline
        0.00      , <+A, 0,    0>
        0.25      , <+A, 0, +2*B>
        0.50 - Nil, <-A, 0, +2*B>
        0.50      , <-A, 0,   +B>  // or <-A, 0, -B>
        0.50 + Nil, <-A, 0, -2*B>
        0.75      , <+A, 0, -2*B>
        1.00      , <+A, 0,    0>
    }

#declare Spline2 =
    spline {
        linear_spline
        0.00, <+A, 0, +2*B>
        0.25, <-A, 0, +2*B>
        0.50, <-A, 0,    0>
        0.75, <-A, 0, -2*B>
        1.00, <+A, 0, -2*B>
    }

#declare NrOfSteps = 1000;
#declare dS = 1/NrOfSteps;

#declare EllipseSpline =
    spline {
        linear_spline
        #for (I, 0, NrOfSteps)
            #declare S = I*dS;
            #declare p1 = Spline1(S);
            #declare p2 = Spline2(S);
            #declare E = (p1.x + A)*p2.z;
            #declare F = (p2.x - A)*p1.z;
            S, A/(E - F)*<E + F, 0, 2*p1.z*p2.z>
        #end // while
    }

#declare LengthSpline =
    spline {
        linear_spline
        #declare LengthSum = 0;
        #declare pP = EllipseSpline(0);
        #for (I, 0, NrOfSteps)
            #declare S = I*dS;
            #declare pN = EllipseSpline(S);
            #declare Length = vlength(pN - pP);
            #declare LengthSum = LengthSum + Length;
            S, LengthSum*<1, 1>
            #declare pP = pN;
        #end // for
    }

#declare TotalLength = LengthSpline(1).u;

#declare InverseLengthSpline =
    spline {
        linear_spline
        #for (I, 0, NrOfSteps)
            #declare S = I*dS;
            #declare Length = LengthSpline(S).u;
            #declare NL = Length/TotalLength;
            NL, S*<1, 1>
        #end // for
    }

#declare dNL = 1/NrOfSteps;
#declare UniformIntervalsSpline =
    spline {
        linear_spline
        #for (I, 0, NrOfSteps)
            #declare NL = I*dNL;
            #declare S = InverseLengthSpline(NL).u;
            NL, EllipseSpline(S)
        #end // for
    }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare NrOfCylinders = 40;

#declare Cylinders =
    union {
        #for (I, 1, NrOfCylinders)
            #declare pS = UniformIntervalsSpline(I/NrOfCylinders);
            cylinder {
                -D*y, +D*y, R
                translate pS
            }
        #end // for
    }

object {
    Cylinders
    pigment { color Yellow }
}

// ===== 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

From: Sven Littkowski
Subject: Re: HELP - Rotating Railing Posts around Scaled Cylinder Edge
Date: 30 Mar 2018 19:07:13
Message: <5abec321$1@news.povray.org>
Yes, it is. Big thanks!!!





On 29.03.2018 20:26, Tor Olav Kristensen wrote:
> #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

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

From: Sven Littkowski
Subject: Re: HELP - Rotating Railing Posts around Scaled Cylinder Edge
Date: 30 Mar 2018 19:10:08
Message: <5abec3d0@news.povray.org>
And yet another method! thanks a lot, Thomas!

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

From: Thomas de Groot
Subject: Re: HELP - Rotating Railing Posts around Scaled Cylinder Edge
Date: 31 Mar 2018 02:49:14
Message: <5abf2f6a$1@news.povray.org>
On 31-3-2018 1:10, Sven Littkowski wrote:
> And yet another method! thanks a lot, Thomas!
> 

Beware though, that my solution is problematic for equidistant posts, 
like Tor Olaf rightly mentioned above.

-- 
Thomas


Post a reply to this message

From: Sven Littkowski
Subject: Re: HELP - Rotating Railing Posts around Scaled Cylinder Edge
Date: 31 Mar 2018 03:24:14
Message: <5abf379e@news.povray.org>
Yes, noted. But I copied all versions into one memory file. Soon, when
reaching the need to elliptically place posts, I will make my
experiences. :-)

If it is not so well for equally spaced posts, it is still good to place
single items.

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

<<< Previous 6 Messages Goto Initial 10 Messages

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