POV-Ray : Newsgroups : povray.newusers : How to: Sphere with 3D Electric Field Lines Server Time
13 May 2024 12:09:20 EDT (-0400)
  How to: Sphere with 3D Electric Field Lines (Message 21 to 26 of 26)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: William F Pokorny
Subject: Re: How to: Sphere with 3D Electric Field Lines
Date: 2 Oct 2014 22:49:52
Message: <542e0ed0$1@news.povray.org>
On 09/28/2014 04:11 PM, Johann wrote:
>
> 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!
>
Johann,
Changing the base equation would certainly change results, but the code 
was set up to implement changes on each placed sphere. Though true that, 
due my hacking, the previous code did need to be changed throughout to 
stay lined up with by sphere changes. Suppose I was aiming to offer an 
example more than a complete solution.

Below is an updated version of the code through the contours part, 
modified so the charged sphere specifications are centralized - so it is 
easier to play with values and placements. I've added a couple of 
additional spheres to make the resultant image more interesting.

There are a thousand ways to further change & improve things, but I am 
going to leave the rest as an exercise for any users of the code.

Have fun.
Bill P.

//----------------------- V3 ------------------------
#version 3.7;
global_settings {
     assumed_gamma 1
     ambient_light srgb <1,1,1>
}
#declare White = srgbft <1,1,1,0,0>;
background {
     color White
}
#declare Camera00 = camera {
     orthographic
     location <0,0,-10>
     sky <0,1,0>
     right x*(image_width/image_height)
     look_at <0,0,0>
}
#declare Light00 = light_source {
     <50,150,-250>, White
}
#declare Grey05 = srgbft <0.05,0.05,0.05,0,0>;
#declare CylinderX = cylinder {
     <-1,0,0>, <1,0,0>, 0.005
     pigment { color Grey05 }
     no_shadow
}
#declare Grey95 = srgbft <0.95,0.95,0.95,0,0>;
#declare CylinderY = cylinder {
     <0,-1,0>, <0,1,0>, 0.005
     pigment { color Grey95 }
     no_shadow
}
#declare Grey50 = srgbft <0.5,0.5,0.5,0,0>;
#declare CylinderZ = cylinder {
     <0,0,-1>, <0,0,1>, 0.005
     pigment { color Grey50 }
     no_shadow
}
#declare Sphere00 = sphere { <0,0,0>, 1 }
#declare K = 1.0;
#declare Min_e = -1.0;
#declare Max_e = 1.0;
#declare Range_e = Max_e-Min_e;
#declare MidAdj_e = Range_e/2;
#declare MaxPlotRange = 10.0;
#include "functions.inc"
#declare Fn00 = function (x,y,z,k,q) {
     (k*q)/(x*x+y*y+z*z+1e-7)
}
#declare Fn01 = function (x,y,z,vx,vy,vz,k,q,mag) {
 
Fn00((x/mag/abs(q))-(vx/mag/abs(q)),(y/mag/abs(q))-(vy/mag/abs(q)),(z/mag/abs(q))-(vz/mag/abs(q)),k,q)
}
#declare Radius02 = 1.0;
#declare Position02 = <2.5,0,0,0.0>;
#declare Fn02 = function (x,y,z) {
     #local vx=Position02.x; #local vy=Position02.y; #local 
vz=Position02.z; Fn01(x,y,z,vx,vy,vz,K,-1.0,Radius02)
}
#declare Radius03 = 1.0;
#declare Position03 = <-2.5,0,0,0.0>;
#declare Fn03 = function (x,y,z) {
     #local vx=Position03.x; #local vy=Position03.y; #local 
vz=Position03.z; Fn01(x,y,z,vx,vy,vz,K,1.0,Radius03)
}
#declare Radius04 = 0.5;
#declare Position04 = <0.0,2.0,0.0>;
#declare Fn04 = function (x,y,z) {
     #local vx=Position04.x; #local vy=Position04.y; #local 
vz=Position04.z; Fn01(x,y,z,vx,vy,vz,K,1.0,Radius04)
}
#declare Radius05 = 0.2;
#declare Position05 = <-0.4,-2.2,0.0>;
#declare Fn05 = function (x,y,z) {
     #local vx=Position05.x; #local vy=Position05.y; #local 
vz=Position05.z; Fn01(x,y,z,vx,vy,vz,K,-1.0,Radius05)
}
#declare FnAllCharges = function (x,y,z) {
     Fn02(x,y,z)+Fn03(x,y,z)+Fn04(x,y,z)+Fn05(x,y,z)
}
#declare FnAllChargesNormalized = function (x,y,z) {
 
(FnAllCharges(x*MaxPlotRange,y*MaxPlotRange,z*MaxPlotRange)+MidAdj_e)/Range_e
}
#declare FnPigmentAllCharges = function (x,y,z) {
     min(1,max(0,FnAllChargesNormalized(x,y,z)))
}
#declare Blue = srgbft <0,0,1,0,0>;
#declare Clear100 = srgbft <1,1,1,1,0>;
#declare Red = srgbft <1,0,0,0,0>;
#declare ColorMapField = color_map {
     [ 0 Blue ]
     [ 0.5 Clear100 ]
     [ 1 Red ]
}
#declare PigmentField = pigment {
     function { FnPigmentAllCharges(x,y,z) }
     color_map { ColorMapField }
}
#declare TextureField = texture {
     pigment { PigmentField }
}
#declare Grey80 = srgbft <0.8,0.8,0.8,0,0>;
#declare ColorMapSphere = color_map {
     [ 0 Blue ]
     [ 0.5 Grey80 ]
     [ 1 Red ]
}
#declare PigmentSphere = pigment {
     function { FnPigmentAllCharges(x,y,z) }
     color_map { ColorMapSphere }
}
#declare TextureSphere = texture {
     pigment { PigmentSphere }
}
#declare ObjSphere02 = object {
     object { Sphere00 }
     scale Radius02
     translate <Position02.x,Position02.y,Position02.z>
}
#declare ObjSphere03 = object {
     object { Sphere00 }
     scale Radius03
     translate <Position03.x,Position03.y,Position03.z>
}
#declare ObjSphere04 = object {
     object { Sphere00 }
     scale Radius04
     translate <Position04.x,Position04.y,Position04.z>
}
#declare ObjSphere05 = object {
     object { Sphere00 }
     scale Radius05
     translate <Position05.x,Position05.y,Position05.z>
}
#declare UnionAllSpheres = union {
     object { ObjSphere02 }
     object { ObjSphere03 }
     object { ObjSphere04 }
     object { ObjSphere05 }
     scale 1/MaxPlotRange
}
#declare ObjAllSpheres = object {
     object { UnionAllSpheres }
     texture { TextureSphere }
     no_shadow
}
#declare Magenta = srgbft <1,0,1,0,0>;
#declare ColorMapContour = color_map {
     [ 0 Clear100 ]
     [ 0.5-(0.5/pow(2,1))-0.005 Clear100 ]
     [ 0.5-(0.5/pow(2,1))+0.000 Magenta ]
     [ 0.5-(0.5/pow(2,1))+0.005 Clear100 ]
     [ 0.5-(0.5/pow(2,2))-0.005 Clear100 ]
     [ 0.5-(0.5/pow(2,2))+0.000 Magenta ]
     [ 0.5-(0.5/pow(2,2))+0.005 Clear100 ]
     [ 0.5-(0.5/pow(2,3))-0.005 Clear100 ]
     [ 0.5-(0.5/pow(2,3))+0.000 Magenta ]
     [ 0.5-(0.5/pow(2,3))+0.005 Clear100 ]
     [ 0.5-(0.5/pow(2,4))-0.005 Clear100 ]
     [ 0.5-(0.5/pow(2,4))+0.000 Magenta ]
     [ 0.5-(0.5/pow(2,4))+0.005 Clear100 ]
     [ 0.5-0.005 Clear100 ]
     [ 0.5+0.000 Magenta ]
     [ 0.5+0.005 Clear100 ]
     [ 0.5+(0.5/pow(2,4))-0.005 Clear100 ]
     [ 0.5+(0.5/pow(2,4))+0.000 Magenta ]
     [ 0.5+(0.5/pow(2,4))+0.005 Clear100 ]
     [ 0.5+(0.5/pow(2,3))-0.005 Clear100 ]
     [ 0.5+(0.5/pow(2,3))+0.000 Magenta ]
     [ 0.5+(0.5/pow(2,3))+0.005 Clear100 ]
     [ 0.5+(0.5/pow(2,2))-0.005 Clear100 ]
     [ 0.5+(0.5/pow(2,2))+0.000 Magenta ]
     [ 0.5+(0.5/pow(2,2))+0.005 Clear100 ]
     [ 0.5+(0.5/pow(2,1))-0.005 Clear100 ]
     [ 0.5+(0.5/pow(2,1))+0.000 Magenta ]
     [ 0.5+(0.5/pow(2,1))+0.005 Clear100 ]
     [ 1 Clear100 ]
}
#declare PigmentContour = pigment {
     function { FnAllChargesNormalized(x,y,z) }
     color_map { ColorMapContour }
}
#declare TextureContour = texture {
     pigment { PigmentContour }
}
#macro Texture2Dslice_ListOf_0 ()
     texture { TextureContour }
     texture { TextureField }
#end
#declare Box00 = box {
     <-9.5,-9.5,-0.001>,<9.5,9.5,0.001>
}
#declare Obj2DSlice = object {
     object { Box00 }
     Texture2Dslice_ListOf_0()
}

//---
camera { Camera00 }
light_source { Light00 }
object { CylinderX }
object { CylinderY }
object { CylinderZ }
object { ObjAllSpheres }
object { Obj2DSlice }


Post a reply to this message

From: Norbert Kern
Subject: Re: How to: Sphere with 3D Electric Field Lines
Date: 3 Oct 2014 02:55:00
Message: <web.542e47c6266802cb5f44f3a00@news.povray.org>
William F Pokorny <ano### [at] anonymousorg> wrote:

> There are a thousand ways to further change & improve things, but I am
> going to leave the rest as an exercise for any users of the code.
>
> Have fun.
> Bill P.


Very nice,
reminds me somewhat on Tek's wips on magnetism (he provided even code) ...

http://evilsuperbrain.com/gallery/wip/index.php?image=magnetism3
http://news.povray.org/povray.binaries.images/thread/%3C432a6c1c@news.povray.org%3E/?ttop=247446&toff=1400

Norbert


Post a reply to this message

From: William F Pokorny
Subject: Re: How to: Sphere with 3D Electric Field Lines
Date: 3 Oct 2014 14:23:06
Message: <542ee98a$1@news.povray.org>
On 10/03/2014 02:53 AM, Norbert Kern wrote:
>
> Very nice,
> reminds me somewhat on Tek's wips on magnetism (he provided even code) ...
>
> http://evilsuperbrain.com/gallery/wip/index.php?image=magnetism3
>
http://news.povray.org/povray.binaries.images/thread/%3C432a6c1c@news.povray.org%3E/?ttop=247446&toff=1400
>
> Norbert
>

Thanks Norbert & thank you for the pointer to Tek's previous work. Not 
work I recall. Perhaps never saw it, but at my age also possible the 
neurons maintaining the memory have quit.

Aside: I read in one of your recent newsgroup postings your collection 
of materials is now at 600 or so. Looking forward to an update - though 
I have to admit I've got the 5 or 6 slowest of your first 330 still to 
render.  Not being very experienced with materials, I've been amazed at 
just how slow some of them can be!

Bill P.


Post a reply to this message

From: Norbert Kern
Subject: Re: How to: Sphere with 3D Electric Field Lines
Date: 3 Oct 2014 15:55:01
Message: <web.542efec7266802cb81584bbb0@news.povray.org>
William F Pokorny <ano### [at] anonymousorg> wrote:

> Aside: I read in one of your recent newsgroup postings your collection
> of materials is now at 600 or so. Looking forward to an update - though
> I have to admit I've got the 5 or 6 slowest of your first 330 still to
> render.  Not being very experienced with materials, I've been amazed at
> just how slow some of them can be!
>
> Bill P.


Purely my fault,

using a new demo scene, there is no such problem anymore.
At 400:225 all scenes of the old "300" material setup needed a bit more than a
day - the new setup allows to render the materials with 1280:720 within the same
time...

And as you can see, it isn't only a sphere on a plane... (
http://news.povray.org/povray.binaries.images/attachment/%3Cweb.54295d1d46a0060a84d386ea0%40news.povray.org%3E/material
s%20update%20examples.jpg
).

And - trust me - the deeper you look in the newsgroups intestines, the more you
will discover. Of course the same is true for private websites, IRTC etc.

By example, Samuel Benge discovered a way to use 65536 samples with nested
average patterns instead of the usual 256 and I don't understand how he did it.

Or let's take Rune's good old grass demos. He managed to construct a pigment
showing to the camera and simulating a 3D grass population.
I'm sure this trick is worth for many new materials alone - at least, if I can
delve deeper into the code...

etc. etc...


Norbert


Post a reply to this message

From: Johann
Subject: Re: How to: Sphere with 3D Electric Field Lines
Date: 5 Oct 2014 06:30:01
Message: <web.54311ce9266802cb16298ca60@news.povray.org>
> Johann,
> Changing the base equation would certainly change results, but the code
> was set up to implement changes on each placed sphere. Though true that,
> due my hacking, the previous code did need to be changed throughout to
> stay lined up with by sphere changes. Suppose I was aiming to offer an
> example more than a complete solution.
>
> Below is an updated version of the code through the contours part,
> modified so the charged sphere specifications are centralized - so it is
> easier to play with values and placements. I've added a couple of
> additional spheres to make the resultant image more interesting.
>
> There are a thousand ways to further change & improve things, but I am
> going to leave the rest as an exercise for any users of the code.
>
> Have fun.
> Bill P.
>

Thank you very much Bill. Now it really gets interesting!

Wish you all the best!

Johann


Post a reply to this message

From: Johann
Subject: Re: How to: Sphere with 3D Electric Field Lines
Date: 5 Oct 2014 06:35:00
Message: <web.54311e84266802cb16298ca60@news.povray.org>
>
> 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

Although it looks a little bit strange the result ( a mix of polygons and
arrows), I really thank you for your help!

Johann


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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