Skip to content
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

feat: Lagrange bases #999

Merged
merged 15 commits into from
May 21, 2022
Merged

feat: Lagrange bases #999

merged 15 commits into from
May 21, 2022

Conversation

keenancrane
Copy link
Collaborator

@keenancrane keenancrane commented May 20, 2022

Description

This PR adds a new example lagrange-bases, which is described in the README. Mostly this is just a dogfooding example; in the process of dogfooding we (re)-discovered some things like exponential cost of long selectors (which put some limitations on the sophistication of this example). It also changes the contains1D function to use a simple max on the difference of interval endpoint values, rather than ifCond on the square of the difference, which was causing the optimizer to hang on this and several other examples. Finally, this PR adds a new function interpolateQuadraticFromPoints which draws a quadratic Bézier curve that interpolates the three given points, rather than using the 2nd point as a control point.

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new ESLint warnings
  • I have reviewed any generated changes to the diagrams/ folder

@cloudflare-pages
Copy link

cloudflare-pages bot commented May 20, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: c8e06c8
Status: ✅  Deploy successful!
Preview URL: https://c84a50ef.penrose-72l.pages.dev

View logs

@keenancrane keenancrane marked this pull request as ready for review May 20, 2022 20:50
@codecov
Copy link

codecov bot commented May 20, 2022

Codecov Report

Merging #999 (c8e06c8) into main (d329dd0) will decrease coverage by 0.08%.
The diff coverage is 8.33%.

@@            Coverage Diff             @@
##             main     #999      +/-   ##
==========================================
- Coverage   63.71%   63.63%   -0.09%     
==========================================
  Files          62       62              
  Lines        7789     7801      +12     
  Branches     1782     1784       +2     
==========================================
+ Hits         4963     4964       +1     
- Misses       2714     2723       +9     
- Partials      112      114       +2     
Impacted Files Coverage Δ
packages/core/src/contrib/Functions.ts 14.25% <0.00%> (-0.18%) ⬇️
packages/core/src/contrib/Constraints.ts 82.11% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d329dd0...c8e06c8. Read the comment docs.

@keenancrane keenancrane requested a review from samestep May 20, 2022 21:52
y="408.9659586607471"
width="65.1769202023942"
width="-406.09798464016694"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange that the width became negative...


`lagrange-bases` is a stub for a package that draws meshes made of higher-order Lagrange finite elements. Currently it supports only linear triangular and quadratic elements, because quadratic quadrilateral elements, and other higher-order elements, require so many constructor arguments that we run into the [exponential scaling bug in Style selectors](https://github.com/penrose/penrose/issues/566).

The basic idea is that `Nodes` can be connected by `Elements` of any order. The rule for elements of type `QuadraticTriangle` in `lagrange-bases.sty` serves as a nice simple example of drawing quadratic Bézier curves; note that because we use the function `interpolateQuadraticFromPoints` rather than `quadraticCurveFromPoints`, these curves interpolate the three given points (rather than using the middle point as an approximated control point). There are some other cool things we could in principle do here (like automatically restricting edges that belong to multiple elements to polynomials of the lower degree), but see again the note about the bug above, which makes it hard to use long selectors.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for documenting this so well!

@keenancrane keenancrane merged commit e4d0259 into main May 21, 2022
@keenancrane keenancrane deleted the lagrange-bases branch May 21, 2022 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants