POV-Ray : Newsgroups : povray.newusers : How to: Sphere with 3D Electric Field Lines : Re: How to: Sphere with 3D Electric Field Lines Server Time
11 May 2024 05:01:10 EDT (-0400)
  Re: How to: Sphere with 3D Electric Field Lines  
From: Alain
Date: 1 Oct 2014 19:01:33
Message: <542c87cd$1@news.povray.org>

> William F Pokorny <ano### [at] anonymousorg> wrote:
>> On 09/27/2014 11:39 AM, Johann wrote:
>>>
>>> Thanks Bill for your proposal! Just a few minutes ago POV RAY started to render
>>> the image and it took about 14 minutes for 320x240 AA 0.3. I believe that what I
>>> am looking for is relative easy and not so complicated.
>>>
>> Johann & all,
>>
>> A memory came back to me a bit ago of work on some vector analysis
>> functions a decade or more back. Sure enough in Pov-Ray's math.inc there
>> is a collection of functions written by Christoph Hormann and Tor Olav
>> Kristensen. Also an example  povray file in
>>
>> scenes/incdemo/f_guncradient.pov.
>>
>> Stealing code almost directly from func_gradient.pov and using our
>> functions to control pigments instead of generate isosurfaces we can get
>> something which runs quite a lot faster.
>>
>> While likely not as artistic an output as I think you want, the result
>> at least touches on all the elements I believe you seek.
>>
>> I'll post an image generated by the code below to p.b.images shortly.
>>
>> Bill P.
>
> Thank you Bill  very much! This is really very close to what I am trying to
> achieve. May I ask something:
> If I modify only the following declare expression:
> #declare Fn00 = function (x,y,z,k,q) {
> (k*q)/(x*x+y*y+z*z+1e-7)
> }
> would be enough to see a different rendered image or it is required in more
> places? I am not speaking about rotation just different field distribution. Is
> it possible the field lines to look like arrows that will show the direction of
> the field? Besides that the equipotential lines are really beautiful!
>
> Great Job and thank you for once more!
>
> Johann
>
>

If you want to replace the lines representing the field orientation and 
strength with arrows, you need to change where they are placed:
union {
   #while (PosX < 1.0)
     #declare PosY=-0.5;
       #while (PosY < 0.5)
         #declare Pos=<PosX, PosY, 0>;
         #declare Vgrd=vGradient(Fn04normalized, Pos);
         #declare Vgrd=<Vgrd.x, Vgrd.y, 0>*0.1;
         #if (vlength(Vgrd)<0.300)
           cylinder {
             <PosX, PosY, 0>-Vgrd*0.105,
             <PosX, PosY, 0>+Vgrd*0.105,
             0.001
             texture {
               pigment { color srgb y*Gradient_Length(Fn04normalized, 
Pos)*0.25 }
             }
           }
         #end
         #declare PosY=PosY+Spacing;
       #end
     #declare PosX=PosX+Spacing;
   #end
}

To become something like this:

union {
   #while (PosX < 1.0)
     #declare PosY=-0.5;
       #while (PosY < 0.5)
         #declare Pos=<PosX, PosY, 0>;
         #declare Vgrd=vGradient(Fn04normalized, Pos);
         #declare Vgrd=<Vgrd.x, Vgrd.y, 0>*0.1;
         #if (vlength(Vgrd)<0.300)
     union{
           cylinder {
             <PosX, PosY, 0>-Vgrd*0.105,
             <PosX, PosY, 0>,
             0.001}
	cone{
	   <PosX, PosY, 0>,0.03,
	   <PosX, PosY, 0>+Vgrd*0.105, 0}
             texture {
               pigment { color srgb y*Gradient_Length(Fn04normalized, 
Pos)*0.25 }
             }
           }
	cone{<PosX, PosY, 0>,0.03, <PosX, PosY, 0>+Vgrd*0.105, 0}
         #end
         #declare PosY=PosY+Spacing;
       #end
     #declare PosX=PosX+Spacing;
   #end
}

Now, one half of each lines stay the same while the other half is 
replaced by a cone. They are placed in an union so that they can get the 
pigment in one statement.


Alain


Post a reply to this message

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