POV-Ray : Newsgroups : povray.general : Equal distribution along stretched circle circumference - how to do it? Server Time
8 Aug 2024 04:08:24 EDT (-0400)
  Equal distribution along stretched circle circumference - how to do it? (Message 1 to 10 of 10)  
From: Jörg 'Yadgar' Bleimann
Subject: Equal distribution along stretched circle circumference - how to do it?
Date: 29 Mar 2001 11:34:34
Message: <3AC3424F.C767174E@ndh.net>
Hi POVers!

As preliminary work for Terragen-like flyover animations I started to
experiment with equal distribution of objects along a stretched circle
curve... in my example, the x axis of the "circle" is 40, while the z
axis is only 20 units, and I want to place 90 small spheres along its
circumference.

When using constant radial spacing, I observed that the distance between


respective values at opposite positions. I assume that the change in
radial position for each sphere to compensate this must be a cosinus
function, something like 2.0933321+0.6973522*cos(i*4) with i going from
0 to 89 (number of spheres), but up to now, I just failed to implement
this correctly into the translate statement.

For better understanding of my problem, I attached the complete scene
script; at clock=0 the oval will be rendered with constant radial
spacing, at clock=1 I intended to do compensating radial spacing...

Thanks in advance for your efforts,

Yadgar


Post a reply to this message


Attachments:
Download 'us-ascii' (2 KB)

From: Jan Walzer
Subject: Re: Equal distribution along stretched circle circumference - how to do it?
Date: 29 Mar 2001 13:35:00
Message: <3ac38054@news.povray.org>
IIRC you have to do some integration ... don't ask me how ...

All I can remember, was to start with the function for the path ...

       /x\   /cos(t)*40\
P(t): ( y )=( sin(t)*20 )    // this should look like vectors
       \z/   \    0    /

somehow you have now to integrate now for t
then you have to do something with this ...

when you have finished, you probably can simplify it and it's
possible, that the solution is something with cos(), but it's hard to
tell from here ...

Maybe someone here can help, or tell you where the formulas for this
kind of stuff are ...

--
background{rgb 1}camera{location<1,5,-2>look_at 0}#macro
m(a,b,i)#local d=(b-a)
/8;#local
e=vcross(d,y);#if(i)m(a-e,a+e+2*d,i-1)m(a+e,a+2*d-e,i-1)m(a+3*d-e,a+e
+3*d,i-1)m(a+3*d-e,a+5*d-e,i-1)m(a+6*d-e,a+e+6*d,i-1)m(a+8*d-e,a+e+8*d
,i-1)#else
cylinder{a,b,vlength(d)/3 pigment{rgb 0}}#end#end m(-4*x,2*x,4) // Jan
Walzer


Post a reply to this message

From: Christoph Hormann
Subject: Re: Equal distribution along stretched circle circumference - how to do it?
Date: 29 Mar 2001 14:05:10
Message: <3AC38761.D7A62011@gmx.de>
Jan Walzer wrote:
> 
> IIRC you have to do some integration ... don't ask me how ...
> 
> All I can remember, was to start with the function for the path ...
> 
>        /x\   /cos(t)*40\
> P(t): ( y )=( sin(t)*20 )    // this should look like vectors
>        \z/   \    0    /
> 
> somehow you have now to integrate now for t
> then you have to do something with this ...
> 

IIRC, integrating an elliptical curve is not possible in a mathematically
exact way.  Not totally sure about it though.  

Christoph

-- 
Christoph Hormann <chr### [at] gmxde>
IsoWood include, radiosity tutorial, TransSkin and other 
things on: http://www.schunter.etc.tu-bs.de/~chris/


Post a reply to this message

From: Francois Dispot
Subject: Re: Equal distribution along stretched circle circumference - how to do it?
Date: 29 Mar 2001 15:39:00
Message: <3AC3AB70.7FEA7CDC@club-internet.fr>
Christoph Hormann wrote:
> 
> Jan Walzer wrote:
> >
> > IIRC you have to do some integration ... don't ask me how ...
> >
> > All I can remember, was to start with the function for the path ...
> >
> >        /x\   /cos(t)*40\
> > P(t): ( y )=( sin(t)*20 )    // this should look like vectors
> >        \z/   \    0    /
> >
> > somehow you have now to integrate now for t
> > then you have to do something with this ...
> >
> 
> IIRC, integrating an elliptical curve is not possible in a mathematically
> exact way.  Not totally sure about it though.

Sure, no way. But you can try to approximate it using any numerical
integration method, even the most basic ones (split your ellipse in many
small segments...)

-- 

      __  __ __  __  _
|  | /  \  /  / |_  /  |/
\/\/ \__/ /_ /_ |__ \_ |\


Post a reply to this message

From: David Fontaine
Subject: Re: Equal distribution along stretched circle circumference - how to do it?
Date: 29 Mar 2001 18:02:51
Message: <3AC3BE64.7B625501@faricy.net>
x and z as a function of t:
x = 40 cos t
z = 20 sin t

arc length is the integral (sum) of distance formula (pythagorean theorem):
 /b   ___________________________
 |  \/(40 cos t)^2 + (20 sin t)^2 dt
 /a

find arc length of the total ellipse and divide by however many sections you want,
find where those arc
lengths are

this can only be done numerically. :( so Jan Cristoph & Francois are correct.

--
David Fontaine  <dav### [at] faricynet>  ICQ 55354965
My raytracing gallery:  http://davidf.faricy.net/


Post a reply to this message

From: Chris Colefax
Subject: Re: Equal distribution along stretched circle circumference - how to do it?
Date: 29 Mar 2001 18:19:26
Message: <3ac3c2fe@news.povray.org>

> As preliminary work for Terragen-like flyover animations I started to
> experiment with equal distribution of objects along a stretched circle
> curve... in my example, the x axis of the "circle" is 40, while the z
> axis is only 20 units, and I want to place 90 small spheres along its
> circumference.
>
> When using constant radial spacing, I observed that the distance between
>

> respective values at opposite positions. I assume that the change in
> radial position for each sphere to compensate this must be a cosinus
> function, something like 2.0933321+0.6973522*cos(i*4) with i going from
> 0 to 89 (number of spheres), but up to now, I just failed to implement
> this correctly into the translate statement.
>
> For better understanding of my problem, I attached the complete scene
> script; at clock=0 the oval will be rendered with constant radial
> spacing, at clock=1 I intended to do compensating radial spacing...

As others have pointed out, doing this in a mathematically exact way would
seem to be impossible.  The same is true of the functions for cubic spline
curves, as used in my Spline Macro File.  However, the file does allow even
spacing along any arbitrary cubic splines using a sampling method.  The file
also includes functions to simplying creating objects based on spline paths,
and animating objects along spline paths.  Creating circles and ellipses is
quite simple using the spline definition options (tip: a tension of -2/3
with four points gives a good circle).

You can find a full tutorial for the file and the downloadable ZIP package
here:

   http://www.geocities.com/ccolefax/spline


Post a reply to this message

From: David Buck
Subject: Re: Equal distribution along stretched circle circumference - how to do it?
Date: 30 Mar 2001 06:33:37
Message: <3AC46F98.2DEADB29@simberon.com>
I would suggest a simple but slow solution:  Guess the distance needed between the
points.  Generate the
required number of points that are that distance apart (simple Euclidean distance)
plus one more.  If that
last one is close enough to the first, stop.  If it's too short, increase the
distance.  If it's too far,
decrease it.  Each time, through, cut the step size in half (bisection algorithm).

For more accuracy, multiply the number of points to position by a fixed constant (say,
10 times), do the
above algorithm, then pick every tenth point.

It may be slow, but it will save you time trying to implement differential equation
solvers and it should
be fairly easy to code.

David Buck

David Fontaine wrote:

> x and z as a function of t:
> x = 40 cos t
> z = 20 sin t
>
> arc length is the integral (sum) of distance formula (pythagorean theorem):
>  /b   ___________________________
>  |  \/(40 cos t)^2 + (20 sin t)^2 dt
>  /a
>
> find arc length of the total ellipse and divide by however many sections you want,
find where those arc
> lengths are
>
> this can only be done numerically. :( so Jan Cristoph & Francois are correct.
>
> --
> David Fontaine  <dav### [at] faricynet>  ICQ 55354965
> My raytracing gallery:  http://davidf.faricy.net/


Post a reply to this message

From: David Buck
Subject: Re: Equal distribution along stretched circle circumference - how to do it?
Date: 30 Mar 2001 08:22:13
Message: <3AC4890D.4E089814@simberon.com>
I thought of an even better way using coding.  Divide the ellipse into, say, 1000
points based on equal angles
on a unit circle.  Calculate where these points reside on the ellipse.  Add up
Euclidean distances between
successive points to give 1000 arc lengths (from the degree mark to the given point)
and the total perimeter
of the ellipse. Now, divide the total perimeter by the number of markers you want to
position to give you the
distance between each marker.  Now it's easy to find the closest perimeter length for
each marker position.
You could even linearly interpolate or spline interpolate the final position, but it
shouldn't be necessary.

If you want results for one specific case, let me know and I wouldn't mind coding it
up and giving you the
results.  It's a pretty simple algorithm.

David Buck

David Buck wrote:

> I would suggest a simple but slow solution:  Guess the distance needed between the
points.  Generate the
> required number of points that are that distance apart (simple Euclidean distance)
plus one more.  If that
> last one is close enough to the first, stop.  If it's too short, increase the
distance.  If it's too far,
> decrease it.  Each time, through, cut the step size in half (bisection algorithm).
>
> For more accuracy, multiply the number of points to position by a fixed constant
(say, 10 times), do the
> above algorithm, then pick every tenth point.
>
> It may be slow, but it will save you time trying to implement differential equation
solvers and it should
> be fairly easy to code.
>
> David Buck
>
> David Fontaine wrote:
>
> > x and z as a function of t:
> > x = 40 cos t
> > z = 20 sin t
> >
> > arc length is the integral (sum) of distance formula (pythagorean theorem):
> >  /b   ___________________________
> >  |  \/(40 cos t)^2 + (20 sin t)^2 dt
> >  /a
> >
> > find arc length of the total ellipse and divide by however many sections you want,
find where those arc
> > lengths are
> >
> > this can only be done numerically. :( so Jan Cristoph & Francois are correct.
> >
> > --
> > David Fontaine  <dav### [at] faricynet>  ICQ 55354965
> > My raytracing gallery:  http://davidf.faricy.net/


Post a reply to this message

From: Wlodzimierz ABX Skiba
Subject: Re: Equal distribution along stretched circle circumference - how to do it?
Date: 30 Mar 2001 09:32:04
Message: <3ac498e4$1@news.povray.org>

> I started to
> experiment with equal distribution of objects along a stretched circle
> curve...

Have you seen my macro sended to p.b.images and p.b.scene-files with subject
"selfaproximation" (21-07-2000) - it shows how I resolved this problem.

ABX


Post a reply to this message

From: Jan Walzer
Subject: Re: Equal distribution along stretched circle circumference - how to do it?
Date: 31 Mar 2001 05:40:32
Message: <3ac5b420@news.povray.org>
Oh yes ...
I remember there was something called "eliptic integrals" ....
They were those that are not that easy (if at all) analytically
integratable...

I just remembered, we did something this way for having an even
distribution along parametric curves ...

Then do it numerically ;)


--
background{rgb 1}camera{location<1,5,-2>look_at 0}#macro
m(a,b,i)#local d=(b-a)
/8;#local
e=vcross(d,y);#if(i)m(a-e,a+e+2*d,i-1)m(a+e,a+2*d-e,i-1)m(a+3*d-e,a+e
+3*d,i-1)m(a+3*d-e,a+5*d-e,i-1)m(a+6*d-e,a+e+6*d,i-1)m(a+8*d-e,a+e+8*d
,i-1)#else
cylinder{a,b,vlength(d)/3 pigment{rgb 0}}#end#end m(-4*x,2*x,4) // Jan
Walzer


Post a reply to this message

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