Comments (10)
I suspect that this existing symbolic function actually works correctly for right cylinders and also cylinders with parallel planes.
For the case of non-parallel planes, numerical integration could be a valid, if expensive, fallback method. There might also be a closed-form general solution to calculate this directly, if someone wants to work on deriving it.
from meshes.jl.
It seems very challenging indeed to get a closed-form solution to this. I think the best plan as you said is to absorb the numerical integration work after we finish the refactoring with support for CRS.
Feel free to close the PR if you feel that a simple solution doesn't exist at the moment. Thanks for the valuable investigation.
from meshes.jl.
I had an idea this morning for how to calculate this in the general (non-intersecting) case. After deriving it out ... it turns out that, so long as you can guarantee that the top and bottom disks don't intersect, the current measure calculations (e.g.
tl:dr; these current measure
functions should actually be accurate for any cylinder [surface] so long its top and bottom disks don't intersect.
from meshes.jl.
Got it. Thanks for clarifying it. Closing.
from meshes.jl.
@mikeingold your recent work on Cylinder/CylinderSurface provides a fix for this or we really need numerical integration in the oblique case?
from meshes.jl.
I had a few spare minutes this evening to think about this more. I think I was able to sketch up the math for how to compute this in the general case without integration so long as the planes donβt intersect.
from meshes.jl.
I'm going to have to re-work #806 slightly, but I think have a closed-form solution/algorithm that works in all but the intersecting-planes case (inspired by https://mathworld.wolfram.com/CylindricalSegment.html)
For V = measure(c::Cylinder)
- If
c
is a right-cylinder, then use the current solution:$V = h ~ \pi r^2$ - If
c
has intersecting planes ... throw a error indicating this case is currently unimplemented. - Otherwise
- Bisect cylinder
c
using a plane orthogonal toaxis(c)
that doesn't intersectc
'stop
orbot
planes within the cylinder radius. - Treat the two partitioned sections as new
Cylinder
s whosebot
is the bisection plane andtop
is the outer plane on that side. These two newCylinder
s are "cylindrical segments". - Find each cylindrical segment's minimum and maximum side lengths,
$h_1$ and$h_2$ , using their: radius$r$ , top center point$\bar{t}$ , normalized central axis$\hat{a}$ , and top plane's normal$\hat{n}$ . Use that information to calculate each's volume, and return the sum of the two results.
- Bisect cylinder
I would probably implement a helper function like _measure_cylindersegment(::Cylinder)
to handle the partitioned components, where a cylinder segment is assumed to have an orthogonal bottom plane. The only real edge case to this solution that I'll have to catch is if a segment's top plane is also orthogonal (a right-cylinder), in which case that segments measure reduces to simply measure(c)
. Overall, this would simplify the third case above to just: partition into cyls = Cylinder[c_1, c_2]
, and then sum(_measurecylindersegment, cyls)
.
An analogous process could then be used for A = measure(c::CylinderSurface)
.
Edit: Update below. There's a significant edge case where this third technique fails.
from meshes.jl.
This is turning out to be a surprisingly-challenging problem. The third method described above (for cylinders with non-parallel planes) should work well in most cases, but it fails if an orthogonal bisection plane can't be determined. In effect: if you imagine a plane orthogonal to axis(c)
transiting along the axis from the cylinder's bottom to top, there has to be a stopping point where the intersection of the plane and the cylinder is a circle. For many cylinders this won't be possible, especially with large radii and/or highly-slanted end planes.
I'm out of ideas for covering this non-parallel planes case at the moment. Throwing numerical integration at it, e.g. integral(p -> T(1), c)
for this specific conditional case, would definitely work but seems a little heavy-handed. We'd also either need to add MeshIntegrals.jl as a dependency or sort out it's long-term path (transition under JuliaGeometry or directly absorbed into Meshes.jl).
from meshes.jl.
That is really nice. Feel free to submit the PR with the final solution. Looking forward to reviewing it.
from meshes.jl.
I think I could have made the statement above more clear. When I said that the "current" methods actually are accurate, I was referring to the ones already present in the master
branch.
The only potential PR-able change we might consider might be to add an if/else
condition that errors on hasintersectingplanes(c)
since those results won't be accurate.
Other than that, and pending any dissent/feedback, I'd recommend closure of this Issue.
from meshes.jl.
Related Issues (20)
- IO with GeoIO.jl not working HOT 2
- Fix `convert(StructuredGrid, grid)` case HOT 2
- `Affine` does not work with `CartesianGrid` HOT 1
- Use StableRNGs.jl for creating test data. HOT 2
- Cannot construct vector with complex coordinates (StackOverflowError) HOT 6
- Stack overflow error in `intersection(Plane, CartesianGrid)` HOT 5
- Miscellaneous issues to fix after major CRS refactor HOT 4
- Update to Makie v0.21 for voxels + unit support HOT 1
- Add `refine` method based on Delaunay vertex insertion
- Methods for uconvert HOT 2
- Fix speed test on MacOS
- Add `Shadow` transform to project onto lower-dimensional spaces
- Cross-referencing `Meshes.jl` documentation HOT 4
- Add `Within` transform to retain geometries within box
- `Scale` and `LengthUnit` transforms on geometries HOT 3
- Add `discretize` method for `Cylinder`
- Specialize `center` and `centroid` for `ParaboloidSurface`
- Add `==` and `isapprox` methods for all `Geometry` subtypes
- Fix corner cases in `Shadow` and add to docs
- point in polygon errors when Point has LatLon as CRS HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meshes.jl.