Engine prototype #13
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "engine-proto"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The branch to be merged tracks our work on prototyping a geometric constraint-solving engine. This work is in the
engine-proto
folder. Most of the code is in Julia (version 1.10.0).Approaches
We tried two broad approaches to the constraint geometry problem. Each one suggested various solution techniques. The Gram matrix approach, with the low-rank factorization technique, seems the most promising.
Algebraic (In the
alg-test
subfolder). Write the constraints as polynomials in the inversive coordinates of the elements, and use computational algebraic geometry techniques to solve the resulting system. We tried the following techniques.Engine.Algebraic.jl
). Symbolic. Find a Gröbner basis for the ideal generated by the constraint equations. Information about the solution variety, like its codimension, is then relatively easy to extract.Engine.Numerical.jl
). Numerical. Cut the solution set along a random hyperplane to get a generic zero-dimensional slice, and then use a fancy homotopy technique to approximate the points in that slice.A few notes about our experiences can be found on the engine prototype wiki page.
Gram matrix (in the
gram-test
subfolder). A construction is described completely, up to conformal transformations, by the Gram matrix of the vectors representing its elements. Express the constraints as fixed entries of the Gram matrix, and use numerical linear algebra techniques to find a list of vectors whose Gram matrix fits the bill. We tried the following techniques.gram-test.sage
,gram-test.jl
,overlap-test.jl
). Find a cluster of up to five elements whose Gram matrix is completely filled in by the constraints. Use LDL decomposition to find a list of vectors with that Gram matrix. This technique can be made algebraic, as seen inoverlap-test.jl
.low-rank-test.jl
) and an visualization of the loss function landscape near global minima (basin-shapes.jl
).The Gram matrix parameterization wiki page contains detailed notes on this approach.
Findings
With the algebraic approach, we hit a performance wall pretty quickly as our constructions grew. It was often hard to find real solutions of the polynomial system, since the techniques we use work most naturally in the complex world.
With the Gram matrix approach, on the other hand, we could solve interesting problems in acceptably short times using the low-rank factorization technique. We put the optimization routine in its own module (
Engine.jl
) and used it to solve five example problems:overlapping-pyramids.jl
circles-in-triangle.jl
sphere-in-tetrahedron.jl
tetrahedron-radius-ratio.jl
irisawa-hexlet.jl
We plan to use low-rank factorization of the Gram matrix in our first app prototype.
Visualizations
We used the visualizer in the
ganja-test
folder to visually check our low-rank factorization results. The visualizer runs Ganja.js in an Electron app, made with Blink. Although Ganja.js makes beautiful pictures under most circumstances, we found two obstacles to using it in production.OK, by way of starting the review of this PR, I looked over the first six rows of notes/inversive.md, and had a few questions:
I will finish the review when you've had a chance to do these things, thanks.
P.S. I have now understood from today's discussion that the coordinates in the current prototype are not quite exactly these. I think we should probably leave these notes alone, but just clearly document wherever the coordinate entities are declared exactly what they are are and how they relate to these coordinates. Thanks!
P.P.S By "leave alone," I didn't mean that we shouldn't do the three things I requested in the review above; I just meant that we shouldn't change the inversive coordinate system described in the notes, but rather document in the code how the one there differs from what's described in the notes.
8084fde
,bd3e350
,a182b66
,23ecca3
.Q(I_\infty, I_P) = 1/2
normalization that we use is useful for working with distances, because the direction ofI_\infty
says where the point at infinity is and the normalization ofI_\infty
encodes a choice of scale.(0, 1, 0, 0, 1)
and(0, -1, 0, 0, 1)
are related by a reflection across the origin followed by a reversal of orientation. The pair you're looking for is(0, 1, 0, 0, 1)
and(0, -1, 0, 0, -1)
, which coincide and have opposite orientations.More about the inversive coordinates, sorry.
I slightly amended the condition that two sphere/planes (sphlanes?) intersect: seems it should be
|Q(I,J)| \leq 1
, with ordinary (not double) absolute value bars and\leq
rather than<
. Please confirm you agree.I am now confused by the row "P is center of sphere rep'd by I":
a. Would it be clearer in the formula cell instead of "..., and
I_P
is normalized to have $Q(I_\infty, I_P) = 1/2$" to say "..., as long asI_P
is normalized in the standard way in whichQ(I_\infty, I_P) = 1/2
?b. In the notes cell, shouldn't it be "(1) the point
P
has signed distance-r
from the sphere", rather than-r/2
?I am also confused by the row "Signed distance between point rep'd by V and sphere/plane rep'd by I":
a. In the notes cell, you give the example that the point rep'd by
V=(d^2, 1, 0, 0, d)
and the sphere byI=(0, 1/r, 0, 0, -1)
are obviously at signed distanced
from one another, which I agree with. But given this, it seems to me from the formula that in this caseQ(V,I) = d^2/2r + d
from the formula forQ
(notd^2/2r - d
).b. Presuming that's the case, and that the formula then works in general, then the formula cell in this row should have
Q(I_\infty, I)d^2 + d
on the right-hand side. Would it be helpful to also include the following in the formula cell?So if
V
is normalized in the standard way and the radius of the sphere isr
, this is justQ(V,I) = d^2/2r + d
.And possibly also:
So that in the case
I
represents a plane andV
is normalized in the standard way, this reduces toQ(V,I) = d
.(Assuming I am correct in all of this, that's a very pleasant reduction (and means we can easily add such a constraint for plane-point distance in the current engine prototype.)
I note that 3a and 2b check with each other, in that when
P
has signed distance-r
from a sphere of radiusr
rep'd by I, then by the formula,Q(I_P,I) = r^2/2r - r = r/2
.If you agree with these proposed changes please either just push a commit with them or let me know that you would like me to. Then I can proceed with the review.
I've checked and incorporated the changes you suggested, so you can start reviewing again!
I just pushed a minor change to
Engine.jl
, which fixes a mistake in a comment.OK, I just made a bunch more edits to notes/inversive.md; mostly they are typographical, but there is some expanded content. I am not going to wait for your review to merge this PR, because I am pretty confident, but I would like you to read through the latest version of this file wherever it has ended up when you get a chance. Thanks.
I see you've checked in entire 3rd-party files (ganja.js). Going forward, we don't want to do that, but instead have a build process that downloads and installs 3rd party files without their needing to be in our repo. However, since the engine-proto code is destined eventually to disappear from the repo, I am not going to hold up this PR for that sake.