POV-Ray : Newsgroups : povray.general : HELP - Rotating Railing Posts around Scaled Cylinder Edge Server Time
29 Mar 2024 02:58:17 EDT (-0400)
  HELP - Rotating Railing Posts around Scaled Cylinder Edge (Message 11 to 16 of 16)  
<<< Previous 10 Messages Goto Initial 10 Messages
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 10 Messages Goto Initial 10 Messages

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