POV-Ray : Newsgroups : povray.advanced-users : how to create a random coil Server Time
31 Oct 2024 10:23:42 EDT (-0400)
  how to create a random coil (Message 1 to 4 of 4)  
From: zj905
Subject: how to create a random coil
Date: 17 Oct 2007 20:30:01
Message: <web.4716a8faa1216bf14f7090800@news.povray.org>
how to draw some random chains grafted on the surface? Thanks.


Post a reply to this message

From: Chris B
Subject: Re: how to create a random coil
Date: 19 Oct 2007 15:15:37
Message: <47190259$1@news.povray.org>
"zj905" <zj9### [at] hotmailcom> wrote in message 
news:web.4716a8faa1216bf14f7090800@news.povray.org...
> how to draw some random chains grafted on the surface? Thanks.
>

I assume you mean a sort of heap on the floor or something like that.
I've seen some POV-Ray chain macros about, but a quick Google didn't lead me 
to any of them.

If I were doing this from scratch I'd probably start by defining a spline, 
using a sphere sweep to check that it defined a suitably random looking path 
across the surface in question and building it up so that successive loops 
didn't intersect each other.

Next I'd define a chain link (e.g. two half torii and two cylinders CSG'd 
together) such that the centre of the metal at one end of the link is at the 
origin with the link in a clearly defined orientation (e.g. standing upright 
and aligned with the Z-axis).

To position each chain link you need to keep a record of where the current 
link is on the spline. Retrieve the coordinates of a point further along the 
spline by  incrementing the spline value until the distance between the two 
points equals the distance from the inner edge of one torus to the inner 
edge of the other. This gives you the position of the next link. The 
difference between the two coordinates gives you a vector representing the 
'lateral' orientation of the current link. Now rotate the current link 
(still at the origin) along its length so that it's between 30 degrees and 
150 degrees off that of the previous link (you could use randomness or a 
more gravity based algorithm), use Reorient_Trans to orient it to the 
'lateral' orientation, then translate it to the current link position.

Now your new point becomes your current point and you repeat until you reach 
the end of your chain.

Hope this helps.

Regards,
Chris B.


Post a reply to this message

From: zj905
Subject: Re: how to create a random coil
Date: 19 Oct 2007 19:00:01
Message: <web.471935d2144555e34849a21c0@news.povray.org>
Thanks for your detailed help. I really appreciate that. Another reader also
mentioned spline method. http://www.geocities.com/ccolefax/spline/index.html
The question is: this method can build one random chain. If the surface were
grafted with hundreds or thousands of chains, how to do? Is there any random
function available to generate the spline path?
"Chris B" <c_b### [at] btconnectcom> wrote:
> "zj905" <zj9### [at] hotmailcom> wrote in message
> news:web.4716a8faa1216bf14f7090800@news.povray.org...
> > how to draw some random chains grafted on the surface? Thanks.
> >
>
> I assume you mean a sort of heap on the floor or something like that.
> I've seen some POV-Ray chain macros about, but a quick Google didn't lead me
> to any of them.
>
> If I were doing this from scratch I'd probably start by defining a spline,
> using a sphere sweep to check that it defined a suitably random looking path
> across the surface in question and building it up so that successive loops
> didn't intersect each other.
>
> Next I'd define a chain link (e.g. two half torii and two cylinders CSG'd
> together) such that the centre of the metal at one end of the link is at the
> origin with the link in a clearly defined orientation (e.g. standing upright
> and aligned with the Z-axis).
>
> To position each chain link you need to keep a record of where the current
> link is on the spline. Retrieve the coordinates of a point further along the
> spline by  incrementing the spline value until the distance between the two
> points equals the distance from the inner edge of one torus to the inner
> edge of the other. This gives you the position of the next link. The
> difference between the two coordinates gives you a vector representing the
> 'lateral' orientation of the current link. Now rotate the current link
> (still at the origin) along its length so that it's between 30 degrees and
> 150 degrees off that of the previous link (you could use randomness or a
> more gravity based algorithm), use Reorient_Trans to orient it to the
> 'lateral' orientation, then translate it to the current link position.
>
> Now your new point becomes your current point and you repeat until you reach
> the end of your chain.
>
> Hope this helps.
>
> Regards,
> Chris B.


Post a reply to this message

From: Chris B
Subject: Re: how to create a random coil
Date: 20 Oct 2007 06:58:01
Message: <4719df39$1@news.povray.org>
"zj905" <zj9### [at] hotmailcom> wrote in message 
news:web.471935d2144555e34849a21c0@news.povray.org...
> Thanks for your detailed help. I really appreciate that. Another reader 
> also
> mentioned spline method. 
> http://www.geocities.com/ccolefax/spline/index.html
> The question is: this method can build one random chain. If the surface 
> were
> grafted with hundreds or thousands of chains, how to do? Is there any 
> random
> function available to generate the spline path?

Hundreds sounds a lot (thousands sound a lot more). Depending upon the 
effect that you're trying to achieve and the resolution you're planning to 
render in, you're unlikely to actually see most of them as distincts 
links/chains, so you may want to consider simulating most of the chains, 
with maybe 3 or 4 more 'authentic' ones in the foreground to give the 
impression that you've done them all.

IMO, the shape of a coil of chain beyond a certain distance could be 
simultated with a blob using a randomised ring of spherical components 
scaled vertically to squash it down a bit. You could apply a speckled 
semi-transparent texture to make it look like a vague heap of something.

At a middle distance you could use the same shape with a load of randomly 
placed chain links sticking out the surface, so that people can see some 
real links there.

Then, for a small number of chains that are close to the camera, I'd go for 
randomised splines to give chains that you can see in detail.

You could write a macro to generate a randomised path. For a coil you can 
use a while loop with the rand() function to adjust the distance from the 
centre of the coil and the amount of rotation in each step. For each point 
you identify on the circular sweep you can check back along the spline for 
points that are within a certain distance in x and z, then take the existing 
y value and add one chain width to raise the current position above the 
coincident position.

If you want to track a length of chain across other coils of chains you 
could build a CSG composite of the 'simulated' shapes and use the trace 
function to find the height of the top surface at the x,z location you wish 
to use in your spline.

Regards,
Chris B.


Post a reply to this message

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