POV-Ray : Newsgroups : povray.general : Help with 'Cloth'-grid thing Server Time
6 Aug 2024 17:00:13 EDT (-0400)
  Help with 'Cloth'-grid thing (Message 1 to 3 of 3)  
From: Andrew Cocker
Subject: Help with 'Cloth'-grid thing
Date: 5 Mar 2002 14:04:28
Message: <3c8516bc@news.povray.org>
I am wanting to code something similar to a cloth, as has been done by
several people recently, but with one main difference. I envisage my 'cloth'
(henceforth called Grid) to be made of fixed length connectors, not springs.
I am not trying to emulate any real-world behaviour, but am more concerned
with learning how to code such a thing. All I want to do at first is to drop
my Grid over a sphere. However, I really don't know where to start.

I need help/hints/pointing to tutorials which will help me set up my Grid,
connect the points (with either cylinders or as a mesh), check for
collisions with objects (a simple sphere and plane would suffice to help me
understand the process), and apply forces such as Gravity and Wind.

Basically, I am unsure of how to do almost all of the above... talk of Euler
and Runge-Kutta are *way* beyond me. Would anyone have any thoughts on how I
should proceed?

All the best,

Andy Cocker


Post a reply to this message

From: Apache
Subject: Re: Help with 'Cloth'-grid thing
Date: 6 Mar 2002 10:13:35
Message: <3c86321f$1@news.povray.org>
very short explanation:

(forward) Euler: simplest way of 'simulating' the behaviour of
grids/clothes. Just a step-by-step simulation that is very easy to code. The
steps have to be very small otherwise the grid/cloth will show weird and
erratic movements.

Runge-Kutta: slightly more complicated than Euler, but still not too
difficult to do. Time steps can be bigger and things will work fine.

Think about this: if all the connections between the nodes are incapable of
becoming longer/shorter the grid won't be able to bend in all directions. It
would be able able to bend in U, or V directions only. So If you'd drop the
grid over a sphere, the grid won't be able to fold over the sphere in a nice
way unless some parts of the grid are able to compress/expand.

How I started:
1. write povscript code with only 1 line of particles (about 30) with the
first locked (incapable of moving). Between each 2 particles I put a
connection (spring) that pulls those 2 particles together when they're too
far away. The spring pushes the 2 particles away from eachother when they're
too close. The spring force function is a linear function (imagine a
straight line from the third quadrant to the first with x=dispositioning of
particle and y=spring_force).

2. discover that with more particles povscript is a bit slow ;-)

3. port the thing to another programming language (c, c++, pascal, fortran?)
and increase the amount of springs. Example: particles A, B, C and D. Lowest
amount of springs possible: 3 (A-B, B-C and C-D). Increase the amount of
springs between particles and the thing will be stronger: A-B, A-C, B-C,
B-D, C-D.
And if you have a grid of 3x3 those will be the particles: A(0, 0), B(1, 0),
C(2, 0), D(0, 1), E(1, 1), F(2, 1), G(0, 2), H(1, 2), I(2, 2). The springs
in case the thing is supple: A-B, A-D, A-E, B-C, B-D, B-E, B-F, C-E, C-F,
D-E, D-G, D-H, E-F, E-G, E-H, E-I, F-H, F-I, G-H, H-I. (Hope I didn't forget
something.)
Calculating the forces is more efficient if you do it spring-by-spring
instead of particle-by-particle of course.
Collission detection with spheres is simple: if the distance between the
center of a sphere and a particle is smaller than or equal to the sphere's
radius, you're having a collission. Adding a temporary spring between the
colliding particle and the sphere's surface will prevent the particle to
enter the sphere. (In fact the system should detect the collission BEFORE
the happens, so you'll have to increasing the sphere's radius a bit.) There
are other ways of handling collission detection that are less simple but
maybe more interesting since the spring like grid-object collissions don't
involve friction IIRC.
--
Apache
http://geitenkaas.dns2go.com/experiments/
apa### [at] yahoocom


Post a reply to this message

From: Andrew Cocker
Subject: Re: Help with 'Cloth'-grid thing
Date: 6 Mar 2002 11:23:10
Message: <3c86426e$1@news.povray.org>
Thanks Apache, that points me in the right direction.

All the best,

Andy Cocker


Post a reply to this message

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