POV-Ray : Newsgroups : povray.advanced-users : how to create a random coil : Re: how to create a random coil Server Time
5 Jul 2024 16:09:37 EDT (-0400)
  Re: how to create a random coil  
From: Chris B
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

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