-
Notifications
You must be signed in to change notification settings - Fork 26
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
Set preferred normal direction for conversion from points to FourierPlanarCurve #1463
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1463 +/- ##
==========================================
+ Coverage 95.31% 95.58% +0.26%
==========================================
Files 87 98 +11
Lines 22262 25165 +2903
==========================================
+ Hits 21220 24053 +2833
- Misses 1042 1112 +70
|
desc/geometry/curve.py
Outdated
rotmat = rotation_matrix(axis, angle) | ||
coords_rotated = coords_centered @ rotmat # rotate to X-Y plane |
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.
Why do we need the additional rotation and not just flipping the normal vector direction? I think we only need to flip the normal vector, since that would effectively reverse the parameterization in real space
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.
Alternatively, I think we could flip the sign of the Fourier coefficients r_n
where
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.
The weird thing is that the curve points test passes with just flipping the sign of the normal, but the fields are different between spline and normal-flipped-FourierPlanar unless I redo the rotation matrix with the flipped normal. I'll look into this a bit more.
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.
So I looked at the coil shapes with and without re-rotating, and it appears that if you only flip the sign of the normal without rotating as well, you mirror the curve as well -- this is because you swap the chirality of the curve. If you drew the curve on a piece of paper, flipping the normal would be looking at the sheet of paper from the back, rather than flipping the piece of paper itself.
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.
Can you try flipping the sign of the r_n
coefficients? (Only the
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.
For some reason this doesn't work, no matter what it seems to need both an axis reversal and a rotation (pancake flip) to get the curves to line up again -- I clarified in the code what the rotation is now doing, but I couldn't find the best way to do it without another rotation.
In the process of working on this , I noticed the following behavior: The problematic code in the compute function:
Minimal Example:
The expected behavior of the assertion should be to fail, as |
related to #1456 |
Previously, the
from_values()
method inFourierPlanarCurve
would convert the coords provided to an r(s) representation with s sorted to be monotonically increasing (counterclockwise). However, this means that if the original coordinates were parameterized "backwards" (clockwise), the newFourierPlanarCurve
would return coordinates in a reversed order, which is problematic if you are trying to run something like a Biot Savart integral where the coordinate order is the implicit current direction in the loop. This PR fixes the issue by flipping the normal vector of theFourierPlanarCurve
when the provided coordinates are in the clockwise direction.