JuliaGeometry / Meshes.jl

Computational geometry in Julia
https://juliageometry.github.io/MeshesDocs/stable
Other
394 stars 85 forks source link

Add more geometries #349

Closed juliohm closed 6 months ago

juliohm commented 1 year ago

Issue to track our efforts adding more primitives.

stla commented 1 year ago

How should we define the general torus? A possibility is major radius + minor radius + center + equatorial plane.

juliohm commented 1 year ago

It sounds like a good parameterization. I've seen definitions in terms of rotations, but they are too abstract for most applications. Happy to review a PR for this one too.

stla commented 1 year ago

Or maybe major radius + minor radius + center + axis of revolution (the normal to the equatorial plane). I think it's more convenient to give a vector than a plane.

juliohm commented 1 year ago

Good point. center + normal + major + minor would be a nice order of fields in the struct.

juliohm commented 1 year ago

As discussed on Zulip, it would be nice to also have a Tube primitive πŸ‘πŸ½

stla commented 1 year ago

And the Cone.

stla commented 1 year ago

For the torus passing through three given points, I have to do a function computing the circumcircle of three points in the 3D space. I'm wondering whether this function could be useful for something else. You're not interested in 3D curves?

juliohm commented 1 year ago

For the torus passing through three given points, I have to do a function computing the circumcircle of three points in the 3D space. I'm wondering whether this function could be useful for something else. You're not interested in 3D curves?

Definitely useful. We are interested in 3D curves too, and already support them btw. BezierCurve is n-dimensional in our code right? What exactly is missing? A new constructor for the Sphere?

stla commented 1 year ago

There's a 2D sphere implemented, that is a circle, but it doesn't live in the 3D space. To define a 3D circle I need its center, its radius, and the normal to the plane it belongs to.

juliohm commented 1 year ago

Our Sphere is n-dimensional. Please double check which constructor is missing and feel free to submit a PR πŸ‘πŸ½

stla commented 1 year ago

But a 3D sphere is not a 3D circle. I don't understand.

juliohm commented 1 year ago

Oh I see what you tried to say now. Our Sphere{3} is a 3D sphere embedded in 3D space. We don't have a 2D sphere embedded in 3D currently. Maybe it is time to add a Circle primitive? I wonder if we can generalize Sphere to accommodate this use case.

juliohm commented 1 year ago

I've added two new primitives to our checklist: Disk and Circle.

Our Ball and Sphere generalizations are defined in terms of a Dim-dimensional center and a radius. In this case, it is assumed that the parametric dimension is a function of the embedding dimension, namely: paramdim(Ball{Dim}) = Dim and paramdim(Sphere{Dim}) = Dim-1.

The new Disk and Circle primitives on the other hand would always be 2D and 1D primitives embedded in 3D space, defined in terms of a Plane and a radius. This gives us the flexibility to place rotated disks in a 3D scene and the ability to define Cone and ConeSurface.

juliohm commented 1 year ago

I've added Disk and Circle as described above. Now we are ready to add Cone and ConeSurface.

juliohm commented 1 year ago

I've added Cone and ConeSurface as described above. Now we are only missing Torus and Tube.

@stla please let me know when you are back online to work on the Torus PR: https://github.com/JuliaGeometry/Meshes.jl/pull/364 πŸ‘πŸ½

juliohm commented 1 year ago

@stla now the only missing primitive from our original list of primitives is the Tube. Would you like to add it?

stla commented 1 year ago

Where should I put the code for the Frenet frames? In the root file primitives.jl?

juliohm commented 1 year ago

Maybe we should add a new source file frames.jl to store this concept.

juliohm commented 1 year ago

@msfch I've added the Prism geometry to the TODO list. Feel free to start a PR :)

mfsch commented 1 year ago

PR for the Prism is at #404

mfsch commented 1 year ago

I also have added a Hyperplane type in my own code. This is different from the existing Plane type, which always has a parametric dimension of 2, and instead has a parametric dimension of Dimβˆ’1. In 3D they are the same, of course, but I still had some use for a geometry that has an internal representation of point+normal rather than point+vectors (or point+point in 2D, which is what Line uses). Maybe the Hyperplane is worth considering as well?

mfsch commented 1 year ago

The Ellipsoid is another type worth considering. As it is a pretty fundamental type when it comes to representations of the Earth, it might be useful to take some inspiration from JuliaGeo packages such as Geodesy.jl, but since those ellipsoids are symmetric around the rotational axis they can’t be used as-is. One aspect that might be interesting is Earth ellipsoids often use the inverse flattening rather as second parameter than the second half-axis to make it easier to represent near-spherical shapes with limited-precision numbers – not sure if that is applicable to the scope of Meshes.jl though.

juliohm commented 1 year ago

Thank you @mfsch, added to the list.

stla commented 1 year ago

Hello. I'm back πŸ‘

Here is some stuff to make a mesh of a closed tubular path. For example a knot:

knot1

One can choose the number of sides. Here I take 4 sides but we don't correctly see them because the mesh is smoothed:

knot2

One can also twist the tube. But again we don't see because of the smoothing.

The method is taken from this blog post.

juliohm commented 1 year ago

Welcome back @stla ! The list of missing geometries is on the top of this issue. Feel free to pick one and submit a PR. Also, regarding the smoothing option, please feel free to submit a PR to the code in ext to add options to the Makie.jl calls.

stla commented 1 year ago

Hey. I'm not familiar with Makie. I have no idea how it deals with the normals.

stla commented 1 year ago

I wanted to show you a twisted tube (two twists) with four sides and without normals, done in R with the same method:

TwistedClosedPath

This really works well. As you can see the sides are not smooth. I took 500 points. In Julia this is very fast so we can take more and the mesh would look smoother.

Ideally we should do four meshes, one for each side and add the normals to each of these meshes. In this way the sides would be smooth but flat, and the angles would remain visible.

prittjam commented 10 months ago

What is the status of the ellipse code?

juliohm commented 10 months ago

No one working on it currently.

Em sex., 8 de dez. de 2023 08:27, prittjam @.***> escreveu:

What is the status of the ellipse code?

β€” Reply to this email directly, view it on GitHub https://github.com/JuliaGeometry/Meshes.jl/issues/349#issuecomment-1847007271, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZQW3O4F2BLNR4DJOXW4STYIL2QNAVCNFSM6AAAAAATHFVT5GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBXGAYDOMRXGE . You are receiving this because you authored the thread.Message ID: @.***>

juliohm commented 6 months ago

Added Ellipsoid. Closing the issue in favor of future issues with specific geometry requests.