-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🍩 #533
🍩 #533
Conversation
Just two first feedback points:
|
First of all, outstanding PR naming game, bravo 💯 ! That looks excellent. I had actually just started working on an atlas for the n-torus here: https://github.com/FedeClaudi/Manifolds.jl/blob/master/torus_wip.jl Anyway, I'll have a look at the code in a second, but it looks great. I wonder how it would generalize to torii of genus > 1 for which there's no nice parametrization? Also, I will steal your visualization code if that's okay, that's such a pretty way to visualize surfaces! |
Codecov Report
@@ Coverage Diff @@
## master #533 +/- ##
==========================================
+ Coverage 98.93% 98.95% +0.02%
==========================================
Files 96 99 +3
Lines 9278 9495 +217
==========================================
+ Hits 9179 9396 +217
Misses 99 99
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Good point, it's topologically the same as the current torus, just with a different metric and point/tangent vector representation.
Thanks, I'm going to add a geodesic curve to that picture, then I will ask for some help turning it into a notebook 🙂 . It would be cool to have sliders for selecting tangent vector for geodesic in the docs.
Cool, that's also a good approach to making an atlas. Manifolds.jl currently focuses on working in an embedding, yes, but the API allows for working without it. Your In this PR I will add a way to compute geodesics fully in charts. Maybe with chart switching if there is an easy way to do it in OrdinaryDiffEq.jl. Also maybe with sensitivity analysis for a gradient-descent-based logarithmic map.
I did a quick search and maybe this would help: https://cs.brown.edu/people/jhughes/papers/Grimm-PNT-2003/paper.pdf ? We would still need to define a metric in some way though, in case of the torus in this PR I simply take the metric from the embedding.
Sure, I stole most of it from here: https://beautiful.makie.org/dev/examples/generated/2d/surfaces/gabriels_horn/ 😄 . |
That's great, I'll have a look at that paper. I'd be happy to help making it an interactive example, it'd be very useful and it would get me to try and understand better the code you're working on. Looking forward to seeing what comes out of it! |
Oh also a different metric, interesting – then you could but I would avoid c) then (just use points/tangent types) because that might be mistaken of a different representation for the default metric we have.
Sure, no problem, I can help turning that into a Pluto Notebook (and maybe even adding it to the docs, since we should start more tutorials I think). |
As a new user: yep. I really like |
To try this you just need to run |
Nice! That looks great! |
test/manifolds/generalized_torus.jl
Outdated
X = get_vector(M, p, X_p0x, B) | ||
@test get_coordinates(M, p, X, B) ≈ X_p0x | ||
|
||
@test_broken norm(X) ≈ norm(M, p0x, TFVector(X_p0x, B)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kellertuer Could you check if this test actually makes sense? This is supposed to test that the vector X
in embedding of the torus has the same norm as calculated using its coordinates in the induced basis and the metric tensor. I'm not sure where I could have a mistake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this one error? If so – by how much?
Also just norm(X)
is a little surprising, is that already in the embedding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, X
is in the embedding and the difference is large:
Expression: norm(X) ≈ norm(M, p0x, TFVector(X_p0x, B))
Evaluated: 2.6832815729997477 ≈ 1.4422205101855958
I'd expect the embedding to be isometric because the metric is actually defined through that embedding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes then I would expect that as well. But for the next few days I do not have time to check the code too much I fear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, it can wait.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, but I hope that in the best case the code works fine after you fixed that 🤓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've found the errors but one of them looks like an issue with API. Currently local_metric
expects point in the embedding while arguably it would make sense to pass there coordinate in a basis. It would be nice to be able to tell these two cases apart by method signatures. Do you have an idea for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, that you found it
Which local_metric
do you refer to? The one on the sphere
Manifolds.jl/src/manifolds/Sphere.jl
Lines 285 to 291 in 71d9d81
@doc raw""" | |
local_metric(M::Sphere{n}, p, ::DefaultOrthonormalBasis) | |
return the local representation of the metric in a [`DefaultOrthonormalBasis`](https://juliamanifolds.github.io/ManifoldsBase.jl/stable/bases.html#ManifoldsBase.DefaultOrthonormalBasis), namely | |
the diagonal matrix of size ``n×n`` with ones on the diagonal, since the metric is obtained | |
from the embedding by restriction to the tangent space ``T_p\mathcal M`` at ``p``. | |
""" |
Does what I would expect – the point p on the manifold (or would you prefer that in charts/coordinates?)
Because there G = local_metric(M, p,B)
returns the metric as a matrix such that for tangent vectors given in coordinates with respect to B
we have c1'*G*c2
which is what I would expect.
One could write one that is g = local_metric(M,p)
such that X'*g*Y
works for vectors (not coordinates).
So I am not sure what you mean by "point in a basis", since we do not have a basis on the manifold.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, it was a bit late -- I meant passing point as parameters in a chart. So probably something like local_metric(M::AbstractManifold, A::AbstractAtlas, i, a)
for coefficients of the metric tensor at point with parametrization a
in chart i
from atlas A
in basis induced by that chart at that point.
What I'd like to develop here a bit is working on a manifold without an embedding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, but then A
solves your thing here :) I like the signature you propose.
What I also meant was, that there is a (though only subtle and small) difference between point-representation and embedding. But sure in charts is what you meant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should document the new torus together with the old torus on the same documentation page, what do you think?
Sure, I can more documentation there. |
I've added computing log/distance/geodesic between two points by solving a BVP in a chart. So I would consider this PR feature-complete, and it just needs some docs and a bit of polishing. I'm quite happy that we have now a decent way to work in charts, and what we have here should nicely generalized to higher-genus tori. |
looks great, looking forward to playing around with it! |
@kellertuer I think this is ready for review. One major point is the new |
Thanks for the summary, I will be travelling the weekend but try to find time to check stuff. |
No problem, we can finish this next week 🙂 . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice PR; I have a few comments, but nothing too serious.
Could you also check for code coverage a little bit? We are not far away from the required rate, just a few lines shy I think.
Thanks, I will check the coverage after addressing your comments. |
Co-authored-by: Ronny Bergmann <[email protected]>
I think I've resolved all issues 🙂 . |
Some initial work on implementing a curved torus discussed in #532 .
Currently it's possible to draw a torus:
as well as do some basic conversions to/from an atlas.
@FedeClaudi you can take a look how$\mathbb{R}^3$ to an in-chart representation. Does that look somewhat understandable? Higher-genus tori would most likely have to implement the same functions, except the embedding can be skipped if explicit transition maps are provided. Currently by default transition maps are defined using an embedding but that's not required.
get_chart_index
is used to select a chart around a given point,get_parameters!
andget_point!
covert to and from parameters in a chart andget_vector_induced_basis!
converts tangent vectors from a representation inI've started work on a fully in-chart geodesic solver but I need to think about it a bit more, so that's not ready for review.