Repository navigation
Deprecate Mesh.from_grid in favor of Mesh.from_lattice - #170
Open
janbridley wants to merge 6 commits into
Open
janbridley wants to merge 6 commits into
janbridley wants to merge 6 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Mesh.from_gridnow raises a DeprecationWarning, in favor of theMesh.from_latticeconstructor. I also slightly changed the parameterization of the mesh generation, which anchors the mesh at [1,0,0,0] without significantly changing the uniformity. As far as I know this is novel, although the finding it small and fairly unimportant as one could always just rotate all the outputs from the original mesh to the desired alignment.def _quaternion_fibonacci_lattice(n): """Generate a near-uniform grid of `n` quaternions. This is equivalent to a Fibonacci lattice on the 3-sphere. See `this paper <https://ieeexplore.ieee.org/document/9878746>`_ for a derivation. """ psi = 1.533751168755204288118041413 # Solution to ψ**4 = ψ + 4 - s = np.arange(n) + 1 / 2 + s = np.arange(n, dtype=float) + s[1:] += psi / 2 t = s / n d = 2 * np.pi * s r0, r1 = (np.sqrt(t), np.sqrt(1 - t)) α, β = (d / np.sqrt(2), d / psi) # Allocate as rows and then transpose, rather than stacking columns result = np.empty((4, n)) - result[...] = r0 * np.sin(α), r0 * np.cos(α), r1 * np.sin(β), r1 * np.cos(β) + result[...] = r1 * np.cos(β), r1 * np.sin(β), r0 * np.cos(α), r0 * np.sin(α) return result.TMotivation and Context
In #33 , I added a quaternion fibonacci lattice which I interpreted as being slightly worse than the existing from grid. However, on further review, the fibonacci grid is actually better for the most important metric: max distance. While the average behavior of the pseudo-Tames solutions is better, the worst-case behavior is far worse, as you end up with small holes in the mesh. As a result of this strain, you also end up with some wasted points that are very near one another.
Looking forward,
from_latticenaturally generalizes to other rotation groups (higher dimensions, other metric spaces, 2d, etc.). from_mesh requires a different signature in each dimension even if it performed well.How Has This Been Tested?
Existing tests pass, and I've added a test to validate the warning. Note that some tests fail if the input mesh does not include the identity quat, so in an ideal world we would bump up the test orientation count and manually exclude the "known" ideal case.
Checklist: