Monday 30 March 2020

Calculating area enclosed by intersections

A small math question today.

Given a unit sphere and an arbitrary ellipsoid, calculate the surface area of sphere inside the ellipsoid.

Without loss of generality, we may assume the unit sphere to be centered at origin, then the question depends solely on the 6 parameters defining the ellipsoid, $c_i, \alpha_i$ for $i=1,2,3$ in $\sum (x_i-c_i)^2/\alpha _i ^2 = 1$. Without thinking too much about existence of analytic solution in terms of the parameters, we want to look for ways to calculate or at least approximate the problem.

My own solution is based on the famous Gauss-Bonnet theorem:
$\int _M KdA + \int _{\partial M} \kappa _g ds = 2\pi \chi (M)$

The curvature of a unit sphere is constantly 1, and the Euler characteristic of a disc is 1. As long as you can calculate the geodesic curvature you get
$|M| = 2\pi - \int _{\partial M} \kappa _g ds$.
The intersection is a union of finitely many closed curves we can just calculate one by one.

A simple example would be as follows:

Consider the intersection between $x^2+y^2+z^2=1$ and $(x-1)^2+y^2+z^2=1$. The intersection $\Gamma$ is given by $x = \frac{1}{2}$ and $y^2+z^2 = \frac{3}{4}$. This is a circle of radius $\frac{\sqrt{3}}{2}$ with geodesic curvature $\frac{1}{\sqrt{3}}$. Therefore we have $\int _{\Gamma} \kappa _g ds = \pi$, so $|A| = 2\pi \pm \pi$ depending on the orientation. The surface area can be verified using the formula from Archimedes $|A| = \pi (h^2+a^2)$.

*

Of course, obtaining the parametrization is sometimes too difficult. Are there any easier ways to approximate the answer? Here are two suggestions from my friends.

- Monte Carlo based: sample points on the surface of the sphere and check whether it is in the ellipsoid.

- Integral approximation: similar to Monte Carlo but instead we split the sphere into pieces using spherical coordinates, then the required area is the integral over the indicator function of the ellipsoid.

And of course we can get an estimation using the Gauss-Bonnet approach. Let us call the sphere $S$ and the ellipsoid $E$. We start from a point of intersection, say $x$. The curve goes in the direction $v\in T_xS \cap T_xE$, the intersection of the tangent spaces of the two objects at $x$. We know the intersection must be of dimension 1 because if the two objects are cotangent at the point then the intersection is a point which generates no area after all.

Obtaining this direction is simply algebra, where we find the intersection between two subspace. With this direction we can numerically obtain a closed curve. There is a gap here because we may not go back to the starting point using numerical approximation. We just assume by smoothness (well sphere and ellipsoid are very nice objects) by doing fine enough approximation things would work (actually I believe we can prove this but I am not an expert in numerical methods) -- then we have an approximated curve of intersection.

From here we can calculate its length as well as its geodesic curvature, and the estimated area follows.

Gauss-Bonnet seems quite universal even if we generalize sphere and ellipsoid to other bounded closed $C^{\infty}$ objects because they are manifolds anyway. The only worry being whether we can get a closed curve without any global features that promises convergence.

*

Well this is just a funny little problem that I enjoyed during the lockdown. I feel like I should write some maths before I go back to my creation whether it is literature, music or research.

Meanwhile I hope everyone is alright during the pandemic -- whether you call it COVID-19, or Wuhan virus. Stay indoor, and stay healthy.

Monday 9 March 2020

⑨/3/2020 Cirno's ⑨th Anniversary

我真的很喜歡senya的聲音……應該說是Prim的聲音。



來點閒話家常吧。

看見以前自己所觸及的巔峰,卻也再上不去大概是創作者最害怕的事情之一。不單是創作,在電玩、競技、人生也是如此。不過其他事物總有一種規律天命可循,唯獨創作靈感來去如風,自身風格也受到天時地利人和影響,每件作品都可謂可遇不可求。

比如周董的<<不能說的祕密>>。
比如牧場物語的礦石鎮。
比如龍王裡面的九頭龍八一……不過人家情場得意,剛剛還修成正果。

自認還沒有本事先摸到自己的頂點,只不過最近回鍋卻好像怎樣抓不到感覺。

我說過,我自己最滿意的Osu!太鼓圖有三張。

YuFu - Holy Moon是自己進入太鼓界的鑰匙,做出自己最高水準似乎理所當然。

IIDX的Babylonia是自己熟識的民族風,加上自己在風雪中偶然得到靈感,做出佳作也是順理成章。

然後是IOSYS的算術教室。在東方大舉進攻音遊的世代,這首歌只是眾多東方音遊曲之一,甚至不在最熱門之列。論熱度IOSYS本身的魔理沙大盜、昆布與Usatei都在算術教室之上;其他團如Silver Forest、EastNewSound、Sound Holic等同時也有不少經典大作。除去James鬼畜圖和數學這兩個因素之外實在很難找到我對這張圖特別滿意的原因。是梗嗎?當年我還沒涉足東方,也聽不懂日文呢。

如果不是歌曲本身的話大概就只有譜面的原因了。

Cirno's Perfect Math Class [Wmf's Taiko]

純色連打貫穿整個譜面,顯現出極強的古典風格。即使在當年年看這張譜面也會覺得這張圖是2009到2010的產物。1/2與1/4連打將所有句子串起來則是本人簡單實用的風格,1/4雖然塞得滿卻不會有任何的違和感。當時我的簽名檔還寫著不要為stream而stream,這張譜面公開了以後立刻就被人拿這句質疑--我沒有為stream而stream就是了,每一句我都能給出相對的解釋。

這張譜面所代表的我是最古典的我,即以大量轉譜和古典樂理為基礎所磨鍊出的風格。

上面那張是在11年2月5日ranked,⑨年後的2020正是做算術教室⑨週年的好時機。但⑨年後的我,做譜風格早已被「污染」:難度通漲所引致主流風格的偏移、1/6以上的混用、K社音遊的亂來風格等,潛移默化地成為了自己一部分。當我想用自己現有風格造出相近的效果時卻發現自己怎也再寫不出那種感覺。明明連打的紅藍轉換不再限於1/2拍上,自己卻發現dkkdk kkkdd這類連打放哪都不對;明明大家對串圖的接受程度比以前更高,我的成品卻比以前少了快150個音符。

雖然風格變化不一定是壞事,但是做出來沒有達到理想中的水準的話檢討的空間還是有的。如何適應這個截然不同的世代並將自己的風格展現出來,對自己能否保持動力map下去至關重要。

不論如何,這張⑨週年版的譜面即使沒達到我心中的水準[8.5/10],要拿個不錯的分數還是可以的。我會給目前的成品7到7.5分吧。圖包等Guest diff到齊以後就會一併上傳。

Cirno's Perfect Maths Class: The 9th Anniversary Edition [Wmf's 2011 Taiko]

說句題外話,C97的高質量原創音樂其實不少。但因為它們不屬於東方或其他主流同人,外人接觸它們的機會比較少。在這裡我力推古典歌劇風的love solfege,主唱綾野えいり的歌劇腔與意大利人都對她讚譽有加: