POV-Ray : Newsgroups : povray.advanced-users : Adding forces to points in curves : Re: Adding forces to points in curves Server Time
30 Jul 2024 06:22:35 EDT (-0400)
  Re: Adding forces to points in curves  
From: Chris Colefax
Date: 28 Dec 1999 19:05:34
Message: <3869504e@news.povray.org>
Rune <run### [at] inamecom> wrote:
> I'm trying to make a long neck-like thing. I must be able
> to set the point where the neck starts and ends. Also the
> normal of the neck in these two points. ("normal" is
> probably not the right word. "Vector" or "direction" is
> probably better, but I'll just use "normal" here) I also
> want to control the length of the neck and the number of
> "links" or segments it is made of. ( The length of each
> "link" would then be [length-of-neck] / [number-of-links] )
[snip]
> I have succeeded in making the points having the right
> distance to each other:
>
> A force is applied to each point. If the point is closer to
> it's neighbor than the desired length then it is pushed
> away from it. If the point is further away the neighbor
> than the desired length then it is pulled closer to it.
> This calculation is done to each sphere with each of each
> sphere's two neighbors. The difference between the old
> and the new position is multiplied with a small value (*1),
> then stored in a temporary array. When the calculations are
> done to each sphere, the changes are applied. Then it
> starts all over and over again a certain number of times (*2).
>
> This makes the point have the right distance to each other,
> but nothing prevents the "neck" from bending so
> unfortunately the points arrange themselves in a zig-zag
> pattern.
>
> I need help with making some forces that makes the "neck"
> bend as little as possible, i.e. make the distribution of
> the bending even, that way making the curve smooth.
> (look in "ikn.inc" line 45.)

To avoid confusion I think it helps to use the word 'tangent' when you're
talking about a vector tangential to the curve, particularly as 'normal' has
particular meanings in POV-Ray (and, of course, in any discussions about
mathematical curves and surfaces).

Now, given the example you posted to .binaries and your description of your
goal I would say the method you're using (inverse kinematics) is quite
suitable.  To avoid kinking perhaps you could apply an extra constraint to
each link which checks the angle it forms with the links around it, eg.
given three sphere centres (P1, P2, and P3) you could calculate the cosine
of the angle using:

   vdot (vnormalize (P2 - P1), vnormalize (P3 - P2))

To stop the kinking you want this to be as close as possible to -1 (the
cosine of 180 degrees), so in addition to being pulled by the endpoints and
tangents and being forced to be separated by a certain distance, the spheres
also try to form a straight line (or as close as possible given the other
constraints).


Post a reply to this message

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