POV-Ray : Newsgroups : povray.unofficial.patches : Trouble with MechSim fields Server Time
1 Jun 2024 18:04:05 EDT (-0400)
  Trouble with MechSim fields (Message 1 to 9 of 9)  
From: ssssmemyself
Subject: Trouble with MechSim fields
Date: 20 Aug 2004 00:40:01
Message: <web.412580292d5d65e015c1769c0@news.povray.org>
I have been fooling around with MegaPov a bit lately and I've come up
against a brick wall. I am trying to simulate the buoyant force of water,
but I can't find out how to make a field with Vector_Function() that is
dependent on the position of masses. So far all I've seen is the example
Vector_Function(function{0}function{-1}function{0}), which is a constant
downward force. My code so far is this:

Before the mechsim{...} block
#declare Fn_Vector = function(x,y,z) {
  Vector_Function(
    function{0}
    function{
      #if (y>RADIUS)
        0
      #else
        #if (y<-RADIUS)
          9.81*4/3
        #else
          9.81*pi*(((y-r)*r*r-1/3*pow(y-r,3))-(-r*r*r-1/3*pow(-r,3)))
        #end
      #end
    }
    function{0}
  )
}

In the mechsim{...} block
field {
  function {
    Fn_Vector(x,y,z)
  }
}

When I try to render it throws an error because it is treating the "y" in
the first #if as <0,1,0> and not the argument of the function. I have tried
replacing x, y, and z with a, b, and c, but then it claims that b is an
uninitialized identifier. What am I doing wrong? Thanks in advance!


Post a reply to this message

From: Christoph Hormann
Subject: Re: Trouble with MechSim fields
Date: 20 Aug 2004 03:33:52
Message: <4125a960@news.povray.org>
ssssmemyself wrote:
> [...]
> #declare Fn_Vector = function(x,y,z) {
>   Vector_Function(
>     function{0}
>     function{
>       #if (y>RADIUS)
>         0
>       #else
>         #if (y<-RADIUS)
>           9.81*4/3
>         #else
>           9.81*pi*(((y-r)*r*r-1/3*pow(y-r,3))-(-r*r*r-1/3*pow(-r,3)))
>         #end
>       #end
>     }
>     function{0}
>   )
> }

You have some basic misunderstanding of how use of #if in functions work 
- you can not do render time conditionals this way - use select() for this.

-- 
Christoph Hormann
http://www.tu-bs.de/~y0013390/


Post a reply to this message

From: ssssmemyself
Subject: Re: Trouble with MechSim fields
Date: 20 Aug 2004 10:05:01
Message: <web.4126030898395bf215c1769c0@news.povray.org>
Christoph Hormann <chr### [at] gmxde> wrote:
> ssssmemyself wrote:
> > [...]
> > #declare Fn_Vector = function(x,y,z) {
> >   Vector_Function(
> >     function{0}
> >     function{
> >       #if (y>RADIUS)
> >         0
> >       #else
> >         #if (y<-RADIUS)
> >           9.81*4/3
> >         #else
> >           9.81*pi*(((y-r)*r*r-1/3*pow(y-r,3))-(-r*r*r-1/3*pow(-r,3)))
> >         #end
> >       #end
> >     }
> >     function{0}
> >   )
> > }
>
> You have some basic misunderstanding of how use of #if in functions work
> - you can not do render time conditionals this way - use select() for this.
>
> --
> Christoph Hormann
> http://www.tu-bs.de/~y0013390/

Whoops! I guess the #if command works more like C precompilers then. Makes
sense, seeing how it starts with a #.


Post a reply to this message

From: ssssmemyself
Subject: Re: Trouble with MechSim fields
Date: 20 Aug 2004 13:25:00
Message: <web.4126339698395bf215c1769c0@news.povray.org>
"ssssmemyself" <sss### [at] hotmailcom> wrote:
> Christoph Hormann <chr### [at] gmxde> wrote:
> >
> > You have some basic misunderstanding of how use of #if in functions work
> > - you can not do render time conditionals this way - use select() for this.
> >
> > --
> > Christoph Hormann
> > http://www.tu-bs.de/~y0013390/
>
> Whoops! I guess the #if command works more like C precompilers then. Makes
> sense, seeing how it starts with a #.

Well, I'm having more trouble with select() now. Here's the listing for
test.pov

#version unofficial megapov 1.0;
#include "mechsim.inc"
global_settings{
  mechsim{
    method 1
    field{
      Vector_Function(
        function{select(y,-100,100)}//should move top mass +x, bottom one -x
        function{0}
        function{0}
      )
    }
    #if(frame_number>1)
      step_count 500
      time_step (1/30)/500
      topology{
        load_file "test.dat"
        save_file "test.dat"
      }
    #else
      step_count 0
      topology{
        mass{<0,5,0>,<0,0,0>,.5 mass 1}
        mass{<0,-5,0>,<0,0,0>,.5 mass 1}
        save_file "test.dat"
      }
    #end
  }
}
#debug "==========n"
#debug vstr(3,mechsim:mass(0):position,", ",0,3)
#debug "n"
#debug vstr(3,mechsim:mass(1):position,", ",0,3)
#debug "n==========n"
camera{location<0,0,-20>look_at<0,0,0>}
light_source{<0,0,-20>color rgb 1}
object{MechSim_Show_All_Objects(-1, false, -1, "")}
sky_sphere{pigment{color rgb<0.4,0.4,0.4>}}

As you can see, the field has a select statement that applies a force of
-100 or 100 in the x direction, depending on the sign of y. To quote the
POV-Ray documentation on select(A, B, C[, D])

"if A < 0 it will return B, else C (A >= 0)."

So, one would assume that the mass at <0,5,0> would move to to the right
because of the field and the mass at <0,-5,0> would move left. According to
the #debug statements and the images produced, both of the masses move

what do I have a basic misunderstanding of this time?


Post a reply to this message

From: ssssmemyself
Subject: Re: Trouble with MechSim fields
Date: 23 Aug 2004 23:10:00
Message: <web.412ab07e98395bf215c1769c0@news.povray.org>
*bump*
So, what's up with select() within field{}s? Any ideas?


Post a reply to this message

From: ssssmemyself
Subject: Re: Trouble with MechSim fields
Date: 7 Sep 2004 22:05:00
Message: <web.413e68bf98395bf23c68e7320@news.povray.org>
"ssssmemyself" <sss### [at] hotmailcom> wrote:
> *bump*
> So, what's up with select() within field{}s? Any ideas?

Is anyone willing ot investigate this bug?


Post a reply to this message

From: ABX
Subject: Re: Trouble with MechSim fields
Date: 8 Sep 2004 11:44:49
Message: <jcbtj0l7qkl6iunn2fsf2r655ci8pkviik@4ax.com>
On Tue,  7 Sep 2004 22:04:47 EDT, "ssssmemyself" <sss### [at] hotmailcom>
wrote:
> "ssssmemyself" <sss### [at] hotmailcom> wrote:
> > *bump*
> > So, what's up with select() within field{}s? Any ideas?
> Is anyone willing ot investigate this bug?

I imagine "anyone" is not willing to be called "smartypants" which seemed to
be your answer to giving help. As far as I understand English it is not
courtesy in expressing.

ABX


Post a reply to this message

From: Stephen
Subject: Re: Trouble with MechSim fields
Date: 8 Sep 2004 12:35:01
Message: <web.413f343398395bf271087b900@news.povray.org>
ABX <abx### [at] abxartpl> wrote:
> On Tue,  7 Sep 2004 22:04:47 EDT, "ssssmemyself" <sss### [at] hotmailcom>
> wrote:
> > "ssssmemyself" <sss### [at] hotmailcom> wrote:
> > > *bump*
> > > So, what's up with select() within field{}s? Any ideas?
> > Is anyone willing ot investigate this bug?
>
> I imagine "anyone" is not willing to be called "smartypants" which seemed to
> be your answer to giving help. As far as I understand English it is not
> courtesy in expressing.
>
> ABX




does not mean that.
Keep up the good work.
 Stephen McAvoy


Post a reply to this message

From: ssssmemyself
Subject: Re: Trouble with MechSim fields
Date: 12 Sep 2004 13:05:01
Message: <web.4144818598395bf2d2736cb70@news.povray.org>
"Stephen" <mca### [at] hotmailcom> wrote:
> ABX <abx### [at] abxartpl> wrote:
> > On Tue,  7 Sep 2004 22:04:47 EDT, "ssssmemyself" <sss### [at] hotmailcom>
> > wrote:
> > > "ssssmemyself" <sss### [at] hotmailcom> wrote:
> > > > *bump*
> > > > So, what's up with select() within field{}s? Any ideas?
> > > Is anyone willing ot investigate this bug?
> >
> > I imagine "anyone" is not willing to be called "smartypants" which seemed to
> > be your answer to giving help. As far as I understand English it is not
> > courtesy in expressing.
> >
> > ABX
>



> does not mean that.
> Keep up the good work.
>  Stephen McAvoy

His remark that I had a "basic misunderstanding" seemed like another "RTFM,
n00b!"-like comment as seen in the Linux community far too often. But, in
all seriousness, is this a bug I'm observing?


Post a reply to this message

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