POV-Ray : Newsgroups : povray.binaries.images : Spherical Harmonics Server Time
7 Nov 2024 09:25:40 EST (-0500)
  Spherical Harmonics (Message 1 to 5 of 5)  
From: Bald Eagle
Subject: Spherical Harmonics
Date: 6 Aug 2016 18:40:01
Message: <web.57a6669c174a9a7c5e7df57c0@news.povray.org>
related to
http://news.povray.org/povray.advanced-users/thread/%3Cweb.57a650c25c93b6e65e7df57c0%40news.povray.org%3E/

I copied the CHSV2RGB macro and stored the r, g, and b values in separate
variables to get rid of the parser warning about a suspicious expression.  How
do I suppress that?
And why do warnings and debug comments to the stream slow down POV-Ray SO much?

I managed to eke out a render, even though there are several things going on
that I don't understand.

For one, the whole logic of generating an array with both P2 and P6 Legendre
polynomials and taking the max of several operations.

I'm sure I must be missing something in generating my array, since I'm not
totally clear on what's taking place in some of the MatLab operations.

I'm not sure why my spline returns a 2-component result.

AND I'm perplexed about the u and v in POV-Ray's parametric.


But I made a pretty picture.   :D

I made the cross-section by making another pseudo-parametric with spheres and
filtering out any y values less than 0 (it's rotated around x), but I'm sure
there must be an intersection / difference / clipped_by method that's more
efficient.


Finite Objects:      3891615
  Parse Time:       0 hours  2 minutes  4 seconds (124.487 seconds)
Peak memory used:        6531100672 bytes
  Trace Time:       0 hours  3 minutes  1 seconds (181.927 seconds)


Post a reply to this message


Attachments:
Download 'sphericalharmonics.png' (188 KB)

Preview of image 'sphericalharmonics.png'
sphericalharmonics.png


 

From: clipka
Subject: Re: Spherical Harmonics
Date: 6 Aug 2016 20:00:03
Message: <57a67a03$1@news.povray.org>
Am 07.08.2016 um 00:37 schrieb Bald Eagle:

> I'm not sure why my spline returns a 2-component result.

I guess it's because splines always return vectors, and the "smallest"
vectors POV-Ray supports are 2D vectors.


Post a reply to this message

From: Cousin Ricky
Subject: Re: Spherical Harmonics
Date: 7 Aug 2016 00:40:01
Message: <web.57a6bb7b58721232b484452a0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> I copied the CHSV2RGB macro and stored the r, g, and b values in separate
> variables to get rid of the parser warning about a suspicious expression.  How
> do I suppress that?

I get that message when I use the rgb keyword with a value that is already a 5
component color.  And it so happens that CHSV2RGB returns a 5 component color.

Depending on the situation, I get rid of the message by using color or rgbft
instead of rgb, or by omitting the keyword altogether.


Post a reply to this message

From: Bald Eagle
Subject: Re: Spherical Harmonics
Date: 7 Aug 2016 02:20:01
Message: <web.57a6d281587212325e7df57c0@news.povray.org>
"Cousin Ricky" <rickysttATyahooDOTcom> wrote:

> I get that message when I use the rgb keyword with a value that is already a 5
> component color.  And it so happens that CHSV2RGB returns a 5 component color.
>
> Depending on the situation, I get rid of the message by using color or rgbft
> instead of rgb, or by omitting the keyword altogether.

Aha.   Good to know.

Spent the last I dunno know how long chasing my tail trying to define an HSV
gradient as a function.  I made a function pigment, and gave that an HSV
color_map - seems to work.  Gonna try to alter the pigment function to something
more complex and see what that yields.

Color maps I guess are restricted to 256 entries, so doing the full 360 degrees
of HSV makes POV choke.  So 0 to 360 step 2 it is.



Now what REALLY perplexes me is WHERE is my 4th harmonic?
I evaluated all of the equations in Excel just to see the values, and it
_should_ be there.   But it's like the whole thing evaluates to zero.
1-Equation[3] gives me a sphere.  1000*Equation[3] gives nada.

//######################################################################

#version 3.7;
global_settings {assumed_gamma 1.0}
#include "colors.inc"
#include "textures.inc"
#include "shapes3.inc"

camera {  location <7, 0, -15>
  look_at  <7, 0, 0>}

light_source {<40, 30, -20> White shadowless}
//light_source {<5.25, 5.25, 5.25> White shadowless}

background {Black}

#macro C_HSV2RGB(Color)
   #local HSVFT = color Color;
   #local H = (HSVFT.red);
   #local S = (HSVFT.green);
   #local V = (HSVFT.blue);
   #local SatRGB = CH2RGB(H);
   #local RGB = ( ((1-S)*<1,1,1> + S*SatRGB) * V );
   <RGB.red,RGB.green,RGB.blue,(HSVFT.filter),(HSVFT.transmit)>
#end
#declare W = 3;

#for (N, 0, 5)
 parametric {
  #debug concat (str(N, 3, 2), "\n\n")
  #ifndef (HH2) #local HH2 = function (S) {mod(sin(S/2)*360, 360)} #end
  #ifndef (H2) #local H2 =  function (S) {select (HH2(S), HH2(S)+360, HH2(S))}
#end          // 0-120       120-240  240-360
  #ifndef (R2) #local R2 = function (S) {select (mod(H2(S),240)-0.5,
(120-H2(S))/60, select (mod(H2(S),240)-1, (240-H2(S))/60, (H2(S)-240)/60 ) ) }
#end
  #ifndef (G2) #local G2 = function (S) {select (mod(H2(S),240)-0.5, H2(S)/60,
    select (mod(H2(S),240)-1, (240-H2(S))/60, 0 ) ) } #end
  #ifndef (B2) #local B2 = function (S) {select (mod(H2(S),240)-0.5, 0,
    select (mod(H2(S),240)-1, (H2(S)-120)/60, (360-H2(S))/60 ) ) } #end

  #ifndef (Color)
   #local Color = function {
    spline {linear_spline
    #for (CM, 0, 360)
     CM/360, R2(CM), G2(CM), B2(CM)
    #end // end for S
    } // end spline
   } // end function
  #end

  #ifndef (Q) #declare Q = function {(x*0)+1-y+(z*0)} #end

  #declare Tex1 =
   texture {
    pigment {function {Q(x, y, z)}
     color_map {
      #for (CM, 0, 360, 2)
      //[S/360, color <R(S), G(S), B(S)>]
      [CM/360, color C_HSV2RGB(rgb <CM, 1, 1>)]
      #end // end for S
     } // end color map
    }  // end pigment
    finish {specular 0.6}
    scale 6
    translate y*2.125
   }

 #declare Equation = array [6] {
 function (u) {abs(1) },
 function (u) {abs(cos(u)) },
 function (u) {abs(3 * pow(cos(u),2) - 1) },
 function (u) {abs(cos(u) * sin(u) * sin(v)) },
 function (u) {abs(5 * pow(cos(u),3) - 3 * cos(u)) },
 function (u) {abs( (5*pow(cos(u),2) - 1) * cos(v) * sin(u) ) },
 }


 #ifdef(E) #undef E #end
 #declare E = Equation[N];
   function { E(u)*sin(u)*cos(v) }, // x-axis
   function { E(u)*sin(u)*sin(v) }, // y-axis
   function { E(u)*cos(u) }   // z-axis
   <0, 0>, <pi, 2*pi>   // <Umin, Vmin>, <Umax, VMax>  (Theta, Phi = Altitude,
Azimuth)

   contained_by { box { <-1,-1,-1>*W, <1,1,1>*W } }
   // max_gradient 2
   accuracy 0.0001
   precompute 15 x,y,z
   rotate x*90
   scale 1
   texture {Tex1}
   translate x*3*N
 }


#end // end for N


Post a reply to this message


Attachments:
Download 'sphericalharmonics_2.png' (18 KB)

Preview of image 'sphericalharmonics_2.png'
sphericalharmonics_2.png


 

From: clipka
Subject: Re: Spherical Harmonics
Date: 7 Aug 2016 02:37:17
Message: <57a6d71d$1@news.povray.org>
Am 07.08.2016 um 08:17 schrieb Bald Eagle:

> Color maps I guess are restricted to 256 entries,

True for POV-Ray 3.7.0, but no longer for the current development versions.


Post a reply to this message

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