 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Clipka gave me these formulas to generate a cylindrical isosurface.
#declare fL = function(x,y,z) {y*100}
#declare fC = function(x,y,z) {sqrt(x*x+z*z)*128}
#declare fH = function(x,y,z) {atan2d(x,z)}
What would be a formula for a sphere? L should be latitude, H longitude,
and C radius.
Thanks.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 11/28/2016 6:42 PM, Mike Horvath wrote:
> Clipka gave me these formulas to generate a cylindrical isosurface.
>
> #declare fL = function(x,y,z) {y*100}
> #declare fC = function(x,y,z) {sqrt(x*x+z*z)*128}
> #declare fH = function(x,y,z) {atan2d(x,z)}
>
> What would be a formula for a sphere? L should be latitude, H longitude,
> and C radius.
>
> Thanks.
Would I use atan(x,y) for L? This produces values between -90..90
degrees, correct? Or should it be atan(z,y)?
Thanks.
Mike
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Mike Horvath <mik### [at] gmail com> wrote:
> On 11/28/2016 6:42 PM, Mike Horvath wrote:
> > Clipka gave me these formulas to generate a cylindrical isosurface.
> >
> > #declare fL = function(x,y,z) {y*100}
> > #declare fC = function(x,y,z) {sqrt(x*x+z*z)*128}
> > #declare fH = function(x,y,z) {atan2d(x,z)}
> >
> > What would be a formula for a sphere? L should be latitude, H longitude,
> > and C radius.
> >
> > Thanks.
>
> Would I use atan(x,y) for L? This produces values between -90..90
> degrees, correct? Or should it be atan(z,y)?
I sure don't know enough to tell you much of anything, the sphere equation is
something like:
function(x,y,z,r) {(pow(x,2)+pow(y,2)+pow(z,2))-pow(r,2)}
There's also the inbuilt function called internal (61) used by functions.inc for
its f_sphere(x,y,z,r) where r is radius. Hopefully I got this right, please
don't count on it!
Bob
P.S. I was trying, rather clumsily, to get the idea of what you might have been
trying to make and only succeeded in creating strange isosurface shapes. Some
were a partial sphere with both a vertical and horizontal cut across it,
thinking I changed to atan(y) and atan2(x,z) but I got lost in the fascination
of new shapes.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Mike Horvath <mik### [at] gmail com> wrote:
> What would be a formula for a sphere?
I always start here:
http://www.econym.demon.co.uk/isotut/
whenever I have any questions about isosurfaces.
Like Christoph said, it takes a certain "way" of thinking to successfully play
with isosurfaces.
I'd also be aware that you may use code and equations that successfully yield a
visible isosurface in a render. That surface may or may not be correct - so I'd
also be thinking about placing visible markers, sending numeric results to the
debug stream, overlaying the isosurface onto your stacked-block model, or some
other way of performing sanity and accuracy checks.
Aside from that, as Christoph said, "don't listen to that man"
I use this
https://www.maxiaids.com/Media/Thumbs/0008/0008988-big-keys-lx-color-abc-300.jpg
to write my SDL code, and when I'm down in the basement POVving, my mom makes me
wear a special helmet so I don't injure myself when trying to visualize 3D
vectors or do Big Boy math. ;)
:D
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 11/29/2016 6:07 AM, omniverse wrote:
> Mike Horvath <mik### [at] gmail com> wrote:
>> On 11/28/2016 6:42 PM, Mike Horvath wrote:
>>> Clipka gave me these formulas to generate a cylindrical isosurface.
>>>
>>> #declare fL = function(x,y,z) {y*100}
>>> #declare fC = function(x,y,z) {sqrt(x*x+z*z)*128}
>>> #declare fH = function(x,y,z) {atan2d(x,z)}
>>>
>>> What would be a formula for a sphere? L should be latitude, H longitude,
>>> and C radius.
>>>
>>> Thanks.
>>
>> Would I use atan(x,y) for L? This produces values between -90..90
>> degrees, correct? Or should it be atan(z,y)?
>
> I sure don't know enough to tell you much of anything, the sphere equation is
> something like:
>
> function(x,y,z,r) {(pow(x,2)+pow(y,2)+pow(z,2))-pow(r,2)}
>
> There's also the inbuilt function called internal (61) used by functions.inc for
> its f_sphere(x,y,z,r) where r is radius. Hopefully I got this right, please
> don't count on it!
>
> Bob
>
> P.S. I was trying, rather clumsily, to get the idea of what you might have been
> trying to make and only succeeded in creating strange isosurface shapes. Some
> were a partial sphere with both a vertical and horizontal cut across it,
> thinking I changed to atan(y) and atan2(x,z) but I got lost in the fascination
> of new shapes.
>
>
Thanks for trying, at least.
:)
Mike
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 11/29/2016 7:54 AM, Bald Eagle wrote:
> Mike Horvath <mik### [at] gmail com> wrote:
>
>> What would be a formula for a sphere?
>
> I always start here:
>
> http://www.econym.demon.co.uk/isotut/
>
> whenever I have any questions about isosurfaces.
That tutorial only gives a single function for a sphere. I need separate
functions for latitude, longitude and radius, that get combined later
using an additional function.
Like this:
#declare fD = function(C) {abs(C-0.5)-0.5}
#declare fDist = function(Dr,Dg,Db) {max(Dr,Dg,Db)}
#declare fR = function(L,C,H) {convertLCH2RGBa1(L,C,H)}
#declare fG = function(L,C,H) {convertLCH2RGBa2(L,C,H)}
#declare fB = function(L,C,H) {convertLCH2RGBa3(L,C,H)}
#declare fL = function(x,y,z) {90+atand(x/y)} // wrong!
#declare fC = function(x,y,z) {sqrt(x*x+z*z)*128}
#declare fH = function(x,y,z) {atan2d(x,z)}
#declare fFinal = function(L,C,H)
{
fDist
(
fD(fR(L,C,H)),
fD(fG(L,C,H)),
fD(fB(L,C,H))
)
}
Mike
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 11/28/2016 6:42 PM, Mike Horvath wrote:
> Clipka gave me these formulas to generate a cylindrical isosurface.
>
> #declare fL = function(x,y,z) {y*100}
> #declare fC = function(x,y,z) {sqrt(x*x+z*z)*128}
> #declare fH = function(x,y,z) {atan2d(x,z)}
>
> What would be a formula for a sphere? L should be latitude, H longitude,
> and C radius.
>
> Thanks.
Maybe this?
#declare fL = function(x,y,z) {90+atand(sqrt(x*x+z*z)*128/y*100)}
Problem: L ranges from 0..100, and C ranges from 0..128, and I want to
avoid generating a flattened ellipsoid.
Mike
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Mike Horvath <mik### [at] gmail com> wrote:
> > What would be a formula for a sphere? L should be latitude, H longitude,
> > and C radius.
https://en.wikipedia.org/wiki/Spherical_coordinate_system
Conversely, the Cartesian coordinates may be retrieved from the spherical
coordinates
https://wikimedia.org/api/rest_v1/media/math/render/svg/d7bcd516d317c31ac48ed36e2ead9537a5f16e2e
> Problem: L ranges from 0..100, and C ranges from 0..128, and I want to
> avoid generating a flattened ellipsoid.
>
> Mike
#declare C = C*(100/128);
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 29.11.2016 um 00:42 schrieb Mike Horvath:
> Clipka gave me these formulas to generate a cylindrical isosurface.
>
> #declare fL = function(x,y,z) {y*100}
> #declare fC = function(x,y,z) {sqrt(x*x+z*z)*128}
> #declare fH = function(x,y,z) {atan2d(x,z)}
>
> What would be a formula for a sphere? L should be latitude, H longitude,
> and C radius.
What you need is _not_ "formulas to generate a [spherical] isosurface".
What you need is formulas to convert from a point in cartesian space to
a colour in the spherical (as oppsed to cylindrical) LCh model.
This is just a small building block in your isosurface function, and in
and of itself has no special relation to isosurfaces whatsoever. (You'll
need to use the same formula to eventually compute an RGB colour pigment.)
If Chroma (C) is to be (spherical) radius, that part is easy:
#declare fC = function(x,y,z) { sqrt(x*x+y*y+z*z)*CONST }
Hue (H) should be unchanged:
#declare fH = function(x,y,z) { atan2(x,z)*CONST }
Luminance gets a bit more complicated: You have to use an atan-based
formula to get an angle, but you must plug in the y coordinate and the
distance between the y axis; the latter is equal to sqrt(x*x+z*z), so
this gives you:
#declare fL = function(x,y,z) { atan2(sqrt(x*x+z*z),y)*CONST }
Choose CONST values as needed; atan2()*CONST may happen to be replacable
by atan2d() again.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 11/29/2016 3:04 PM, Bald Eagle wrote:
> Mike Horvath <mik### [at] gmail com> wrote:
>
>>> What would be a formula for a sphere? L should be latitude, H longitude,
>>> and C radius.
>
> https://en.wikipedia.org/wiki/Spherical_coordinate_system
> Conversely, the Cartesian coordinates may be retrieved from the spherical
> coordinates
>
https://wikimedia.org/api/rest_v1/media/math/render/svg/d7bcd516d317c31ac48ed36e2ead9537a5f16e2e
>
>> Problem: L ranges from 0..100, and C ranges from 0..128, and I want to
>> avoid generating a flattened ellipsoid.
>>
>> Mike
>
> #declare C = C*(100/128);
>
>
THANK YOU!!
This had what I needed:
https://en.wikipedia.org/wiki/Spherical_coordinate_system#Cartesian_coordinates
I'm not sure I'm 100% correct, but here are my calculations:
#declare fD = function(C) {abs(C-0.5)-0.5}
#declare fDist = function(Dr,Dg,Db) {max(Dr,Dg,Db)}
#declare fR = function(L,C,H) {convertLCH2RGBa1(L,C,H)}
#declare fG = function(L,C,H) {convertLCH2RGBa2(L,C,H)}
#declare fB = function(L,C,H) {convertLCH2RGBa3(L,C,H)}
#declare fL = function(x,y,z) {acosd(y/sqrt(x*x+y*y+z*z))/180*100}
#declare fC = function(x,y,z) {sqrt(x*x+y*y+z*z)*128}
#declare fH = function(x,y,z) {atan2d(z,x)}
#declare fFinal = function(L,C,H)
{
fDist
(
fD(fR(L,C,H)),
fD(fG(L,C,H)),
fD(fB(L,C,H))
)
}
I just wish the results were more interesting.
Mike
Post a reply to this message
Attachments:
Download 'cielch_color_solid_sphere_isosurface_light.png' (61 KB)
Preview of image 'cielch_color_solid_sphere_isosurface_light.png'

|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 11/29/2016 3:26 PM, clipka wrote:
> Luminance gets a bit more complicated: You have to use an atan-based
> formula to get an angle, but you must plug in the y coordinate and the
> distance between the y axis; the latter is equal to sqrt(x*x+z*z), so
> this gives you:
>
> #declare fL = function(x,y,z) { atan2(sqrt(x*x+z*z),y)*CONST }
>
> Choose CONST values as needed; atan2()*CONST may happen to be replacable
> by atan2d() again.
>
Wikipedia says it should be more like
#declare fL = function(x,y,z) { atan2(sqrt(x*x+y*y+z*z),y)*CONST }
Do you agree?
Mike
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 11/29/2016 5:04 PM, Mike Horvath wrote:
> On 11/29/2016 3:26 PM, clipka wrote:
>> Luminance gets a bit more complicated: You have to use an atan-based
>> formula to get an angle, but you must plug in the y coordinate and the
>> distance between the y axis; the latter is equal to sqrt(x*x+z*z), so
>> this gives you:
>>
>> #declare fL = function(x,y,z) { atan2(sqrt(x*x+z*z),y)*CONST }
>>
>> Choose CONST values as needed; atan2()*CONST may happen to be replacable
>> by atan2d() again.
>>
>
> Wikipedia says it should be more like
>
> #declare fL = function(x,y,z) { atan2(sqrt(x*x+y*y+z*z),y)*CONST }
>
> Do you agree?
>
> Mike
Wait! I scanned your response too quickly. Wikipedia gives this:
acos(y/r)
which is totally different from what you suggest. Are they equivalent?
Mike
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 11/29/2016 3:26 PM, clipka wrote:
> Luminance gets a bit more complicated: You have to use an atan-based
> formula to get an angle, but you must plug in the y coordinate and the
> distance between the y axis; the latter is equal to sqrt(x*x+z*z), so
> this gives you:
>
> #declare fL = function(x,y,z) { atan2(sqrt(x*x+z*z),y)*CONST }
>
> Choose CONST values as needed; atan2()*CONST may happen to be replacable
> by atan2d() again.
>
Also, don't I need to divide by 180 first before multiplying by the
constant?
atan2d(sqrt(x*x+z*z),y)/180*100
Mike
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 29.11.2016 um 23:07 schrieb Mike Horvath:
> On 11/29/2016 5:04 PM, Mike Horvath wrote:
>> On 11/29/2016 3:26 PM, clipka wrote:
>>> Luminance gets a bit more complicated: You have to use an atan-based
>>> formula to get an angle, but you must plug in the y coordinate and the
>>> distance between the y axis; the latter is equal to sqrt(x*x+z*z), so
>>> this gives you:
>>>
>>> #declare fL = function(x,y,z) { atan2(sqrt(x*x+z*z),y)*CONST }
>>>
>>> Choose CONST values as needed; atan2()*CONST may happen to be replacable
>>> by atan2d() again.
>>>
>>
>> Wikipedia says it should be more like
>>
>> #declare fL = function(x,y,z) { atan2(sqrt(x*x+y*y+z*z),y)*CONST }
>>
>> Do you agree?
>>
>> Mike
>
> Wait! I scanned your response too quickly. Wikipedia gives this:
>
> acos(y/r)
>
> which is totally different from what you suggest. Are they equivalent?
I think so. Wikipedia is right, and I'm confident my formula is also
correct. I haven't verified the equivalence algebraically though.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 29.11.2016 um 23:12 schrieb Mike Horvath:
> On 11/29/2016 3:26 PM, clipka wrote:
>> Luminance gets a bit more complicated: You have to use an atan-based
>> formula to get an angle, but you must plug in the y coordinate and the
>> distance between the y axis; the latter is equal to sqrt(x*x+z*z), so
>> this gives you:
>>
>> #declare fL = function(x,y,z) { atan2(sqrt(x*x+z*z),y)*CONST }
>>
>> Choose CONST values as needed; atan2()*CONST may happen to be replacable
>> by atan2d() again.
>>
>
> Also, don't I need to divide by 180 first before multiplying by the
> constant?
>
> atan2d(sqrt(x*x+z*z),y)/180*100
Well, that's equivalent to
atan2(...)/pi*100
so it's just a matter of choosing a fitting CONST for your purposes ;)
But yes, the way you're doing it is probably right for your application.
I later noticed that you may need to add another constant though,
depending on the nominal value range.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Le 16-11-28 à 18:42, Mike Horvath a écrit :
> Clipka gave me these formulas to generate a cylindrical isosurface.
>
> #declare fL = function(x,y,z) {y*100}
> #declare fC = function(x,y,z) {sqrt(x*x+z*z)*128}
> #declare fH = function(x,y,z) {atan2d(x,z)}
>
> What would be a formula for a sphere? L should be latitude, H longitude,
> and C radius.
>
> Thanks.
When I want a isosurface sphere, I use the following:
#include "functions.inc"
Then, I use the f_sphere(x,y,z,radius) function that use an internal
function. Faster and simple.
If you want the function to use in an isosurface, it's
sqrt(pow(x,2)+pow(y,2)+pow(z,2))-Radius to be used with a threshold of zero.
Also, you can use sqrt(pow(x,2)+pow(y,2)+pow(z,2)) and use the threshold
to controll the radius.
Using 3 functions is if you want to make a parametric sphere. It's not
the same thing.
Alain
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 12/1/2016 6:41 PM, Alain wrote:
> Le 16-11-28 à 18:42, Mike Horvath a écrit :
>> Clipka gave me these formulas to generate a cylindrical isosurface.
>>
>> #declare fL = function(x,y,z) {y*100}
>> #declare fC = function(x,y,z) {sqrt(x*x+z*z)*128}
>> #declare fH = function(x,y,z) {atan2d(x,z)}
>>
>> What would be a formula for a sphere? L should be latitude, H longitude,
>> and C radius.
>>
>> Thanks.
>
> When I want a isosurface sphere, I use the following:
>
> #include "functions.inc"
>
> Then, I use the f_sphere(x,y,z,radius) function that use an internal
> function. Faster and simple.
>
> If you want the function to use in an isosurface, it's
> sqrt(pow(x,2)+pow(y,2)+pow(z,2))-Radius to be used with a threshold of
> zero.
> Also, you can use sqrt(pow(x,2)+pow(y,2)+pow(z,2)) and use the threshold
> to controll the radius.
>
> Using 3 functions is if you want to make a parametric sphere. It's not
> the same thing.
>
>
> Alain
I don't want a sphere. I want an irregular shape in a spherical
coordinate system.
Mike
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |