HollowaySean / BlackHoleViz_v2

Black Hole Visualizer in Unity C#
MIT License
109 stars 11 forks source link

Error in spherical transformation #2

Open jj01101010 opened 1 month ago

jj01101010 commented 1 month ago

Hi HollowaySean,

I read your blog post about visualizing Black Holes and read your code. I think I figured out why you have trouble calculating the z component of your direction vector in RelativisticStart.compute (line 107). I think you made an error when calculating the matrix elements of the transformation matrix in line 34. The transformation matrix components from line 41 and 43 should be -origin.z / (rxz rxz) and origin.x / (rxz rxz). This is why you have to square the components in line 107, because the magnitude of origin.xz is sqrt(x^2 + z^2), but the formula states x^2 + z^2.

https://en.wikipedia.org/wiki/Spherical_coordinate_system (see the jacobian matrix J)

jj01101010 commented 1 month ago

This might also be the reason for your trouble with the numerical errors from the first paper you mentioned, but this is just a guess. I currently try to implement this paper. I will tell you if I figure it out

jj01101010 commented 1 month ago

Actually the numerical issues arise from an error in the paper from Alain Riazuelo. The derivative dk^\theta/dp is wrong. It should be k^theta k^r instead of k^phi k^r.

HollowaySean commented 1 month ago

@jj01101010 Thank you for pointing this out! I can not tell you how meaningful it is to me that anyone is looking at my code, and I appreciate you finding a cause for this.

I am not maintaining this repo any longer, but I intend to make a new version in the near future. I will use this information in the rebuild.