[HN Gopher] Spherical Harmonics
___________________________________________________________________
Spherical Harmonics
Author : raffihotter
Score : 100 points
Date : 2024-12-20 05:34 UTC (3 days ago)
(HTM) web link (www.rhotter.com)
(TXT) w3m dump (www.rhotter.com)
| gus_massa wrote:
| They look too big. I expected all the l=1 to be like a cone near
| (0,0,0). And I expected one of them to be vertical instead of
| horizontal.
| esperent wrote:
| I'm not sure about the size but I _think_ the shapes are
| correct. It 's just very hard to examine them when they're
| rotating at such high speed.
|
| Compare them to the image on this page:
|
| https://en.m.wikipedia.org/wiki/Spherical_harmonics
|
| Suggestion to OP: this would be much more useful if you add a
| button to stop the rotation.
| dtgriscom wrote:
| ... or a slider to control the rotation position or speed.
| gus_massa wrote:
| Now it looks better close to the 0. Did the OP change the
| implementation?
|
| ALso, I noticed that there is a real/imaginary/complex menu.
| I was looking at the real part of the complex versions, but
| it's necesary to look at the complete complex version to
| understand them.
|
| Note that the graphic in Wikipedia is showing the real
| versions. In the real versions you for l=1 the functions in
| directions x, y and z[m=0], and all of them look identical
| except for the direction. But in the complex versions you
| have (x+iy)/sqrt(2)[m=1], (x-iy)/sqrt(2)[m=-1] and z[m=0],
| and when you show only the real part of them the first two
| are smaller.
| liontwist wrote:
| why does the page scroll when I drag a slider?
| raffihotter wrote:
| Hmm, looking into this.
| CamperBob2 wrote:
| Any updates on the ultrasound brain imager project? I
| remember reading about that a couple of years ago but didn't
| see any follow-ups. It sounded extremely nifty.
| raffihotter wrote:
| im still working on ultrasound stuff, but specifically for
| BCI! https://news.ycombinator.com/item?id=42021450
| raffihotter wrote:
| fixed! sorry about that, and thanks for the feedback
| liontwist wrote:
| Thanks for sharing and making a fix.
| ghostpepper wrote:
| Anyone know a good explanation of what spherical harmonics are?
| NotYourLawyer wrote:
| Solutions to a certain differential equation that comes up in
| quantum mechanics and elsewhere.
| defrost wrote:
| Coming at them from practical applications is one approach.
|
| I've used spherical harmonics to model earth centric "surfaces"
| and fields - magnetics and gravity, etc.
|
| You might think of them as a stacked sine and cosine waves
| (like a fourier transform breaking a continuous function into
| sin and cosine components) on a directional vector radiating
| outwards from the centre point of sphere.
|
| https://geomag.bgs.ac.uk/research/modelling/IGRF.html
|
| https://en.wikipedia.org/wiki/International_Geomagnetic_Refe...
|
| https://en.wikipedia.org/wiki/World_Magnetic_Model
| lizmutton wrote:
| I think of it as a good basis for functions on a perfectly
| spherical surface. Going down in levels of "l", you describe
| more and more details in terms of angular scale.
|
| Thus, it's widely used in earth science and astrophysics, and
| anything that involves spherical symmetry (like a Hydrogen
| atom) -- in reality, nothing is a perfect sphere, but that's a
| very good approximation.
| ajkjk wrote:
| Just for fun...
|
| They are relatively easy to understand if you already
| understand Fourier transforms.
|
| In a Fourier transform you can write some (suitably well-
| behaved) function f(x) as a sum of a bunch of sinusoids of
| different frequencies:
|
| f(x) = a_0 + a_1 cos(x) + a_2 cos(2x) + ... + b_1 sin(x) + b_2
| sin(2x) + ...
|
| Or more generally a sum over all real values, f(x) = [?] a(k)
| cos(kx) + b(k) sin(kx) dk, since signals can have fractional
| frequencies.
|
| And in many cases the two sides are the same. Many operations
| in math and in ph operate on functions in such a way that they
| can distribute over their behavior on different frequencies,
| which is why Fourier transforms are really useful. For instance
| we hear different frequencies in different ways so if you
| Fourier-transform an audio waveform you can turn some
| frequencies up and others down (or drop them entirely, which is
| more-or-less what mp3 compression is).
|
| This also works in 2d or 3d, where now you have frequencies in
| all three directions:
|
| f(x,y,z) = f(0) + a_(100) cos(x) + a_(110) cos(x) cos(y) +
| a_(111) cos(x) cos(y) cos(z) + (all the sine terms and negative
| frequencies and everything else)
|
| and this is useful in all kinds of ways also, e.g. taking
| Fourier transforms of a 2d image and then dropping the high
| frequency components that are hard to see is basically what
| JPEG compression is. As before it helps a lot that you can
| interact with the different frequency components separately.
|
| But. Sometimes what you want is not the frequency in linear
| space (e.g. the frequency in x or y) but the frequency in
| angular coordinates: to ask "how many times does this variable
| change as you go around a circle in the (xy) plane?" Which is
| to say, you want to know the Fourier component in term like
| cos(ph), cos(2ph), sin(ph), etc. That looks like
|
| f(x,y) = a_1 cos(ph) + a_2 cos(2ph) + b_1 sin(ph) + ...
|
| Which is what we would call a "circular harmonic" (with
| ph=ph(x,y)=arctan(y/x)), each coefficient a_i is a function of
| (r). Unlike the linear Fourier transform, there can be no
| "fractional" frequencies---since ph=0 and ph=2pi are the same
| point, all the circular frequencies have to be integers.
|
| When you try to do this in 3d using two angular coordinates ph
| and th, it gets a lot funkier. Now you can't really write it as
| a simple series of the two frequencies separately; they kinda
| "step on each other", because a rotation in (xy) can be written
| as a sum of rotations in (yz) and (zx).
|
| But you can do it in terms of a different, slightly stranger
| series. One variable L=0,1,2,3... will describe the "total"
| frequency on any plane, and another variable
| m=-L,-L+1,...0,...L-1,L describes how many rotations happen in
| your favorite choice of (xy) plane. m is allowed to range from
| -L to L because we have already said that L is the total
| frequency on any axis, so we just have to say whether they're
| happening in our chosen axis or not. So the series becomes
|
| f(x,y,z) = a_(0, 0) + a_(1,-1) Y_(1,-1) + a_(1,0) Y_(1,0) +
| a_(1,1) Y_(1,1) + a_(2,-2) Y_(2,-2) + ... = [?] a_(L,m) Y_(L,m)
| (th,ph)
|
| The functions Y_(L,m) (th,ph) are the "spherical harmonics".
| They serve the role of sin(ox) and cos(ox) when you Fourier-
| expand a function in terms of spherical coordinates ph and th.
|
| There are lots of reasons that that's useful, but the case that
| is most well-known is that the state of an electron wave
| function in an atom can be indexed in terms of which spherical
| harmonic it's in, and only two electrons are allowed to be in
| each one (one spin up and one spin down, for much-more-bizarre
| reasons). So the spherical harmonic functions are also the
| shape of the various electron orbitals that you see in a
| chemistry textbook.
| aeonik wrote:
| Thank you, this made it click for me.
| setopt wrote:
| Excellent explanation.
|
| > So the spherical harmonic functions are also the shape of
| the various electron orbitals that you see in a chemistry
| textbook.
|
| Minor nitpick: Chemistry textbooks usually use the "cubic
| harmonics" instead of the "spherical harmonics". They are
| real-valued linear combinations of the standard spherical
| harmonics, with the additional benefit that the basis set
| respects the Cartesian symmetries.
|
| For example, the "p_z orbital" is a l=1 spherical harmonic
| and a cubic harmonic. But the cubic harmonics then add p_x
| and p_y orbitals as basis functions, whereas the spherical
| harmonics choose the chiral "p_x +- ip_y orbitals" as its
| basis instead.
| ajkjk wrote:
| Oh thanks, I didn't know that (I studied physics and only
| know the chemistry part superficially). But I did know, and
| wondered about, the fact that the spherical harmonics have
| an e^imph factor yet there's nothing about the explanation
| that involves complex numbers per se (besides that writing
| out sine/cosine series is way more tedious than
| exponentials). Makes sense that they just get factored.
| xkcd-sucks wrote:
| You know if you take a metal plate bolted down at it's center,
| throw some salt on it and bow the edge with a violin bow. It
| makes stable patterns depending on the frequency of the tone
| playing
|
| Now take this plate and turn it into a 3d sphere and that's
| spherical harmonica more or less. Electronsike to form them
| jms55 wrote:
| Very very high level explanation that I'm trying to paraphrase
| from memory, so there's a good chance parts of it are wrong or
| use the wrong terminology:
|
| A polynomial is a function like `f(x) = Ax^3 + Bx^2 + Cx^1 +
| Dx^0`
|
| You can approximate most(all?) continuous functions using
| polynomials. The more "parts" (e.g. Bx^2 is one part) of the
| polynomial you have, the better you can represent a given
| function.
|
| The previous example was a 1d function, but polynomials can be
| over any number of dimensions. E.g. a 3d polynomial `f(x, y,
| z)`.
|
| Spherical harmonics are just a form of 3d polynomials, but with
| some special "parts" (called a basis function), with the amount
| of parts you have called a "band".
|
| As for what they're good for, they're a fairly compact way of
| representing and filtering 3d signals.
|
| In 3d rendering, they're really good at storing light hitting a
| point from different directions. You have an incoming ray of
| light on a unit sphere/hemisphere with origin x, y, z going
| towards the given point. You can then take your list of light
| rays with various (x,y,z) origins and (r,g,b) intensities, and
| then form a spherical harmonics approximation over it
| (basically a fitted 3d polynomial), which can be stored as just
| a few coefficients (A, B, C, D, etc...) using 1 or 2 bands, and
| cheaply computed (querying the light value r,g,b for a given
| ray) by plugging in the ray's x, y, z into the formula.
|
| Besides being cheap to store and query, because you're only
| using 1-2 bands, you only capture the "low frequency" of the
| lighting signal, e.g. large changes in the light value get
| dropped, since it's just an approximation of the original
| signal. While this is normally bad, for 3d rendering, it's free
| denoising, giving you a smoother output image!
| bjornsing wrote:
| Spherical harmonics are essentially orthogonal basis functions
| on the sphere. They are popular in 3D graphics because you can
| very quickly compute the sphere integral over the product of
| two functions, as the dot product of their basis function
| coefficients(!). This can be used for real-time complex
| lighting on relatively modest hardware.
| raffihotter wrote:
| I added an explanation to the page! Hope it's helpful.
| quantum_state wrote:
| They are just eigen states of the angular momentum operator.
| setopt wrote:
| That's a very quantum physics-centric explanation though
| (username checks out...).
|
| A more general definition is that they are eigenfunctions of
| the Laplacian operator on a sphere, which arise in many
| contexts.
| jasomill wrote:
| More generally, see also the Laplace-Beltrami and Laplace-
| de Rham operators, both defined on (pseudo-)Riemannian
| manifolds not necessarily embedded in R3.
|
| Even more generally, see the huge body of beautiful
| mathematics that has arisen from the study of elliptic
| differential operators in general (de Rham cohomology,
| Hodge theory, the Atiyah-Singer index theorem, ...).
| Koshkin wrote:
| Did you mean that they are basis functions for irreducible
| representations of _SO_ (3)?
| xeonmc wrote:
| a vibrating string make sine waves, a vibrating bubble make
| spherical harmonics.
| Applejinx wrote:
| Love it, that's a fantastic image for these. As a musician
| intimately aware of how vibrating strings work, the vibrating
| bubble is a perfect analogy, it seems.
| dahart wrote:
| Musicians: see also radial planar circular harmonics, e.g.
| drums. This is a halfway point in between vibrating strings
| and vibrating bubbles. It's highly applicable in music and
| is easier to understand and visualize than 3d basis
| functions; maybe a nice stepping stone.
|
| https://en.wikipedia.org/wiki/Vibrations_of_a_circular_memb
| r...
| ajross wrote:
| It's the list of "waves" that can propagate around the surface
| of a sphere without interfering with each other. They are self-
| reinforcing modes. So you can represent any function of values
| on the surface as a combination of these, the same way you do
| with e.g. FFT coefficients in a JPEG file.
|
| And it turns out that this "self-reinforcing" property is
| critically important for quantum mechanics, as each of the
| functions defines a different "state" from the perspective of a
| "particle". So we can do a lot of good physics work[1] by
| pretending[2] that all electrons exist in one of these states.
|
| [1] Like, y'know, explaining chemistry.
|
| [2] The details are always harder, because the electrons
| interact with other ways than just flying around the sphere, so
| the math isn't tractable in an absolute sense. But as long as
| you pretend that this is mostly right you can treat the
| remainder as just "fixups" in a giant framework called
| perturbation theory.
| lizmutton wrote:
| Neat!! thanks for sharing
| JeremyHerrman wrote:
| For those of you curious about WHY these shapes look like the do
| (e.g. "why does l=0, m=0 have a donut in the middle of two
| lobes?"), this video from Munster University finally gave me an
| intuitive understanding of how these shapes arise.
|
| https://youtu.be/Opufc3onVow
| JeremyHerrman wrote:
| typo here, l=2,m=0 is the orbital with the donut
| vecter wrote:
| Are these related to (or exactly) the distribution of electron
| orbits?
| aeve890 wrote:
| Yes. These are solutions of the Schrodinger equation for the
| electron in the hydrogen atom.
| drdeca wrote:
| Aren't the spherical harmonics functions with domain S^2, the
| sphere? I think the solutions to the (time-independent)
| Schrodinger equation for an electron in a hydrogen atom are
| given by like, a product of a function of distance from the
| center with one of the spherical harmonics, or something like
| that?
| momoschili wrote:
| you are correct. The Schrodinger equation for the hydrogen
| atoms in spherical coordinates demonstrates separability
| which allows you to separate the radial and angular
| coordinates. The radial term, which is most interesting due
| to the 1/r potential is typically a Laguerre polynomial.
| The angular term is 'free' from any potential is typically
| a spherical harmonic.
|
| The spherical harmonics in general are typically derived as
| part of the solution to the Laplace equation in spherical
| coordinates. A bit of a semantic point (though perhaps the
| distinction is important) though, since the Laplace
| equation's angular dependence is identical to that of the
| Schrodinger equation for the hydrogen atom.
| momoschili wrote:
| not quite as they are missing the radial dependence
| ajross wrote:
| It's actually more confusing IMHO, because these graphs
| _overload_ the radial dimension to show probability as
| "distance from the origin". You have to multiply that by the
| radial function to get an actual probability distribution,
| which kinda/sorta looks like these pictures but not really.
|
| Really the harmonics are best understood as something like
| "wave height on the surface of a sphere". They tell you how
| the electrons (or whatever) are going to distribute
| themselves radially, not where they're going in 3D space.
|
| Also FWIW: the much harder thing to grok here (at least it
| was for me), and that no one tries to tackle, is why the "l"
| number corresponds directly to angular momentum. In
| particular "l==0" doesn't look like there's any rotation
| going on at all.
| momoschili wrote:
| Simply speaking, "l" describes the number of nodes. In the
| same sense that a particle in a box with sin(nx) wave
| function has more nodes the higher energy (or momentum)
| state it is in.
|
| As for why l==0 has no rotation going on at all, one would
| say that this should be expected. Qualitatively, the
| symmetric sphere does not change with rotation, so how
| would we tell if it is rotating or not? And perhaps the
| next step is controversial, but if there is no way to tell,
| maybe there is no dependence? This is a similar argument to
| why the electric field of an infinite plane is constant
| with respect to distance from it.
| Scene_Cast2 wrote:
| If anyone is curious about applications - these can be used to
| approximate low-frequency components of a point's surroundings.
| They were used in Halo 3 to do real-time HDRI lighting and
| shadowing (see "Lighting and Material of Halo 3" from Siggraph
| 2008).
|
| After the success of this method, there was a fairly long stretch
| of researchers looking for a better orthonormal basis (such as 2D
| Haar wavelents, as spherical harmonics is basically a Fourier
| Transform on a spherical basis). I think the pinnacle of this
| direction was Anisotropic Spherical Gaussians from 2013.
|
| These days though, you'd at least use a neural net to learn a
| basis (or use a neural net to learn something else entirely). And
| of course, Gaussian Splats are the technique du jour for realtime
| relighting.
| xeonmc wrote:
| I wonder if Cartesian-basis multipole expansion could get the
| best of both worlds of GS and SH, as the former basis captures
| anisotropy but not detail while the latter captures detail but
| not anisotropy, whereas Cartesian multipole expansion naturally
| captures both right from the low orders, and is much easier to
| align to game worlds.
|
| (to be precise, both can be captured by either if you include
| enough orders, what I mean is mainly how the information
| distribution scales with respect to each attribute)
|
| Also, the age-old physics question: what is the minimum order
| of spherical harmonics required to approximate a cow?
| RossBencina wrote:
| Another application is Ambisonic sound spatialisation formats,
| where a finite set of signals corresponding to spherical
| harmonics are used to encode spatial sound fields.
| https://en.wikipedia.org/wiki/Ambisonics
| ziotom78 wrote:
| They are used also to characterize the statistical properties
| of fields over the sphere. A notable example is the pattern of
| hot/cold spots in the Cosmic Microwave Background Radiation
| (CMBR, [1]). They are distributed stochastically, and the best
| way to fit cosmological models against the measurements is to
| decompose the temperature/polarization fields into spherical
| harmonics and compute the power spectrum associated with each
| (which plays the role of a "spatial frequency" over the sky
| sphere).
|
| [1] https://en.wikipedia.org/wiki/Cosmic_microwave_background
| dustingetz wrote:
| in QM the spherical harmonics are more of a basis space for
| electronic state and not the actual electronic state, right? So
| does that mean there are other ways to think about electron
| configurations that satisfy Shrodinger etc?
| rsfern wrote:
| Yes - for example when modeling solid materials it's common
| to use a plane wave basis set for the electronic wave
| function instead of atomic orbitals
| pletnes wrote:
| Spherical harmonics are exact solutions to electronic states
| for hydrogen-<<style>> atoms.
| evanb wrote:
| ... for the angular dependence; there is also radial
| dependence.
| rzzzt wrote:
| I have "Spherical Harmonic Lighting: The Gritty Details" in my
| PDF stash: https://www.semanticscholar.org/paper/Spherical-
| Harmonic-Lig...
| lloda wrote:
| The vector version of these is used in antenna theory to
| represent and transform the radiation of finite sources, like
| when measuring antenna patterns.
| dwallin wrote:
| I do want to point out, gaussian splats don't really offer
| anything in particular for realtime relighting, if anything it
| adds additional challenges. Under the hood, most
| implementations leverage spherical harmonics for baked-in
| lighting.
|
| Did you by chance mean anisotropic spherical gaussians? ASG is
| a new-ish technique often used to model specular lighting but
| is unrelated to gaussian splatting.
| jms55 wrote:
| Obligatory useful SH paper for 3d rendering:
| http://www.ppsloan.org/publications/StupidSH36.pdf
|
| Also lots of other cool research around SH in rendering, e.g. the
| recent ZH3 paper.
| raffihotter wrote:
| Thanks for sharing this! Linked it on the website.
| ykonstant wrote:
| Stupid sexy harmonics.
| tomxor wrote:
| Shameless plug, in 140 bytes https://www.dwitter.net/h/wikimedia
| djmips wrote:
| Is this a math function that fits in a tweet challenge?
| tomxor wrote:
| Yes but It's just demos, doesn't have to be so purely Math.
| setopt wrote:
| See also the "cubic harmonics", which is an equivalent basis to
| spherical harmonics but they are real instead of complex, and
| also more natural to use in cubic crystals due to their
| symmetries.
|
| I have also seen "triangular harmonics", "zonal harmonics", etc.
| in use in other materials.
| openrisk wrote:
| Next project: spin harmonics
|
| https://en.m.wikipedia.org/wiki/Spinor_spherical_harmonics
| pletnes wrote:
| If you need to work on numerical computation with spherical
| harmonics, I've used this library with some success.
|
| https://github.com/SHTOOLS/SHTOOLS
| dagss wrote:
| TL;DR about spherical harmonics: It is what you use instead of
| Fourier transforms if what you transform is on the surface of a
| sphere.
|
| My experience is from cosmology (CMB) where they are heavily used
| just like Fourier transforms, I think they are also used in
| meteorology.
___________________________________________________________________
(page generated 2024-12-23 23:01 UTC)