diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index dc1a86ac7..e0ba2d068 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.11.1","generation_timestamp":"2024-11-13T10:11:32","documenter_version":"1.8.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.11.1","generation_timestamp":"2024-11-14T11:53:40","documenter_version":"1.8.0"}} \ No newline at end of file diff --git a/dev/about/license/index.html b/dev/about/license/index.html index e88998692..7b4217310 100644 --- a/dev/about/license/index.html +++ b/dev/about/license/index.html @@ -22,4 +22,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +SOFTWARE. diff --git a/dev/algorithms/boundingbox/0d32f0af.png b/dev/algorithms/boundingbox/0d32f0af.png deleted file mode 100644 index d8bcef6ae..000000000 Binary files a/dev/algorithms/boundingbox/0d32f0af.png and /dev/null differ diff --git a/dev/algorithms/boundingbox/b5bf5dbc.png b/dev/algorithms/boundingbox/b5bf5dbc.png new file mode 100644 index 000000000..5b1d4d223 Binary files /dev/null and b/dev/algorithms/boundingbox/b5bf5dbc.png differ diff --git a/dev/algorithms/boundingbox/index.html b/dev/algorithms/boundingbox/index.html index ca5b5ccc7..db669d5bc 100644 --- a/dev/algorithms/boundingbox/index.html +++ b/dev/algorithms/boundingbox/index.html @@ -1,11 +1,11 @@ -Bounding box · Meshes.jl

Bounding box

pset = PointSet(rand(Point, 100, crs=Cartesian2D))
+Bounding box · Meshes.jl

Bounding box

pset = PointSet(rand(Point, 100, crs=Cartesian2D))
 bbox = boundingbox(pset)
 
 fig = Mke.Figure(size = (800, 400))
 viz(fig[1,1], bbox)
 viz!(fig[1,1], pset, color = :black)
-fig
Example block output
box  = Box((-1, -1), (0, 0))
+fig
Example block output
box  = Box((-1, -1), (0, 0))
 ball = Ball((0, 0), (1))
 gset = GeometrySet([box, ball])
 bbox = boundingbox(gset)
@@ -14,4 +14,4 @@
 viz(fig[1,1], bbox)
 viz!(fig[1,1], boundary(box), color = :gray)
 viz!(fig[1,1], boundary(ball), color = :gray)
-fig
Example block output
+fig
Example block output
diff --git a/dev/algorithms/clamping/4a826806.png b/dev/algorithms/clamping/4a826806.png new file mode 100644 index 000000000..a14da730d Binary files /dev/null and b/dev/algorithms/clamping/4a826806.png differ diff --git a/dev/algorithms/clamping/59b2b80e.png b/dev/algorithms/clamping/59b2b80e.png deleted file mode 100644 index 80a452462..000000000 Binary files a/dev/algorithms/clamping/59b2b80e.png and /dev/null differ diff --git a/dev/algorithms/clamping/index.html b/dev/algorithms/clamping/index.html index fb79a48cb..b5429d47b 100644 --- a/dev/algorithms/clamping/index.html +++ b/dev/algorithms/clamping/index.html @@ -1,5 +1,5 @@ -Clamping · Meshes.jl

Clamping

Meshes adds methods to Julia's built-in clamp function. The additional methods clamp points to the edges of a box in any number of dimensions. The target points and boxes must have the same number of dimensions and the same numeric type.

Base.clampMethod
clamp(point, box)

Clamp the coordinates of a Point to the edges of a Box.

For each dimension, coordinates outside of the box are moved to the nearest edge of the box. The point and box must have an equal number of dimensions.

source
# set of 2D points to clamp
+Clamping · Meshes.jl

Clamping

Meshes adds methods to Julia's built-in clamp function. The additional methods clamp points to the edges of a box in any number of dimensions. The target points and boxes must have the same number of dimensions and the same numeric type.

Base.clampMethod
clamp(point, box)

Clamp the coordinates of a Point to the edges of a Box.

For each dimension, coordinates outside of the box are moved to the nearest edge of the box. The point and box must have an equal number of dimensions.

source
# set of 2D points to clamp
 points = PointSet(rand(Point, 100, crs=Cartesian2D))
 
 # 2D box defining the clamping boundaries
@@ -15,4 +15,4 @@
 ax = Mke.Axis(fig[1,2], title="clamped", aspect=1, limits=(0,1,0,1))
 viz!(ax, box)
 viz!(ax, clamped, color=:black, pointsize=6)
-fig
Example block output
+fig
Example block output
diff --git a/dev/algorithms/clipping/index.html b/dev/algorithms/clipping/index.html index 925d66e9c..eb3ee25db 100644 --- a/dev/algorithms/clipping/index.html +++ b/dev/algorithms/clipping/index.html @@ -1,5 +1,5 @@ -Clipping · Meshes.jl

Clipping

Meshes.clipFunction
clip(geometry, other, method)

Clip the subject geometry with other geometry using clipping method.

source

Sutherland-Hodgman

# polygon to clip
+Clipping · Meshes.jl

Clipping

Meshes.clipFunction
clip(geometry, other, method)

Clip the subject geometry with other geometry using clipping method.

source

Sutherland-Hodgman

# polygon to clip
 outer = Ring((8, 0), (4, 8), (2, 8), (-2, 0), (0, 0), (1, 2), (5, 2), (6, 0))
 inner = Ring((4, 4), (2, 4), (3, 6))
 poly = PolyArea([outer, inner])
@@ -13,4 +13,4 @@
 viz(poly)
 viz!(other, color = :black, alpha = 0.2)
 viz!(boundary(clipped), color = :red, segmentsize = 3)
-Mke.current_figure()
Example block output
+Mke.current_figure()
Example block output
diff --git a/dev/algorithms/coarsening/index.html b/dev/algorithms/coarsening/index.html index 041e64afa..7386e2562 100644 --- a/dev/algorithms/coarsening/index.html +++ b/dev/algorithms/coarsening/index.html @@ -1,6 +1,6 @@ -Coarsening · Meshes.jl

Coarsening

RegularCoarsening

Meshes.RegularCoarseningType
RegularCoarsening(f₁, f₂, ..., fₙ)

Coarsen each dimension of the grid by given factors f₁, f₂, ..., fₙ.

Examples

coarsen(grid2D, RegularCoarsening(2, 3))
-coarsen(grid3D, RegularCoarsening(2, 3, 1))
source
grid = CartesianGrid(100, 100)
+Coarsening · Meshes.jl

Coarsening

RegularCoarsening

Meshes.RegularCoarseningType
RegularCoarsening(f₁, f₂, ..., fₙ)

Coarsen each dimension of the grid by given factors f₁, f₂, ..., fₙ.

Examples

coarsen(grid2D, RegularCoarsening(2, 3))
+coarsen(grid3D, RegularCoarsening(2, 3, 1))
source
grid = CartesianGrid(100, 100)
 
 # refine three times
 cor1 = coarsen(grid, RegularCoarsening(2, 2))
@@ -12,4 +12,4 @@
 viz(fig[1,2], cor1, showsegments = true)
 viz(fig[2,1], cor2, showsegments = true)
 viz(fig[2,2], cor3, showsegments = true)
-fig
Example block output
+fig
Example block output
diff --git a/dev/algorithms/discretization/010dfe55.png b/dev/algorithms/discretization/010dfe55.png new file mode 100644 index 000000000..b093112e9 Binary files /dev/null and b/dev/algorithms/discretization/010dfe55.png differ diff --git a/dev/algorithms/discretization/3685d118.png b/dev/algorithms/discretization/3685d118.png new file mode 100644 index 000000000..91fe27913 Binary files /dev/null and b/dev/algorithms/discretization/3685d118.png differ diff --git a/dev/algorithms/discretization/518f4c27.png b/dev/algorithms/discretization/518f4c27.png deleted file mode 100644 index 27fc40855..000000000 Binary files a/dev/algorithms/discretization/518f4c27.png and /dev/null differ diff --git a/dev/algorithms/discretization/b9f4a78c.png b/dev/algorithms/discretization/b9f4a78c.png deleted file mode 100644 index f484b22da..000000000 Binary files a/dev/algorithms/discretization/b9f4a78c.png and /dev/null differ diff --git a/dev/algorithms/discretization/index.html b/dev/algorithms/discretization/index.html index 132e7d2b4..5c7f83860 100644 --- a/dev/algorithms/discretization/index.html +++ b/dev/algorithms/discretization/index.html @@ -1,5 +1,5 @@ -Discretization · Meshes.jl

Discretization

Meshes.discretizeFunction
discretize(geometry, [method])

Discretize geometry with discretization method.

If the method is ommitted, a default algorithm is used with a specific number of elements.

source
Meshes.discretizewithinFunction
discretizewithin(boundary, method)

Discretize geometry within boundary with boundary discretization method.

source
Meshes.simplexifyFunction
simplexify(object)

Discretize object into simplices using an appropriate discretization method.

Notes

This function is sometimes called "triangulate" when the object has parametric dimension 2.

source

FanTriangulation

hexagon = Hexagon((0.,0.), (1.,0.), (1.,1.),
+Discretization · Meshes.jl

Discretization

Meshes.discretizeFunction
discretize(geometry, [method])

Discretize geometry with discretization method.

If the method is ommitted, a default algorithm is used with a specific number of elements.

source
Meshes.discretizewithinFunction
discretizewithin(boundary, method)

Discretize geometry within boundary with boundary discretization method.

source
Meshes.simplexifyFunction
simplexify(object)

Discretize object into simplices using an appropriate discretization method.

Notes

This function is sometimes called "triangulate" when the object has parametric dimension 2.

source

FanTriangulation

hexagon = Hexagon((0.,0.), (1.,0.), (1.,1.),
                   (0.75,1.5), (0.25,1.5), (0.,1.))
 
 mesh = discretize(hexagon, FanTriangulation())
@@ -7,7 +7,7 @@
 fig = Mke.Figure(size = (800, 400))
 viz(fig[1,1], hexagon)
 viz(fig[1,2], mesh, showsegments = true)
-fig
Example block output

DehnTriangulation

# polygonal area
+fig
Example block output

DehnTriangulation

# polygonal area
 polyarea = PolyArea([(0.22926679, 0.47329807), (0.23094065, 0.44913536), (0.2569517, 0.38217533),
                      (0.3072999, 0.272418), (0.34814754, 0.18421611), (0.37949452, 0.11756973),
                      (0.4013409, 0.07247882), (0.41368666, 0.048943404), (0.42597583, 0.031655528),
@@ -54,17 +54,17 @@
 fig = Mke.Figure(size = (800, 400))
 viz(fig[1,1], polyarea)
 viz(fig[1,2], mesh, showsegments = true)
-fig
Example block output

HeldTriangulation

Meshes.HeldTriangulationType
HeldTriangulation([rng]; shuffle=true)

Fast Industrial-Strength Triangulation (FIST) of polygons.

This triangulation method is the method behind the famous Mapbox's Earcut library. It is based on a ear clipping algorithm adapted for complex n-gons with holes. It has O(n²) time complexity where n is the number of vertices. In practice it is very efficient due to heuristics implemented in the algorithm.

The option shuffle is used to shuffle the order in which ears are clipped. It improves the quality of the triangles, which can be very sliver otherwise. Optionally, specify the random number generator rng.

References

source
mesh = discretize(polyarea, HeldTriangulation())
+fig
Example block output

HeldTriangulation

Meshes.HeldTriangulationType
HeldTriangulation([rng]; shuffle=true)

Fast Industrial-Strength Triangulation (FIST) of polygons.

This triangulation method is the method behind the famous Mapbox's Earcut library. It is based on a ear clipping algorithm adapted for complex n-gons with holes. It has O(n²) time complexity where n is the number of vertices. In practice it is very efficient due to heuristics implemented in the algorithm.

The option shuffle is used to shuffle the order in which ears are clipped. It improves the quality of the triangles, which can be very sliver otherwise. Optionally, specify the random number generator rng.

References

source
mesh = discretize(polyarea, HeldTriangulation())
 
 fig = Mke.Figure(size = (800, 400))
 viz(fig[1,1], polyarea)
 viz(fig[1,2], mesh, showsegments = true)
-fig
Example block output

DelaunayTriangulation

mesh = discretize(polyarea, DelaunayTriangulation())
+fig
Example block output

DelaunayTriangulation

mesh = discretize(polyarea, DelaunayTriangulation())
 
 fig = Mke.Figure(size = (800, 400))
 viz(fig[1,1], polyarea)
 viz(fig[1,2], mesh, showsegments = true)
-fig
Example block output

As can be seen in the following example, all discretization methods for Polygon automatically work in the presence of holes:

outer = [(0.18142937, 0.54681134), (0.38282228, 0.107781954), (0.43220532, 0.013640274),
+fig
Example block output

As can be seen in the following example, all discretization methods for Polygon automatically work in the presence of holes:

outer = [(0.18142937, 0.54681134), (0.38282228, 0.107781954), (0.43220532, 0.013640274),
          (0.48068276, 0.019459315), (0.48322055, 0.11583236), (0.46696007, 0.2230227),
          (0.48184678, 0.2656454), (0.45998818, 0.2784367), (0.4168235, 0.2190962),
          (0.4124987, 0.21208182), (0.39593673, 0.2520411), (0.44333926, 0.28375763),
@@ -83,12 +83,12 @@
 fig = Mke.Figure(size = (800, 400))
 viz(fig[1,1], polyarea)
 viz(fig[1,2], mesh, showsegments = true)
-fig
Example block output

RegularDiscretization

Meshes.RegularDiscretizationType
RegularDiscretization(n1, n2, ..., np)

A method to discretize primitive geometries with n1×n2×...×np elements sampled regularly along each parametric dimensions. The adequate number of points is calculated for each type of geometry and passed to RegularSampling.

source
sphere = Sphere((0.,0.,0.), 1.)
+fig
Example block output

RegularDiscretization

Meshes.RegularDiscretizationType
RegularDiscretization(n1, n2, ..., np)

A method to discretize primitive geometries with n1×n2×...×np elements sampled regularly along each parametric dimensions. The adequate number of points is calculated for each type of geometry and passed to RegularSampling.

source
sphere = Sphere((0.,0.,0.), 1.)
 
 mesh = discretize(sphere, RegularDiscretization(10,10))
 
-viz(mesh, showsegments = true)
Example block output

ManualSimplexification

box = Box((0., 0., 0.), (1., 1., 1.))
+viz(mesh, showsegments = true)
Example block output

ManualSimplexification

box = Box((0., 0., 0.), (1., 1., 1.))
 
 mesh = discretize(box, ManualSimplexification())
 
-viz(mesh, colors = 1:nelements(mesh))
Example block output
+viz(mesh, colors = 1:nelements(mesh))
Example block output
diff --git a/dev/algorithms/hulls/1920e6a0.png b/dev/algorithms/hulls/1920e6a0.png new file mode 100644 index 000000000..b057889a8 Binary files /dev/null and b/dev/algorithms/hulls/1920e6a0.png differ diff --git a/dev/algorithms/hulls/b5df703a.png b/dev/algorithms/hulls/b5df703a.png deleted file mode 100644 index c1942bd05..000000000 Binary files a/dev/algorithms/hulls/b5df703a.png and /dev/null differ diff --git a/dev/algorithms/hulls/index.html b/dev/algorithms/hulls/index.html index c4697fc52..d874b66ae 100644 --- a/dev/algorithms/hulls/index.html +++ b/dev/algorithms/hulls/index.html @@ -1,11 +1,11 @@ -Hulls · Meshes.jl

Hulls

Meshes.hullFunction
hull(points, method)

Compute the hull of points with given method.

source
pset = PointSet(rand(Point, 100, crs=Cartesian2D))
+Hulls · Meshes.jl

Hulls

Meshes.hullFunction
hull(points, method)

Compute the hull of points with given method.

source
pset = PointSet(rand(Point, 100, crs=Cartesian2D))
 chul = convexhull(pset)
 
 fig = Mke.Figure(size = (800, 400))
 viz(fig[1,1], chul)
 viz!(fig[1,1], pset, color = :black)
-fig
Example block output
box  = Box((-1, -1), (0, 0))
+fig
Example block output
box  = Box((-1, -1), (0, 0))
 ball = Ball((0, 0), (1))
 gset = GeometrySet([box, ball])
 chul = convexhull(gset)
@@ -14,4 +14,4 @@
 viz(fig[1,1], chul)
 viz!(fig[1,1], boundary(box), color = :gray)
 viz!(fig[1,1], boundary(ball), color = :gray)
-fig
Example block output
+fig
Example block output
diff --git a/dev/algorithms/intersection/index.html b/dev/algorithms/intersection/index.html index d280fdee4..06a1cb34c 100644 --- a/dev/algorithms/intersection/index.html +++ b/dev/algorithms/intersection/index.html @@ -16,10 +16,10 @@ else return 3 end -end
2
Meshes.IntersectionTypeType
IntersectionType

The different types of intersection that may occur between geometries. Type IntersectionType in a Julia session to see the full list.

source
Meshes.IntersectionType
Intersection{G}

An intersection between geometries holding a geometry of type G.

source
Meshes.intersectionFunction
intersection([f], g₁, g₂)

Compute the intersection of two geometries or domains g₁ and g₂ and apply function f to it. Default function is identity.

Examples

intersection(g₁, g₂) do I
+end
2
Meshes.IntersectionTypeType
IntersectionType

The different types of intersection that may occur between geometries. Type IntersectionType in a Julia session to see the full list.

source
Meshes.intersectionFunction
intersection([f], g₁, g₂)

Compute the intersection of two geometries or domains g₁ and g₂ and apply function f to it. Default function is identity.

Examples

intersection(g₁, g₂) do I
   if I isa CrossingLines
     # do something
   else
     # do nothing
   end
-end

Notes

When a custom function f is used that reduces the number of return types, Julia is able to optimize the branches of the code and generate specialized code. This is not the case when f === identity.

source
Base.intersectMethod
g₁ ∩ g₂

Return the intersection of two geometries or domains g₁ and g₂ as a new (multi-)geometry.

source
+end

Notes

When a custom function f is used that reduces the number of return types, Julia is able to optimize the branches of the code and generate specialized code. This is not the case when f === identity.

source
Base.intersectMethod
g₁ ∩ g₂

Return the intersection of two geometries or domains g₁ and g₂ as a new (multi-)geometry.

source
diff --git a/dev/algorithms/merging/index.html b/dev/algorithms/merging/index.html index 06085639d..f888b1aaf 100644 --- a/dev/algorithms/merging/index.html +++ b/dev/algorithms/merging/index.html @@ -1,5 +1,5 @@ -Merging · Meshes.jl

Merging

Geometries and meshes can be merged into a single geometric object as illustrated in the following example. The resulting type depends on the combination of input types, and can be a Mesh or Multi geometry.

Base.mergeMethod
merge(object₁, object₂)

Merge object₁ with object₂, i.e. concatenate the vertices and adjust the connectivities accordingly.

source
g = CartesianGrid(2, 2)
+Merging · Meshes.jl

Merging

Geometries and meshes can be merged into a single geometric object as illustrated in the following example. The resulting type depends on the combination of input types, and can be a Mesh or Multi geometry.

Base.mergeMethod
merge(object₁, object₂)

Merge object₁ with object₂, i.e. concatenate the vertices and adjust the connectivities accordingly.

source
g = CartesianGrid(2, 2)
 t = Triangle((3, 0), (4, 0), (3, 1))
 
 m = merge(g, t)
5 SimpleMesh
@@ -20,4 +20,4 @@
   ├─ Quadrangle(2, 3, 6, 5)
   ├─ Quadrangle(4, 5, 8, 7)
   ├─ Quadrangle(5, 6, 9, 8)
-  └─ Triangle(10, 11, 12)
+ └─ Triangle(10, 11, 12)
diff --git a/dev/algorithms/neighborsearch/index.html b/dev/algorithms/neighborsearch/index.html index 38e1fb293..6b6b879b7 100644 --- a/dev/algorithms/neighborsearch/index.html +++ b/dev/algorithms/neighborsearch/index.html @@ -1,6 +1,6 @@ -Neighbor search · Meshes.jl

Neighbor search

It is often useful to search neighbor elements in a domain given a point of reference. This can be performed with search methods:

Meshes.BoundedNeighborSearchMethodType
BoundedNeighborSearchMethod

A method for searching neighbors with the property that the number of neighbors is bounded above by a known constant (e.g. k-nearest neighbors).

source
Meshes.searchFunction
search(pₒ, method, mask=nothing)

Return neighbors of point pₒ using method. Optionally, specify a mask for all indices of the domain.

source
Meshes.search!Function
search!(neighbors, pₒ, method; mask=nothing)

Update neighbors of point pₒ using bounded search method and return number of neighbors found. Optionally, specify a mask for all indices of the domain.

See BoundedNeighborSearchMethod for additional details.

source
Meshes.searchdistsFunction
searchdists(pₒ, method, mask=nothing)

Return neighbors and distances of point pₒ using bounded search method. Optionally, specify a mask for all indices of the domain.

See BoundedNeighborSearchMethod for additional details.

source
Meshes.searchdists!Function
searchdists!(neighbors, distances, pₒ, method; mask=nothing)

Update neighbors and distances of point pₒ using bounded search method and return number of neighbors found. Optionally, specify a mask for all indices of the domain.

See BoundedNeighborSearchMethod for additional details.

source

Search methods are constructed with various types of parameters. One may be interested in k-nearest neighbors, or interested in neighbors within a certain Neighborhood:

Meshes.NeighborhoodType
Neighborhood

A neighborhood is a geometry that is not attached to any specific point in space, and is free to slide over a domain of interest.

source
Meshes.MetricBallType
MetricBall(radii, rotation=nothing)
-MetricBall(radius, metric=Euclidean())

A metric ball is a neighborhood that can be expressed in terms of a metric and a set of radii. The two main examples are the Euclidean ball an the Mahalanobis (ellipsoid) ball.

When multiple radii are provided, they can be rotated by a rotation specification from the Rotations.jl package. Alternatively, a metric from the Distances.jl package can be specified together with a single radius.

Examples

N-dimensional Euclidean ball with radius 1.0:

julia> euclidean = MetricBall(1.0)

Axis-aligned 3D ellipsoid with radii (3.0, 2.0, 1.0):

julia> mahalanobis = MetricBall((3.0, 2.0, 1.0))
source

The following example demonstrates neighbor search with the KNearestSearch method:

grid = CartesianGrid(10, 10)
+Neighbor search · Meshes.jl

Neighbor search

It is often useful to search neighbor elements in a domain given a point of reference. This can be performed with search methods:

Meshes.BoundedNeighborSearchMethodType
BoundedNeighborSearchMethod

A method for searching neighbors with the property that the number of neighbors is bounded above by a known constant (e.g. k-nearest neighbors).

source
Meshes.searchFunction
search(pₒ, method, mask=nothing)

Return neighbors of point pₒ using method. Optionally, specify a mask for all indices of the domain.

source
Meshes.search!Function
search!(neighbors, pₒ, method; mask=nothing)

Update neighbors of point pₒ using bounded search method and return number of neighbors found. Optionally, specify a mask for all indices of the domain.

See BoundedNeighborSearchMethod for additional details.

source
Meshes.searchdistsFunction
searchdists(pₒ, method, mask=nothing)

Return neighbors and distances of point pₒ using bounded search method. Optionally, specify a mask for all indices of the domain.

See BoundedNeighborSearchMethod for additional details.

source
Meshes.searchdists!Function
searchdists!(neighbors, distances, pₒ, method; mask=nothing)

Update neighbors and distances of point pₒ using bounded search method and return number of neighbors found. Optionally, specify a mask for all indices of the domain.

See BoundedNeighborSearchMethod for additional details.

source

Search methods are constructed with various types of parameters. One may be interested in k-nearest neighbors, or interested in neighbors within a certain Neighborhood:

Meshes.NeighborhoodType
Neighborhood

A neighborhood is a geometry that is not attached to any specific point in space, and is free to slide over a domain of interest.

source
Meshes.MetricBallType
MetricBall(radii, rotation=nothing)
+MetricBall(radius, metric=Euclidean())

A metric ball is a neighborhood that can be expressed in terms of a metric and a set of radii. The two main examples are the Euclidean ball an the Mahalanobis (ellipsoid) ball.

When multiple radii are provided, they can be rotated by a rotation specification from the Rotations.jl package. Alternatively, a metric from the Distances.jl package can be specified together with a single radius.

Examples

N-dimensional Euclidean ball with radius 1.0:

julia> euclidean = MetricBall(1.0)

Axis-aligned 3D ellipsoid with radii (3.0, 2.0, 1.0):

julia> mahalanobis = MetricBall((3.0, 2.0, 1.0))
source

The following example demonstrates neighbor search with the KNearestSearch method:

grid = CartesianGrid(10, 10)
 
 # 4-nearest neighbors
 searcher = KNearestSearch(grid, 4)
@@ -19,4 +19,4 @@
  0.7071067811865476 m
  0.7071067811865476 m
  0.7071067811865476 m
- 0.7071067811865476 m

Finally, the functions search! and searchdists! can be used in hot loops to avoid unnecessary memory allocations.

BallSearch

KNearestSearch

Meshes.KNearestSearchType
KNearestSearch(domain, k; metric=Euclidean())

A method for searching k nearest neighbors in domain according to metric.

source

KBallSearch

Meshes.KBallSearchType
KBallSearch(domain, k, ball)

A method that searches k nearest neighbors and then filters these neighbors using a metric ball.

See MetricBall for additional details.

source
+ 0.7071067811865476 m

Finally, the functions search! and searchdists! can be used in hot loops to avoid unnecessary memory allocations.

BallSearch

KNearestSearch

Meshes.KNearestSearchType
KNearestSearch(domain, k; metric=Euclidean())

A method for searching k nearest neighbors in domain according to metric.

source

KBallSearch

Meshes.KBallSearchType
KBallSearch(domain, k, ball)

A method that searches k nearest neighbors and then filters these neighbors using a metric ball.

See MetricBall for additional details.

source
diff --git a/dev/algorithms/orientation/index.html b/dev/algorithms/orientation/index.html index 732b9d1e6..d281380f8 100644 --- a/dev/algorithms/orientation/index.html +++ b/dev/algorithms/orientation/index.html @@ -1,5 +1,5 @@ -Orientation · Meshes.jl

Orientation

Many geometric processing algorithms for 2D geometries rely on the concept of orientation, which is illustrated below.

Meshes.orientationFunction
orientation(geom)

Returns the orientation of the geometry geom as either counter-clockwise (CCW) or clockwise (CW).

source

For polygons without holes, the function returns the orientation of the boundary, which is a Ring:

tri = Triangle((0, 0), (1, 0), (0, 1))
+Orientation · Meshes.jl

Orientation

Many geometric processing algorithms for 2D geometries rely on the concept of orientation, which is illustrated below.

Meshes.orientationFunction
orientation(geom)

Returns the orientation of the geometry geom as either counter-clockwise (CCW) or clockwise (CW).

source

For polygons without holes, the function returns the orientation of the boundary, which is a Ring:

tri = Triangle((0, 0), (1, 0), (0, 1))
 
 orientation(tri)
CCW::OrientationType = 1
tri = Triangle((0, 0), (0, 1), (1, 0))
 
@@ -11,4 +11,4 @@
 orientation(poly)
3-element Vector{OrientationType}:
  CCW::OrientationType = 1
  CW::OrientationType = 0
- CW::OrientationType = 0
+ CW::OrientationType = 0
diff --git a/dev/algorithms/partitioning/index.html b/dev/algorithms/partitioning/index.html index e8b24dd17..6a92cdcc7 100644 --- a/dev/algorithms/partitioning/index.html +++ b/dev/algorithms/partitioning/index.html @@ -1,2 +1,2 @@ -Partition · Meshes.jl

Partition

Meshes.partitionFunction
partition([rng], object, method)

Partition object with partition method. Optionally, specify random number generator rng.

source

Uniform

Meshes.UniformPartitionType
UniformPartition(k, [shuffle])

A method for partitioning spatial objects uniformly into k subsets of approximately equal size. Optionally shuffle the data (default to true).

source

Fraction

Meshes.FractionPartitionType
FractionPartition(fraction, shuffle=true)

A method for partitioning spatial objects according to a given fraction. Optionally shuffle elements before partitioning.

source

Block

Meshes.BlockPartitionType
BlockPartition(sides; neighbors=false)

A method for partitioning spatial objects into blocks of given sides. Optionally, compute the neighbors of a block as the metadata.

BlockPartition(side₁, side₂, ..., sideₙ; neighbors=false)

Alternatively, specify the sides side₁, side₂, ..., sideₙ.

source

Bisect-Point

Meshes.BisectPointPartitionType
BisectPointPartition(normal, point)

A method for partitioning spatial objects into two half spaces defined by a normal direction and a reference point.

source

Bisect-Fraction

Meshes.BisectFractionPartitionType
BisectFractionPartition(normal, fraction=0.5, maxiter=10)

A method for partitioning spatial objects into two half spaces defined by a normal direction and a fraction of points. The partition is returned within maxiter bisection iterations.

source

Ball

Meshes.BallPartitionType
BallPartition(radius; metric=Euclidean())

A method for partitioning spatial objects into balls of a given radius using a metric.

source

Plane

Meshes.PlanePartitionType
PlanePartition(normal; [tol])

A method for partitioning spatial objects into a family of hyperplanes defined by a normal direction. Two points x and y belong to the same hyperplane when (x - y) ⋅ normal < tol.

source

Direction

Meshes.DirectionPartitionType
DirectionPartition(direction; [tol])

A method for partitioning spatial objects along a given direction with bandwidth tolerance tol.

source

Predicate

Meshes.PredicatePartitionType
PredicatePartition(predicate)

A method for partitioning spatial objects with a given predicate function. Two locations i and j are part of the same subset whenever predicate(i, j) == true

source

SpatialPredicate

Meshes.SpatialPredicatePartitionType
SpatialPredicatePartition(predicate)

A method for partitioning spatial objects with a given spatial predicate function. Two coordinates x and y are part of the same subset whenever predicate(x, y) == true.

source

Product

Meshes.ProductPartitionType
ProductPartition(p₁, p₂)

A method for partitioning spatial objects using the product of two partitioning methods p₁ and p₂.

source

Hierarchical

Meshes.HierarchicalPartitionType
HierarchicalPartition(first, second)

A partitioning method in which a first partition is applied and then a second partition is applied to each subset of the first.

source
+Partition · Meshes.jl

Partition

Meshes.partitionFunction
partition([rng], object, method)

Partition object with partition method. Optionally, specify random number generator rng.

source

Uniform

Meshes.UniformPartitionType
UniformPartition(k, [shuffle])

A method for partitioning spatial objects uniformly into k subsets of approximately equal size. Optionally shuffle the data (default to true).

source

Fraction

Meshes.FractionPartitionType
FractionPartition(fraction, shuffle=true)

A method for partitioning spatial objects according to a given fraction. Optionally shuffle elements before partitioning.

source

Block

Meshes.BlockPartitionType
BlockPartition(sides; neighbors=false)

A method for partitioning spatial objects into blocks of given sides. Optionally, compute the neighbors of a block as the metadata.

BlockPartition(side₁, side₂, ..., sideₙ; neighbors=false)

Alternatively, specify the sides side₁, side₂, ..., sideₙ.

source

Bisect-Point

Meshes.BisectPointPartitionType
BisectPointPartition(normal, point)

A method for partitioning spatial objects into two half spaces defined by a normal direction and a reference point.

source

Bisect-Fraction

Meshes.BisectFractionPartitionType
BisectFractionPartition(normal, fraction=0.5, maxiter=10)

A method for partitioning spatial objects into two half spaces defined by a normal direction and a fraction of points. The partition is returned within maxiter bisection iterations.

source

Ball

Meshes.BallPartitionType
BallPartition(radius; metric=Euclidean())

A method for partitioning spatial objects into balls of a given radius using a metric.

source

Plane

Meshes.PlanePartitionType
PlanePartition(normal; [tol])

A method for partitioning spatial objects into a family of hyperplanes defined by a normal direction. Two points x and y belong to the same hyperplane when (x - y) ⋅ normal < tol.

source

Direction

Meshes.DirectionPartitionType
DirectionPartition(direction; [tol])

A method for partitioning spatial objects along a given direction with bandwidth tolerance tol.

source

Predicate

Meshes.PredicatePartitionType
PredicatePartition(predicate)

A method for partitioning spatial objects with a given predicate function. Two locations i and j are part of the same subset whenever predicate(i, j) == true

source

SpatialPredicate

Meshes.SpatialPredicatePartitionType
SpatialPredicatePartition(predicate)

A method for partitioning spatial objects with a given spatial predicate function. Two coordinates x and y are part of the same subset whenever predicate(x, y) == true.

source

Product

Meshes.ProductPartitionType
ProductPartition(p₁, p₂)

A method for partitioning spatial objects using the product of two partitioning methods p₁ and p₂.

source

Hierarchical

Meshes.HierarchicalPartitionType
HierarchicalPartition(first, second)

A partitioning method in which a first partition is applied and then a second partition is applied to each subset of the first.

source
diff --git a/dev/algorithms/refinement/index.html b/dev/algorithms/refinement/index.html index 99d0e5a9a..0d676155d 100644 --- a/dev/algorithms/refinement/index.html +++ b/dev/algorithms/refinement/index.html @@ -1,5 +1,5 @@ -Refinement · Meshes.jl

Refinement

TriRefinement

Meshes.TriRefinementType
TriRefinement([pred])

Refinement of polygonal meshes into triangles. A n-gon for which the predicate pred holds true is subdivided into n triangles. The method refines all n-gons if the pred is ommited.

source
grid = CartesianGrid(10, 10)
+Refinement · Meshes.jl

Refinement

TriRefinement

Meshes.TriRefinementType
TriRefinement([pred])

Refinement of polygonal meshes into triangles. A n-gon for which the predicate pred holds true is subdivided into n triangles. The method refines all n-gons if the pred is ommited.

source
grid = CartesianGrid(10, 10)
 
 # refine three times
 ref1 = refine(grid, TriRefinement())
@@ -11,7 +11,7 @@
 viz(fig[1,2], ref1, showsegments = true)
 viz(fig[2,1], ref2, showsegments = true)
 viz(fig[2,2], ref3, showsegments = true)
-fig
Example block output

QuadRefinement

Meshes.QuadRefinementType
QuadRefinement()

Refinement of polygonal meshes into quadrangles. A n-gon is subdivided into n quadrangles.

source
grid = CartesianGrid(10, 10)
+fig
Example block output

QuadRefinement

Meshes.QuadRefinementType
QuadRefinement()

Refinement of polygonal meshes into quadrangles. A n-gon is subdivided into n quadrangles.

source
grid = CartesianGrid(10, 10)
 
 # refine three times
 ref1 = refine(grid, QuadRefinement())
@@ -24,7 +24,7 @@
 viz(fig[2,1], ref2, showsegments = true)
 viz(fig[2,2], ref3, showsegments = true)
 fig
Example block output

RegularRefinement

Meshes.RegularRefinementType
RegularRefinement(f₁, f₂, ..., fₙ)

Refine each dimension of the grid by given factors f₁, f₂, ..., fₙ.

Examples

refine(grid2D, RegularRefinement(2, 3))
-refine(grid3D, RegularRefinement(2, 3, 1))
source
grid = CartesianGrid(10, 10)
+refine(grid3D, RegularRefinement(2, 3, 1))
source
grid = CartesianGrid(10, 10)
 
 # refine three times
 ref1 = refine(grid, RegularRefinement(2, 2))
@@ -36,7 +36,7 @@
 viz(fig[1,2], ref1, showsegments = true)
 viz(fig[2,1], ref2, showsegments = true)
 viz(fig[2,2], ref3, showsegments = true)
-fig
Example block output

Catmull-Clark

# define a cube in R^3
+fig
Example block output

Catmull-Clark

# define a cube in R^3
 points = [(0,0,0),(1,0,0),(1,1,0),(0,1,0),(0,0,1),(1,0,1),(1,1,1),(0,1,1)]
 connec = connect.([(1,4,3,2),(5,6,7,8),(1,2,6,5),(3,4,8,7),(1,5,8,4),(2,3,7,6)])
 mesh   = SimpleMesh(points, connec)
@@ -51,7 +51,7 @@
 viz(fig[1,2], ref1, showsegments = true)
 viz(fig[2,1], ref2, showsegments = true)
 viz(fig[2,2], ref3, showsegments = true)
-fig
Example block output

TriSubdivision

grid = CartesianGrid(10, 10)
+fig
Example block output

TriSubdivision

grid = CartesianGrid(10, 10)
 
 # refine three times
 ref1 = refine(grid, TriSubdivision())
@@ -63,4 +63,4 @@
 viz(fig[1,2], ref1, showsegments = true)
 viz(fig[2,1], ref2, showsegments = true)
 viz(fig[2,2], ref3, showsegments = true)
-fig
Example block output
+figExample block output diff --git a/dev/algorithms/sampling/06db547d.png b/dev/algorithms/sampling/06db547d.png new file mode 100644 index 000000000..c521d18a0 Binary files /dev/null and b/dev/algorithms/sampling/06db547d.png differ diff --git a/dev/algorithms/sampling/0c93a575.png b/dev/algorithms/sampling/0c93a575.png new file mode 100644 index 000000000..e3aac5620 Binary files /dev/null and b/dev/algorithms/sampling/0c93a575.png differ diff --git a/dev/algorithms/sampling/37397e9e.png b/dev/algorithms/sampling/37397e9e.png new file mode 100644 index 000000000..524332d1d Binary files /dev/null and b/dev/algorithms/sampling/37397e9e.png differ diff --git a/dev/algorithms/sampling/3cac76c9.png b/dev/algorithms/sampling/3cac76c9.png deleted file mode 100644 index 48236f6d6..000000000 Binary files a/dev/algorithms/sampling/3cac76c9.png and /dev/null differ diff --git a/dev/algorithms/sampling/3f121eb9.png b/dev/algorithms/sampling/3f121eb9.png new file mode 100644 index 000000000..dff01cbb0 Binary files /dev/null and b/dev/algorithms/sampling/3f121eb9.png differ diff --git a/dev/algorithms/sampling/846751af.png b/dev/algorithms/sampling/846751af.png new file mode 100644 index 000000000..8306df3c6 Binary files /dev/null and b/dev/algorithms/sampling/846751af.png differ diff --git a/dev/algorithms/sampling/d4141f9f.png b/dev/algorithms/sampling/d4141f9f.png deleted file mode 100644 index 3b1b0107b..000000000 Binary files a/dev/algorithms/sampling/d4141f9f.png and /dev/null differ diff --git a/dev/algorithms/sampling/d99075b9.png b/dev/algorithms/sampling/d99075b9.png deleted file mode 100644 index bbe21867c..000000000 Binary files a/dev/algorithms/sampling/d99075b9.png and /dev/null differ diff --git a/dev/algorithms/sampling/da44b202.png b/dev/algorithms/sampling/da44b202.png deleted file mode 100644 index 5edc56717..000000000 Binary files a/dev/algorithms/sampling/da44b202.png and /dev/null differ diff --git a/dev/algorithms/sampling/e604abc7.png b/dev/algorithms/sampling/e604abc7.png deleted file mode 100644 index 8bda05f75..000000000 Binary files a/dev/algorithms/sampling/e604abc7.png and /dev/null differ diff --git a/dev/algorithms/sampling/index.html b/dev/algorithms/sampling/index.html index 80699849f..8be00381f 100644 --- a/dev/algorithms/sampling/index.html +++ b/dev/algorithms/sampling/index.html @@ -1,11 +1,11 @@ -Sampling · Meshes.jl

Sampling

StatsBase.sampleMethod
sample([rng], object, method)

Sample elements or points from geometric object with method. Optionally, specify random number generator rng.

source
Meshes.DiscreteSamplingMethodType
DiscreteSamplingMethod

A method for sampling from discrete representations of geometric objects such as meshes or collections of geometries.

source
Meshes.ContinuousSamplingMethodType
ContinuousSamplingMethod

A method for sampling from continuous representations of geometric objects. In this case, geometric objects are interpreted as a set of points in the embedding space.

source

Discrete sampling

UniformSampling

Meshes.UniformSamplingType
UniformSampling(size, replace=false, ordered=false)

Sample elements uniformly from a given domain/data. Produce a sample of given size with or without replacement depending on the replace option. The option ordered can be used to return samples in the same order of the domain/data.

source
grid = CartesianGrid(20, 20)
+Sampling · Meshes.jl

Sampling

StatsBase.sampleMethod
sample([rng], object, method)

Sample elements or points from geometric object with method. Optionally, specify random number generator rng.

source
Meshes.DiscreteSamplingMethodType
DiscreteSamplingMethod

A method for sampling from discrete representations of geometric objects such as meshes or collections of geometries.

source
Meshes.ContinuousSamplingMethodType
ContinuousSamplingMethod

A method for sampling from continuous representations of geometric objects. In this case, geometric objects are interpreted as a set of points in the embedding space.

source

Discrete sampling

UniformSampling

Meshes.UniformSamplingType
UniformSampling(size, replace=false, ordered=false)

Sample elements uniformly from a given domain/data. Produce a sample of given size with or without replacement depending on the replace option. The option ordered can be used to return samples in the same order of the domain/data.

source
grid = CartesianGrid(20, 20)
 
 # uniform sampling without replacement
 sampler = UniformSampling(100, replace=false)
 blocks  = sample(grid, sampler)
 
-viz(blocks)
Example block output

WeightedSampling

Meshes.WeightedSamplingType
WeightedSampling(size, [weights]; replace=false, ordered=false)

Sample elements from a given domain/data using weights. Produce a sample of given size with or without replacement depending on the replace option. The option ordered can be used to return samples in the same order of the original domain/data. By default weights are uniform.

source
grid = CartesianGrid(20, 20)
+viz(blocks)
Example block output

WeightedSampling

Meshes.WeightedSamplingType
WeightedSampling(size, [weights]; replace=false, ordered=false)

Sample elements from a given domain/data using weights. Produce a sample of given size with or without replacement depending on the replace option. The option ordered can be used to return samples in the same order of the original domain/data. By default weights are uniform.

source
grid = CartesianGrid(20, 20)
 
 # upper blocks are 10x more likely
 weights = [fill(1, 200); fill(10, 200)]
@@ -14,34 +14,34 @@
 sampler = WeightedSampling(100, weights, replace=false)
 blocks  = sample(grid, sampler)
 
-viz(blocks)
Example block output

BallSampling

Meshes.BallSamplingType
BallSampling(radius; [options])

A method for sampling isolated elements from a given domain/data according to a norm-ball of given radius.

Options

  • metric - Metric for the ball (default to Euclidean())
  • maxsize - Maximum size of the resulting sample (default to none)
source
grid = CartesianGrid(20, 20)
+viz(blocks)
Example block output

BallSampling

Meshes.BallSamplingType
BallSampling(radius; [options])

A method for sampling isolated elements from a given domain/data according to a norm-ball of given radius.

Options

  • metric - Metric for the ball (default to Euclidean())
  • maxsize - Maximum size of the resulting sample (default to none)
source
grid = CartesianGrid(20, 20)
 
 # sample blocks that are apart by a given radius
 sampler = BallSampling(5.0)
 blocks  = sample(grid, sampler)
 
-viz(blocks)
Example block output

Continuous sampling

RegularSampling

Meshes.RegularSamplingType
RegularSampling(n1, n2, ..., np)

Generate samples regularly using n1 points along the first parametric dimension, n2 points along the second parametric dimension, ..., np points along the last parametric dimension.

Examples

Sample sphere regularly with 360 longitudes and 180 latitudes:

sample(Sphere((0,0,0), 1), RegularSampling(360, 180))
source
grid = CartesianGrid(20, 20)
+viz(blocks)
Example block output

Continuous sampling

RegularSampling

Meshes.RegularSamplingType
RegularSampling(n1, n2, ..., np)

Generate samples regularly using n1 points along the first parametric dimension, n2 points along the second parametric dimension, ..., np points along the last parametric dimension.

Examples

Sample sphere regularly with 360 longitudes and 180 latitudes:

sample(Sphere((0,0,0), 1), RegularSampling(360, 180))
source
grid = CartesianGrid(20, 20)
 
 # sample points regularly
 sampler = RegularSampling(20, 30)
 points  = sample(grid, sampler) |> collect
 
-viz(points)
Example block output

HomogeneousSampling

Meshes.HomogeneousSamplingType
HomogeneousSampling(size, [weights])

Generate sample of given size from geometric object according to a homogeneous density. Optionally, provide weights to specify custom sampling weights for the elements of a domain.

source
grid = CartesianGrid(20, 20)
+viz(points)
Example block output

HomogeneousSampling

Meshes.HomogeneousSamplingType
HomogeneousSampling(size, [weights])

Generate sample of given size from geometric object according to a homogeneous density. Optionally, provide weights to specify custom sampling weights for the elements of a domain.

source
grid = CartesianGrid(20, 20)
 
 # sample points homogeneously
 sampler = HomogeneousSampling(100)
 points  = sample(grid, sampler) |> collect
 
-viz(points)
Example block output

MinDistanceSampling

Meshes.MinDistanceSamplingType
MinDistanceSampling(α, ρ=0.65, δ=100, metric=Euclidean())

Generate sample from geometric object such that all pairs of points are at least α units of distance away from each other. Optionally specify the relative radius ρ for the packing pattern, the oversampling factor δ and the metric.

This method is sometimes referred to as Poisson disk sampling or blue noise sampling in the computer graphics community.

References

source
grid = CartesianGrid(20, 20)
+viz(points)
Example block output

MinDistanceSampling

Meshes.MinDistanceSamplingType
MinDistanceSampling(α, ρ=0.65, δ=100, metric=Euclidean())

Generate sample from geometric object such that all pairs of points are at least α units of distance away from each other. Optionally specify the relative radius ρ for the packing pattern, the oversampling factor δ and the metric.

This method is sometimes referred to as Poisson disk sampling or blue noise sampling in the computer graphics community.

References

source
grid = CartesianGrid(20, 20)
 
 # sample points that are apart by a given radius
 sampler = MinDistanceSampling(3.0)
 points  = sample(grid, sampler) |> collect
 
-viz(points)
Example block output

FibonacciSampling

sphere = Sphere((0.,0.,0.), 1.)
+viz(points)
Example block output

FibonacciSampling

sphere = Sphere((0.,0.,0.), 1.)
 
 # sample points using the Fibonacci lattice method
 sampler  = FibonacciSampling(100)
 points  = sample(sphere, sampler) |> collect
 
-viz(points)
Example block output
+viz(points)
Example block output
diff --git a/dev/algorithms/sideof/index.html b/dev/algorithms/sideof/index.html index 03cda2974..9cf9f0c0e 100644 --- a/dev/algorithms/sideof/index.html +++ b/dev/algorithms/sideof/index.html @@ -1,8 +1,8 @@ -Sideof · Meshes.jl

Sideof

The sideof function can be used to efficiently query the side of multiple points with respect to a given geometry or mesh.

Meshes.SideTypeType
IntersectionType

The different types of sides that a point may lie in relation to a boundary geometry or mesh. Type SideType in a Julia session to see the full list.

source
Meshes.sideofMethod
sideof(point, line)

Determines on which side the point is in relation to the line. Possible results are LEFT, RIGHT or ON the line.

Notes

  • Assumes the orientation of Segment(line(0), line(1)).
source
Meshes.sideofMethod
sideof(point, mesh)

Determines on which side the point is in relation to the surface mesh. Possible results are IN or OUT the mesh.

source
sideof(Point(0, 0), Line((1, 0), (1, 1)))
LEFT::SideType = 3
points = [Point(0, 0), Point(0.2, 0.2), Point(2, 1)]
+Sideof · Meshes.jl

Sideof

The sideof function can be used to efficiently query the side of multiple points with respect to a given geometry or mesh.

Meshes.SideTypeType
IntersectionType

The different types of sides that a point may lie in relation to a boundary geometry or mesh. Type SideType in a Julia session to see the full list.

source
Meshes.sideofMethod
sideof(point, line)

Determines on which side the point is in relation to the line. Possible results are LEFT, RIGHT or ON the line.

Notes

  • Assumes the orientation of Segment(line(0), line(1)).
source
Meshes.sideofMethod
sideof(point, mesh)

Determines on which side the point is in relation to the surface mesh. Possible results are IN or OUT the mesh.

source
sideof(Point(0, 0), Line((1, 0), (1, 1)))
LEFT::SideType = 3
points = [Point(0, 0), Point(0.2, 0.2), Point(2, 1)]
 polygon = Triangle((0, 0), (1, 0), (0, 1))
 
 sideof(points, boundary(polygon))
3-element Vector{SideType}:
  ON::SideType = 2
  IN::SideType = 0
- OUT::SideType = 1
+ OUT::SideType = 1
diff --git a/dev/algorithms/simplification/index.html b/dev/algorithms/simplification/index.html index f85ddd333..e13a02486 100644 --- a/dev/algorithms/simplification/index.html +++ b/dev/algorithms/simplification/index.html @@ -1,5 +1,5 @@ -Simplification · Meshes.jl

Simplification

SelingerSimplification

poly = PolyArea([(0.22926679, 0.47329807), (0.23094065, 0.44913536), (0.2569517, 0.38217533),
+Simplification · Meshes.jl

Simplification

SelingerSimplification

poly = PolyArea([(0.22926679, 0.47329807), (0.23094065, 0.44913536), (0.2569517, 0.38217533),
                  (0.3072999, 0.272418), (0.34814754, 0.18421611), (0.37949452, 0.11756973),
                  (0.4013409, 0.07247882), (0.41368666, 0.048943404), (0.42597583, 0.031655528),
                  (0.4382084, 0.0206152), (0.45038435, 0.015822414), (0.4625037, 0.017277176),
@@ -49,7 +49,7 @@
 viz(fig[1,2], simp1)
 viz(fig[2,1], simp2)
 viz(fig[2,2], simp3)
-fig
Example block output

DouglasPeuckerSimplification

simp1 = simplify(poly, DouglasPeuckerSimplification(0.01))
+fig
Example block output

DouglasPeuckerSimplification

simp1 = simplify(poly, DouglasPeuckerSimplification(0.01))
 simp2 = simplify(poly, DouglasPeuckerSimplification(0.05))
 simp3 = simplify(poly, DouglasPeuckerSimplification(0.10))
 
@@ -58,7 +58,7 @@
 viz(fig[1,2], simp1)
 viz(fig[2,1], simp2)
 viz(fig[2,2], simp3)
-fig
Example block output

MinMaxSimplification

Meshes.MinMaxSimplificationType
MinMaxSimplification(method; min=3, max=typemax(Int), maxiter=10)

Simplify geometries with binary search algorithm and a parent simplification method.

The simplification is performed until the number of vertices is in the [min, max] range or until a maximum number of iterations maxiter is reached.

source
simp1 = simplify(poly, MinMaxSimplification(DouglasPeuckerSimplification, max=20))
+fig
Example block output

MinMaxSimplification

Meshes.MinMaxSimplificationType
MinMaxSimplification(method; min=3, max=typemax(Int), maxiter=10)

Simplify geometries with binary search algorithm and a parent simplification method.

The simplification is performed until the number of vertices is in the [min, max] range or until a maximum number of iterations maxiter is reached.

source
simp1 = simplify(poly, MinMaxSimplification(DouglasPeuckerSimplification, max=20))
 simp2 = simplify(poly, MinMaxSimplification(DouglasPeuckerSimplification, max=10))
 simp3 = simplify(poly, MinMaxSimplification(DouglasPeuckerSimplification, max=5))
 
@@ -67,4 +67,4 @@
 viz(fig[1,2], simp1)
 viz(fig[2,1], simp2)
 viz(fig[2,2], simp3)
-fig
Example block output
+fig
Example block output
diff --git a/dev/algorithms/tesselation/001c1a6a.png b/dev/algorithms/tesselation/001c1a6a.png deleted file mode 100644 index 885458fc2..000000000 Binary files a/dev/algorithms/tesselation/001c1a6a.png and /dev/null differ diff --git a/dev/algorithms/tesselation/265bf715.png b/dev/algorithms/tesselation/265bf715.png new file mode 100644 index 000000000..5d30d2c0a Binary files /dev/null and b/dev/algorithms/tesselation/265bf715.png differ diff --git a/dev/algorithms/tesselation/7a0b0783.png b/dev/algorithms/tesselation/7a0b0783.png deleted file mode 100644 index e4f7913a3..000000000 Binary files a/dev/algorithms/tesselation/7a0b0783.png and /dev/null differ diff --git a/dev/algorithms/tesselation/e451a3f2.png b/dev/algorithms/tesselation/e451a3f2.png new file mode 100644 index 000000000..47c5a37cf Binary files /dev/null and b/dev/algorithms/tesselation/e451a3f2.png differ diff --git a/dev/algorithms/tesselation/index.html b/dev/algorithms/tesselation/index.html index 2844384b9..84920ca89 100644 --- a/dev/algorithms/tesselation/index.html +++ b/dev/algorithms/tesselation/index.html @@ -1,14 +1,14 @@ -Tesselation · Meshes.jl

Tesselation

Meshes.tesselateFunction
tesselate(pointset, [method])

Tesselate pointset with tesselation method.

If the method is ommitted, a default algorithm is used.

source

DelaunayTesselation

points = rand(Point, 100, crs=Cartesian2D)
+Tesselation · Meshes.jl

Tesselation

Meshes.tesselateFunction
tesselate(pointset, [method])

Tesselate pointset with tesselation method.

If the method is ommitted, a default algorithm is used.

source

DelaunayTesselation

points = rand(Point, 100, crs=Cartesian2D)
 
 mesh = tesselate(points, DelaunayTesselation())
 
 viz(mesh, showsegments = true)
 viz!(points, color = :red)
-Mke.current_figure()
Example block output

VoronoiTesselation

points = rand(Point, 100, crs=Cartesian2D)
+Mke.current_figure()
Example block output

VoronoiTesselation

points = rand(Point, 100, crs=Cartesian2D)
 
 mesh = tesselate(points, VoronoiTesselation())
 
 viz(mesh, showsegments = true)
 viz!(points, color = :red)
-Mke.current_figure()
Example block output
+Mke.current_figure()
Example block output
diff --git a/dev/algorithms/winding/index.html b/dev/algorithms/winding/index.html index 7ceffe801..6772015b2 100644 --- a/dev/algorithms/winding/index.html +++ b/dev/algorithms/winding/index.html @@ -1,8 +1,8 @@ -Winding · Meshes.jl

Winding

The winding number is intimately connected to the sideof function, which is used more often in applications.

points = [Point(0, 0), Point(0.2, 0.2), Point(2, 1)]
+Winding · Meshes.jl

Winding

The winding number is intimately connected to the sideof function, which is used more often in applications.

points = [Point(0, 0), Point(0.2, 0.2), Point(2, 1)]
 polygon = Triangle((0, 0), (1, 0), (0, 1))
 
 winding(points, boundary(polygon))
3-element Vector{Float64}:
  0.25
  1.0
- 0.0
+ 0.0
diff --git a/dev/contributing/guidelines/index.html b/dev/contributing/guidelines/index.html index 6c7e52494..e5c4efe4d 100644 --- a/dev/contributing/guidelines/index.html +++ b/dev/contributing/guidelines/index.html @@ -1,3 +1,3 @@ Guidelines · Meshes.jl

Guidelines

First off, thank you for considering contributing to Meshes.jl. Below are a few suggestions to speed up the collaboration process:

  • Please be polite, we are here to help and learn from each other.
  • Try to explain your contribution with simple language.
  • References to textbooks and papers are always welcome.
  • Follow the coding standards in the source.

Reporting issues

If you are experiencing issues or have discovered a bug, please report it on GitHub. To make the resolution process easier, please include the version of Julia and Meshes.jl in your writeup. These can be found with two commands:

julia> versioninfo()
-julia> using Pkg; Pkg.status()

Feature requests

If you have suggestions of improvement or algorithms that you would like to see implemented in Meshes.jl, please open an issue on GitHub. Suggestions as well as feature requests are very welcome.

Code contribution

If you have code that you would like to contribute to Meshes.jl, that is awesome! Please open an issue before you create the pull request on GitHub so that we make sure your idea is aligned with our goals for the project.

After your idea is discussed and revised by maintainers, please get the development version of the project by typing the following in the package manager:

] activate @dev

This will create a fresh environment called @dev where you can play with the project components without compromising your normal user environment.

] dev Meshes

This will clone all the project components in your ~/.julia folder so that you can modify it and submit a pull request on GitHub later. Don't hesitate to ask questions. We are looking forward to your contributions.

+julia> using Pkg; Pkg.status()

Feature requests

If you have suggestions of improvement or algorithms that you would like to see implemented in Meshes.jl, please open an issue on GitHub. Suggestions as well as feature requests are very welcome.

Code contribution

If you have code that you would like to contribute to Meshes.jl, that is awesome! Please open an issue before you create the pull request on GitHub so that we make sure your idea is aligned with our goals for the project.

After your idea is discussed and revised by maintainers, please get the development version of the project by typing the following in the package manager:

] activate @dev

This will create a fresh environment called @dev where you can play with the project components without compromising your normal user environment.

] dev Meshes

This will clone all the project components in your ~/.julia folder so that you can modify it and submit a pull request on GitHub later. Don't hesitate to ask questions. We are looking forward to your contributions.

diff --git a/dev/domains/meshes/index.html b/dev/domains/meshes/index.html index 9b03db946..511317797 100644 --- a/dev/domains/meshes/index.html +++ b/dev/domains/meshes/index.html @@ -1,18 +1,18 @@ -Meshes · Meshes.jl

Meshes

Meshes can be constructed directly (e.g. CartesianGrid) or based on other constructs such as connectivity lists and topological structures (e.g. SimpleMesh).

Overview

Meshes.MeshType
Mesh{M,CRS,TP}

A mesh of geometries in a given manifold M with point coordinates specified in a coordinate reference system CRS. Unlike a general domain, a mesh has a well-defined topology TP.

source
Meshes.GridType
Grid{M,CRS,Dim}

A grid of geometries in a given manifold M with points coordinates specified in a coordinate reference system CRS, which is embedded in Dim dimensions.

source
Meshes.RegularGridType
RegularGrid(dims, origin, spacing)

A regular grid with dimensions dims, lower left corner at origin and cell spacing spacing. The three arguments must have the same length.

RegularGrid(dims, origin, spacing, offset)

A regular grid with dimensions dims, with lower left corner of element offset at origin and cell spacing spacing.

RegularGrid(start, finish, dims=dims)

Alternatively, construct a regular grid from a start point to a finish with dimensions dims.

RegularGrid(start, finish, spacing)

Alternatively, construct a regular grid from a start point to a finish point using a given spacing.

Examples

RegularGrid((10, 20), Point(LatLon(30.0°, 60.0°)), (1.0, 1.0)) # add coordinate units to spacing
+Meshes · Meshes.jl

Meshes

Meshes can be constructed directly (e.g. CartesianGrid) or based on other constructs such as connectivity lists and topological structures (e.g. SimpleMesh).

Overview

Meshes.MeshType
Mesh{M,CRS,TP}

A mesh of geometries in a given manifold M with point coordinates specified in a coordinate reference system CRS. Unlike a general domain, a mesh has a well-defined topology TP.

source
Meshes.GridType
Grid{M,CRS,Dim}

A grid of geometries in a given manifold M with points coordinates specified in a coordinate reference system CRS, which is embedded in Dim dimensions.

source
Meshes.RegularGridType
RegularGrid(dims, origin, spacing)

A regular grid with dimensions dims, lower left corner at origin and cell spacing spacing. The three arguments must have the same length.

RegularGrid(dims, origin, spacing, offset)

A regular grid with dimensions dims, with lower left corner of element offset at origin and cell spacing spacing.

RegularGrid(start, finish, dims=dims)

Alternatively, construct a regular grid from a start point to a finish with dimensions dims.

RegularGrid(start, finish, spacing)

Alternatively, construct a regular grid from a start point to a finish point using a given spacing.

Examples

RegularGrid((10, 20), Point(LatLon(30.0°, 60.0°)), (1.0, 1.0)) # add coordinate units to spacing
 RegularGrid((10, 20), Point(Polar(0.0cm, 0.0rad)), (10.0mm, 1.0rad)) # convert spacing units to coordinate units
 RegularGrid((10, 20), Point(Mercator(0.0, 0.0)), (1.5, 1.5))
-RegularGrid((10, 20, 30), Point(Cylindrical(0.0, 0.0, 0.0)), (3.0, 2.0, 1.0))

See also CartesianGrid.

source
# 2D regular grid
+RegularGrid((10, 20, 30), Point(Cylindrical(0.0, 0.0, 0.0)), (3.0, 2.0, 1.0))

See also CartesianGrid.

source
# 2D regular grid
 grid = RegularGrid((8, 8), Point(Polar(0, 0)), (1, π/4))
 
 viz(grid, showsegments = true)
Example block output
Meshes.CartesianGridType
CartesianGrid(dims, origin, spacing)

A Cartesian grid with dimensions dims, lower left corner at origin and cell spacing spacing. The three arguments must have the same length.

CartesianGrid(dims, origin, spacing, offset)

A Cartesian grid with dimensions dims, with lower left corner of element offset at origin and cell spacing spacing.

CartesianGrid(start, finish, dims=dims)

Alternatively, construct a Cartesian grid from a start point (lower left) to a finish point (upper right).

CartesianGrid(start, finish, spacing)

Alternatively, construct a Cartesian grid from a start point to a finish point using a given spacing.

CartesianGrid(dims)
-CartesianGrid(dim1, dim2, ...)

Finally, a Cartesian grid can be constructed by only passing the dimensions dims as a tuple, or by passing each dimension dim1, dim2, ... separately. In this case, the origin and spacing default to (0,0,...) and (1,1,...).

CartesianGrid is an alias to RegularGrid with Cartesian CRS.

Examples

Create a 3D grid with 100x100x50 hexahedrons:

julia> CartesianGrid(100, 100, 50)

Create a 2D grid with 100 x 100 quadrangles and origin at (10.0, 20.0):

julia> CartesianGrid((100, 100), (10.0, 20.0), (1.0, 1.0))

Create a 1D grid from -1 to 1 with 100 segments:

julia> CartesianGrid((-1.0,), (1.0,), dims=(100,))

See also RegularGrid.

source
# 3D Cartesian grid
+CartesianGrid(dim1, dim2, ...)

Finally, a Cartesian grid can be constructed by only passing the dimensions dims as a tuple, or by passing each dimension dim1, dim2, ... separately. In this case, the origin and spacing default to (0,0,...) and (1,1,...).

CartesianGrid is an alias to RegularGrid with Cartesian CRS.

Examples

Create a 3D grid with 100x100x50 hexahedrons:

julia> CartesianGrid(100, 100, 50)

Create a 2D grid with 100 x 100 quadrangles and origin at (10.0, 20.0):

julia> CartesianGrid((100, 100), (10.0, 20.0), (1.0, 1.0))

Create a 1D grid from -1 to 1 with 100 segments:

julia> CartesianGrid((-1.0,), (1.0,), dims=(100,))

See also RegularGrid.

source
# 3D Cartesian grid
 grid = CartesianGrid(10, 10, 10)
 
 viz(grid, showsegments = true)
Example block output
Meshes.RectilinearGridType
RectilinearGrid(x, y, z, ...)
 RectilinearGrid{M,C}(x, y, z, ...)

A rectilinear grid with vertices at sorted coordinates x, y, z, ..., manifold M (default to 𝔼) and CRS type C (default to Cartesian).

Examples

Create a 2D rectilinear grid with regular spacing in x dimension and irregular spacing in y dimension:

julia> x = 0.0:0.2:1.0
 julia> y = [0.0, 0.1, 0.3, 0.7, 0.9, 1.0]
-julia> RectilinearGrid(x, y)
source
# 2D rectilinear grid
+julia> RectilinearGrid(x, y)
source
# 2D rectilinear grid
 x = 0.0:0.2:1.0
 y = [0.0, 0.1, 0.3, 0.7, 0.9, 1.0]
 grid = RectilinearGrid(x, y)
@@ -20,14 +20,14 @@
 viz(grid, showsegments = true)
Example block output
Meshes.StructuredGridType
StructuredGrid(X, Y, Z, ...)
 StructuredGrid{M,C}(X, Y, Z, ...)

A structured grid with vertices at sorted coordinates X, Y, Z, ..., manifold M (default to 𝔼) and CRS type C (default to Cartesian).

Examples

Create a 2D structured grid with regular spacing in x dimension and irregular spacing in y dimension:

julia> X = repeat(0.0:0.2:1.0, 1, 6)
 julia> Y = repeat([0.0, 0.1, 0.3, 0.7, 0.9, 1.0]', 6, 1)
-julia> StructuredGrid(X, Y)
source
# 2D structured grid
+julia> StructuredGrid(X, Y)
source
# 2D structured grid
 X = [i/20 * cos(3π/2 * (j-1) / (30-1)) for i in 1:20, j in 1:30]
 Y = [i/20 * sin(3π/2 * (j-1) / (30-1)) for i in 1:20, j in 1:30]
 grid = StructuredGrid(X, Y)
 
 viz(grid, showsegments = true)
Example block output
Meshes.SimpleMeshType
SimpleMesh(vertices, topology)

A simple mesh with vertices and topology.

SimpleMesh(vertices, connectivities; relations=false)

Alternatively, construct a simple mesh with vertices and connectivities. The option relations can be used to build topological relations assuming that the connectivities represent the elements of the mesh.

Examples

julia> points = [(0.0, 0.0),(1.0, 0.0), (1.0, 1.0)]
 julia> connec = [connect((1,2,3))]
-julia> mesh   = SimpleMesh(points, connec)

See also Topology, GridTopology, HalfEdgeTopology, SimpleTopology.

Notes

source
# global vector of 2D points
+julia> mesh   = SimpleMesh(points, connec)

See also Topology, GridTopology, HalfEdgeTopology, SimpleTopology.

Notes

source
# global vector of 2D points
 points = [(0,0),(1,0),(0,1),(1,1),(0.25,0.5),(0.75,0.5)]
 
 # connect the points into N-gon
@@ -36,17 +36,17 @@
 # 2D mesh made of N-gon elements
 mesh = SimpleMesh(points, connec)
 
-viz(mesh, showsegments = true)
Example block output

Connectivities

Meshes.ConnectivityType
Connectivity{PL,N}

A connectivity list of N indices representing a Polytope of type PL. Indices are taken from a global vector of Point.

Connectivity objects are constructed with the connect function.

source
Meshes.connectFunction
connect(indices, [PL])

Connect a list of indices from a global vector of Point into a Polytope of type PL.

The type PL can be a Ngon in which case the length of the indices is used to identify the actual polytope type.

Finally, the type PL can be ommitted. In this case, the indices are assumed to be connected as a Ngon or as a Segment.

Examples

Connect indices into a Triangle:

connect((1,2,3), Triangle)

Connect indices into N-gons, a Triangle and a Quadrangle:

connect.([(1,2,3), (2,3,4,5)], Ngon)

Connect indices into N-gon or segment:

connect((1,2)) # Segment
+viz(mesh, showsegments = true)
Example block output

Connectivities

Meshes.ConnectivityType
Connectivity{PL,N}

A connectivity list of N indices representing a Polytope of type PL. Indices are taken from a global vector of Point.

Connectivity objects are constructed with the connect function.

source
Meshes.connectFunction
connect(indices, [PL])

Connect a list of indices from a global vector of Point into a Polytope of type PL.

The type PL can be a Ngon in which case the length of the indices is used to identify the actual polytope type.

Finally, the type PL can be ommitted. In this case, the indices are assumed to be connected as a Ngon or as a Segment.

Examples

Connect indices into a Triangle:

connect((1,2,3), Triangle)

Connect indices into N-gons, a Triangle and a Quadrangle:

connect.([(1,2,3), (2,3,4,5)], Ngon)

Connect indices into N-gon or segment:

connect((1,2)) # Segment
 connect((1,2,3)) # Triangle
-connect((1,2,3,4)) # Quadrangle
source
Meshes.materializeFunction
materialize(connec, points)

Materialize a face using the connec list and a global vector of points.

source

Topology

Meshes.GridTopologyType
GridTopology(dims, [periodic])

A data structure for grid topologies with dims elements. Optionally, specify which dimensions are periodic. Default to aperiodic dimensions.

Examples

julia> GridTopology((10,20)) # 10x20 elements in a grid
-julia> GridTopology((10,20), (true,false)) # cylinder topology
source
Meshes.materializeFunction
materialize(connec, points)

Materialize a face using the connec list and a global vector of points.

source

Topology

Meshes.GridTopologyType
GridTopology(dims, [periodic])

A data structure for grid topologies with dims elements. Optionally, specify which dimensions are periodic. Default to aperiodic dimensions.

Examples

julia> GridTopology((10,20)) # 10x20 elements in a grid
+julia> GridTopology((10,20), (true,false)) # cylinder topology
source
Meshes.HalfEdgeTopologyType
HalfEdgeTopology(elements; sort=true)
 HalfEdgeTopology(halfedges)

A data structure for orientable 2-manifolds based on half-edges constructed from a vector of connectivity elements or from a vector of pairs of halfedges.

The option sort can be used to sort the elements in adjacent-first order in case of inconsistent orientation (i.e. mix of clockwise and counter-clockwise).

Examples

Construct half-edge topology from a list of top-faces:

elements = connect.([(1,2,3),(3,2,4,5)])
-topology = HalfEdgeTopology(elements)

See also Topology.

References

Notes

  • Two types of half-edges exist (Kettner 1999). This implementation is the most common type that splits the incident elements.

  • A vector of halfedges together with a dictionary of half4elem and a dictionary of half4vert can be used to retrieve topolological relations in optimal time. In this case, half4vert[i] returns the index of the half-edge in halfedges with head equal to i. Similarly, half4elem[i] returns the index of a half-edge in halfedges that is in the element i. Additionally, a dictionary edge4pair returns the index of the edge (i.e. two halves) for a given pair of vertices.

  • If the elements of the mesh already have consistent orientation, then the sort option can be disabled for maximum performance.

source
Meshes.SimpleTopologyType
SimpleTopology(connectivities)

A data structure that stores all connectivities of a mesh.

Notes

This data structure is sometimes referred to as the "soup of geometries". It does not support topological relations and is therefore incompatible with algorithms that rely on neighborhood search. It is still useful for mesh visualization and IO operations.

source

Relations

Meshes.TopologicalRelationType
TopologicalRelation

A topological relation between faces of a Mesh implemented for a given Topology.

An object implementing this trait is a functor that can be evaluated at an integer index representing the face.

Examples

# create boundary relation mapping
+topology = HalfEdgeTopology(elements)

See also Topology.

References

Notes

  • Two types of half-edges exist (Kettner 1999). This implementation is the most common type that splits the incident elements.

  • A vector of halfedges together with a dictionary of half4elem and a dictionary of half4vert can be used to retrieve topolological relations in optimal time. In this case, half4vert[i] returns the index of the half-edge in halfedges with head equal to i. Similarly, half4elem[i] returns the index of a half-edge in halfedges that is in the element i. Additionally, a dictionary edge4pair returns the index of the edge (i.e. two halves) for a given pair of vertices.

  • If the elements of the mesh already have consistent orientation, then the sort option can be disabled for maximum performance.

source
Meshes.SimpleTopologyType
SimpleTopology(connectivities)

A data structure that stores all connectivities of a mesh.

Notes

This data structure is sometimes referred to as the "soup of geometries". It does not support topological relations and is therefore incompatible with algorithms that rely on neighborhood search. It is still useful for mesh visualization and IO operations.

source

Relations

Meshes.TopologicalRelationType
TopologicalRelation

A topological relation between faces of a Mesh implemented for a given Topology.

An object implementing this trait is a functor that can be evaluated at an integer index representing the face.

Examples

# create boundary relation mapping
 # 2-faces to 0-faces (i.e. vertices)
 ∂ = Boundary{2,0}(topology)
 
 # list of vertices for first face
-∂(1)

References

source
Meshes.BoundaryType
Boundary{P,Q}(topology)

The boundary relation from rank P to smaller rank Q for a given topology.

source
Meshes.CoboundaryType
Coboundary{P,Q}(topology)

The co-boundary relation from rank P to greater rank Q for a given topology.

source

Consider the following examples with the Boundary and Coboundary relations defined for the HalfEdgeTopology:

# global vector of 2D points
+∂(1)

References

source
Meshes.BoundaryType
Boundary{P,Q}(topology)

The boundary relation from rank P to smaller rank Q for a given topology.

source
Meshes.CoboundaryType
Coboundary{P,Q}(topology)

The co-boundary relation from rank P to greater rank Q for a given topology.

source
Meshes.AdjacencyType
Adjacency{P}(topology)

The adjacency relation of rank P for a given topology.

source

Consider the following examples with the Boundary and Coboundary relations defined for the HalfEdgeTopology:

# global vector of 2D points
 points = [(0,0),(1,0),(0,1),(1,1),(0.25,0.5),(0.75,0.5)]
 
 # connect the points into N-gon
@@ -76,7 +76,7 @@
 𝒞₁₂ = Coboundary{1,2}(topo)
 
 # show n-gons that share edge 3
-𝒞₁₂(3)
(2, 1)

Matrices

Based on topological relations, we can extract matrices that are widely used in applications such as laplacematrix, and adjacencymatrix.

Laplace

Meshes.laplacematrixFunction
laplacematrix(mesh; kind=nothing)

The Laplace-Beltrami (a.k.a. Laplacian) matrix of the mesh. Optionally, specify the kind of discretization.

Available discretizations

  • :uniform - Lᵢⱼ = 1 / |𝒜(i)|, ∀j ∈ 𝒜(i)
  • :cotangent - Lᵢⱼ = cot(αᵢⱼ) + cot(βᵢⱼ), ∀j ∈ 𝒜(i)

where 𝒜(i) is the adjacency relation at vertex i.

References

source
grid = CartesianGrid(10, 10)
+𝒞₁₂(3)
(2, 1)

Matrices

Based on topological relations, we can extract matrices that are widely used in applications such as laplacematrix, and adjacencymatrix.

Laplace

Meshes.laplacematrixFunction
laplacematrix(mesh; kind=nothing)

The Laplace-Beltrami (a.k.a. Laplacian) matrix of the mesh. Optionally, specify the kind of discretization.

Available discretizations

  • :uniform - Lᵢⱼ = 1 / |𝒜(i)|, ∀j ∈ 𝒜(i)
  • :cotangent - Lᵢⱼ = cot(αᵢⱼ) + cot(βᵢⱼ), ∀j ∈ 𝒜(i)

where 𝒜(i) is the adjacency relation at vertex i.

References

source
grid = CartesianGrid(10, 10)
 
 laplacematrix(grid, kind = :uniform)
121×121 SparseArrays.SparseMatrixCSC{Float64, Int64} with 561 stored entries:
 ⎡⠻⣦⡀⠈⠲⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⎤
@@ -107,7 +107,7 @@
  -1.0  -0.0    ⋅   -1.0   2.0
  -1.0    ⋅   -0.0  -1.0   2.0
    ⋅   -1.0  -1.0  -0.0   2.0
-  2.0   2.0   2.0   2.0  -8.0

Measure

Meshes.measurematrixFunction
measurematrix(mesh)

The measure (or "mass") matrix of the mesh, i.e. a diagonal matrix with entries Mᵢᵢ = 2Aᵢ where Aᵢ is (one-third of) the sum of the areas of triangles sharing vertex i.

The discrete cotangent Laplace-Beltrami operator can be written as Δ = M⁻¹L. When solving systems of the form Δu = f, it is useful to write Lu = Mf and exploit the symmetry of L.

source
grid = CartesianGrid(10, 10)
+  2.0   2.0   2.0   2.0  -8.0

Measure

Meshes.measurematrixFunction
measurematrix(mesh)

The measure (or "mass") matrix of the mesh, i.e. a diagonal matrix with entries Mᵢᵢ = 2Aᵢ where Aᵢ is (one-third of) the sum of the areas of triangles sharing vertex i.

The discrete cotangent Laplace-Beltrami operator can be written as Δ = M⁻¹L. When solving systems of the form Δu = f, it is useful to write Lu = Mf and exploit the symmetry of L.

source
grid = CartesianGrid(10, 10)
 
 measurematrix(grid)
121×121 LinearAlgebra.Diagonal{Unitful.Quantity{Float64, 𝐋^2, Unitful.FreeUnits{(m^2,), 𝐋^2, nothing}}, Vector{Unitful.Quantity{Float64, 𝐋^2, Unitful.FreeUnits{(m^2,), 𝐋^2, nothing}}}}:
  0.666667 m^2         ⋅            ⋅     …         ⋅             ⋅   
@@ -138,7 +138,7 @@
          ⋅     0.333333 m^2          ⋅             ⋅             ⋅   
          ⋅             ⋅     0.333333 m^2          ⋅             ⋅   
          ⋅             ⋅             ⋅     0.333333 m^2          ⋅   
-         ⋅             ⋅             ⋅             ⋅     0.666667 m^2

Adjacency

Meshes.adjacencymatrixFunction
adjacencymatrix(mesh; rank=paramdim(mesh))

The adjacency matrix of the mesh using the adjacency relation of given rank for the underlying topology.

source
grid = CartesianGrid(10, 10)
+         ⋅             ⋅             ⋅             ⋅     0.666667 m^2

Adjacency

Meshes.adjacencymatrixFunction
adjacencymatrix(mesh; rank=paramdim(mesh))

The adjacency matrix of the mesh using the adjacency relation of given rank for the underlying topology.

source
grid = CartesianGrid(10, 10)
 
 adjacencymatrix(grid)
100×100 SparseArrays.SparseMatrixCSC{Int64, Int64} with 360 stored entries:
 ⎡⠪⡦⡀⠀⠑⢄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⎤
@@ -180,4 +180,4 @@
 ⎢⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠢⡀⠈⠪⡦⡀⠈⠢⡄⠀⠀⎥
 ⎢⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠢⡀⠈⠫⡦⡀⠈⠣⡄⎥
 ⎢⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠦⡀⠈⠪⡦⡀⠈⎥
-⎣⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠦⡀⠈⠫⡦⎦
+⎣⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠦⡀⠈⠫⡦⎦
diff --git a/dev/domains/sets/748afd49.png b/dev/domains/sets/748afd49.png new file mode 100644 index 000000000..c3513ab5d Binary files /dev/null and b/dev/domains/sets/748afd49.png differ diff --git a/dev/domains/sets/b82e58e3.png b/dev/domains/sets/b82e58e3.png deleted file mode 100644 index c6a19b2ff..000000000 Binary files a/dev/domains/sets/b82e58e3.png and /dev/null differ diff --git a/dev/domains/sets/d014f487.png b/dev/domains/sets/d014f487.png new file mode 100644 index 000000000..2a52bea18 Binary files /dev/null and b/dev/domains/sets/d014f487.png differ diff --git a/dev/domains/sets/fcbc582a.png b/dev/domains/sets/fcbc582a.png deleted file mode 100644 index 530587c46..000000000 Binary files a/dev/domains/sets/fcbc582a.png and /dev/null differ diff --git a/dev/domains/sets/index.html b/dev/domains/sets/index.html index ba3ae3840..0c45adf5e 100644 --- a/dev/domains/sets/index.html +++ b/dev/domains/sets/index.html @@ -1,5 +1,5 @@ -Sets · Meshes.jl

Sets

Geometry sets represent a collection of geometries without any connectivity information (a.k.a., "soup of geometries").

Meshes.GeometrySetType
GeometrySet(geometries)

A set of geometries representing a Domain.

Examples

Set containing two balls centered at (0.0, 0.0) and (1.0, 1.0):

julia> GeometrySet([Ball((0.0, 0.0)), Ball((1.0, 1.0))])

Notes

  • Geometries with different CRS will be projected to the CRS of the first geometry.
source
GeometrySet(rand(Ball, 3)) |> viz
Example block output
Meshes.PointSetType
PointSet(points)

A set of points (a.k.a. point cloud) representing a Domain.

Examples

All point sets below are the same and contain two points in R³:

julia> PointSet([Point(1,2,3), Point(4,5,6)])
+Sets · Meshes.jl

Sets

Geometry sets represent a collection of geometries without any connectivity information (a.k.a., "soup of geometries").

Meshes.GeometrySetType
GeometrySet(geometries)

A set of geometries representing a Domain.

Examples

Set containing two balls centered at (0.0, 0.0) and (1.0, 1.0):

julia> GeometrySet([Ball((0.0, 0.0)), Ball((1.0, 1.0))])

Notes

  • Geometries with different CRS will be projected to the CRS of the first geometry.
source
GeometrySet(rand(Ball, 3)) |> viz
Example block output
Meshes.PointSetType
PointSet(points)

A set of points (a.k.a. point cloud) representing a Domain.

Examples

All point sets below are the same and contain two points in R³:

julia> PointSet([Point(1,2,3), Point(4,5,6)])
 julia> PointSet(Point(1,2,3), Point(4,5,6))
 julia> PointSet([(1,2,3), (4,5,6)])
-julia> PointSet((1,2,3), (4,5,6))
source
PointSet(rand(Point, 100, crs=Cartesian2D)) |> viz
Example block output
+julia> PointSet((1,2,3), (4,5,6))
source
PointSet(rand(Point, 100, crs=Cartesian2D)) |> viz
Example block output
diff --git a/dev/domains/trajectories/index.html b/dev/domains/trajectories/index.html index 08771e112..191e2bec7 100644 --- a/dev/domains/trajectories/index.html +++ b/dev/domains/trajectories/index.html @@ -1,7 +1,7 @@ -Trajectories · Meshes.jl

Trajectories

Trajectories of geometries are special geometry sets with one-dimensional grid topology. They are often used in geosciences to represent drill holes, wells, etc.

# construct centroids along Bezier curve
+Trajectories · Meshes.jl

Trajectories

Trajectories of geometries are special geometry sets with one-dimensional grid topology. They are often used in geosciences to represent drill holes, wells, etc.

# construct centroids along Bezier curve
 b = BezierCurve([(0, 0, 0), (3, 3, 0), (3, 0, 7)])
 c = [b(t) for t in range(0, stop=1, length=20)]
 
 # cylindrical trajectory with radius 2
-CylindricalTrajectory(c, 2) |> viz
Example block output
+CylindricalTrajectory(c, 2) |> viz
Example block output
diff --git a/dev/geometries/polytopes/index.html b/dev/geometries/polytopes/index.html index 876dc33cd..dbb12d603 100644 --- a/dev/geometries/polytopes/index.html +++ b/dev/geometries/polytopes/index.html @@ -1,6 +1,6 @@ -Polytopes · Meshes.jl

Polytopes

Abstract

Meshes.PolytopeType
Polytope{K,M,CRS}

We say that a geometry is a K-polytope when it is a collection of "flat" sides that constitute a K-dimensional subspace. They are called chain, polygon and polyhedron respectively for 1D (K=1), 2D (K=2) and 3D (K=3) subspaces. The parameter K is also known as the rank or parametric dimension of the polytope (https://en.wikipedia.org/wiki/Abstract_polytope).

The term polytope expresses a particular combinatorial structure. A polyhedron, for example, can be decomposed into faces. Each face can then be decomposed into edges, and edges into vertices. Some conventions act as a mapping between vertices and higher dimensional features (edges, faces, cells...), removing the need to store all features.

Additionally, the following property must hold in order for a geometry to be considered a polytope: the boundary of a (K+1)-polytope is a collection of K-polytopes, which may have (K-1)-polytopes in common. See https://en.wikipedia.org/wiki/Polytope.

Notes

  • Type aliases are Chain, Polygon, Polyhedron.
source

Concrete

Segment

Meshes.SegmentType
Segment(p1, p2)

An oriented line segment with end points p1, p2. The segment can be called as s(t) with t between 0 and 1 to interpolate linearly between its endpoints.

See also Rope, Ring, Line.

source
Segment((0., 0.), (1.,1.)) |> viz
Example block output

Rope

Meshes.RopeType
Rope(p1, p2, ..., pn)

An open polygonal chain from a sequence of points p1, p2, ..., pn.

See also Chain and Ring.

source
Rope((0.,0.), (1.,0.5), (1.,1.), (2.,0.)) |> viz
Example block output

Ring

Meshes.RingType
Ring(p1, p2, ..., pn)

A closed polygonal chain from a sequence of points p1, p2, ..., pn.

See also Chain and Rope.

source
Ring((0.,0.), (1.,0.5), (1.,1.), (2.,0.)) |> viz
Example block output

Ngon

Meshes.NgonType
Ngon(p₁, p₂, ..., pₙ)

A N-gon is a polygon with N ≥ 3 vertices p₁, p₂, ..., pₙ oriented counter-clockwise (CCW). In this case the number of vertices is fixed and known at compile time. Examples of N-gon are Triangle (N=3), Quadrangle (N=4), Pentagon (N=5), etc.

Notes

  • Although the number of vertices N is known at compile time, we use abstract vectors to store the list of vertices. This design allows constructing N-gon from views of global vectors without expensive memory allocations.

  • Type aliases are Triangle, Quadrangle, Pentagon, Hexagon, Heptagon, Octagon, Nonagon, Decagon.

source
Triangle((0.,0.), (1.,0.), (0.,1.)) |> viz
Example block output

PolyArea

Meshes.PolyAreaType
PolyArea(outer)
-PolyArea([outer, inner₁, inner₂, ..., innerₖ])

A polygonal area with outer ring, and optional inner rings inner₁, inner₂, ..., innerₖ.

Rings can be a vector of Point or a vector of tuples with coordinates for convenience, in which case the first point should not be repeated at the end of the vector.

source
outer = [(0, 0), (1, 0), (1, 1), (0, 1)]
+Polytopes · Meshes.jl

Polytopes

Abstract

Meshes.PolytopeType
Polytope{K,M,CRS}

We say that a geometry is a K-polytope when it is a collection of "flat" sides that constitute a K-dimensional subspace. They are called chain, polygon and polyhedron respectively for 1D (K=1), 2D (K=2) and 3D (K=3) subspaces. The parameter K is also known as the rank or parametric dimension of the polytope (https://en.wikipedia.org/wiki/Abstract_polytope).

The term polytope expresses a particular combinatorial structure. A polyhedron, for example, can be decomposed into faces. Each face can then be decomposed into edges, and edges into vertices. Some conventions act as a mapping between vertices and higher dimensional features (edges, faces, cells...), removing the need to store all features.

Additionally, the following property must hold in order for a geometry to be considered a polytope: the boundary of a (K+1)-polytope is a collection of K-polytopes, which may have (K-1)-polytopes in common. See https://en.wikipedia.org/wiki/Polytope.

Notes

  • Type aliases are Chain, Polygon, Polyhedron.
source

Concrete

Segment

Meshes.SegmentType
Segment(p1, p2)

An oriented line segment with end points p1, p2. The segment can be called as s(t) with t between 0 and 1 to interpolate linearly between its endpoints.

See also Rope, Ring, Line.

source
Segment((0., 0.), (1.,1.)) |> viz
Example block output

Rope

Meshes.RopeType
Rope(p1, p2, ..., pn)

An open polygonal chain from a sequence of points p1, p2, ..., pn.

See also Chain and Ring.

source
Rope((0.,0.), (1.,0.5), (1.,1.), (2.,0.)) |> viz
Example block output

Ring

Meshes.RingType
Ring(p1, p2, ..., pn)

A closed polygonal chain from a sequence of points p1, p2, ..., pn.

See also Chain and Rope.

source
Ring((0.,0.), (1.,0.5), (1.,1.), (2.,0.)) |> viz
Example block output

Ngon

Meshes.NgonType
Ngon(p₁, p₂, ..., pₙ)

A N-gon is a polygon with N ≥ 3 vertices p₁, p₂, ..., pₙ oriented counter-clockwise (CCW). In this case the number of vertices is fixed and known at compile time. Examples of N-gon are Triangle (N=3), Quadrangle (N=4), Pentagon (N=5), etc.

Notes

  • Although the number of vertices N is known at compile time, we use abstract vectors to store the list of vertices. This design allows constructing N-gon from views of global vectors without expensive memory allocations.

  • Type aliases are Triangle, Quadrangle, Pentagon, Hexagon, Heptagon, Octagon, Nonagon, Decagon.

source
Triangle((0.,0.), (1.,0.), (0.,1.)) |> viz
Example block output

PolyArea

Meshes.PolyAreaType
PolyArea(outer)
+PolyArea([outer, inner₁, inner₂, ..., innerₖ])

A polygonal area with outer ring, and optional inner rings inner₁, inner₂, ..., innerₖ.

Rings can be a vector of Point or a vector of tuples with coordinates for convenience, in which case the first point should not be repeated at the end of the vector.

source
outer = [(0, 0), (1, 0), (1, 1), (0, 1)]
 hole1 = [(0.2, 0.2), (0.2, 0.4), (0.4, 0.4), (0.4, 0.2)]
 hole2 = [(0.6, 0.2), (0.6, 0.4), (0.8, 0.4), (0.8, 0.2)]
-poly  = PolyArea([outer, hole1, hole2]) |> viz
Example block output

Tetrahedron

Tetrahedron((0,0,0),(1,0,0),(0,1,0),(0,0,1)) |> viz
Example block output

Hexahedron

Hexahedron((0,0,0),(1,0,0),(1,1,0),(0,1,0),(0,0,1),(1,0,1),(1,1,1),(0,1,1)) |> viz
Example block output

Pyramid

Pyramid((0,0,0),(1,0,0),(1,1,0),(0,1,0),(0,0,1)) |> viz
Example block output
+poly = PolyArea([outer, hole1, hole2]) |> viz
Example block output

Tetrahedron

Tetrahedron((0,0,0),(1,0,0),(0,1,0),(0,0,1)) |> viz
Example block output

Hexahedron

Hexahedron((0,0,0),(1,0,0),(1,1,0),(0,1,0),(0,0,1),(1,0,1),(1,1,1),(0,1,1)) |> viz
Example block output

Pyramid

Pyramid((0,0,0),(1,0,0),(1,1,0),(0,1,0),(0,0,1)) |> viz
Example block output
diff --git a/dev/geometries/primitives/391a4130.png b/dev/geometries/primitives/391a4130.png new file mode 100644 index 000000000..6006b32da Binary files /dev/null and b/dev/geometries/primitives/391a4130.png differ diff --git a/dev/geometries/primitives/67142837.png b/dev/geometries/primitives/67142837.png deleted file mode 100644 index 5f8563fbc..000000000 Binary files a/dev/geometries/primitives/67142837.png and /dev/null differ diff --git a/dev/geometries/primitives/index.html b/dev/geometries/primitives/index.html index 162f0f0b4..8d0491206 100644 --- a/dev/geometries/primitives/index.html +++ b/dev/geometries/primitives/index.html @@ -1,5 +1,5 @@ -Primitives · Meshes.jl

Primitives

Abstract

Concrete

Point

Meshes.PointType
Point(x₁, x₂, ..., xₙ)
+Primitives · Meshes.jl

Primitives

Abstract

Concrete

Point

Meshes.PointType
Point(x₁, x₂, ..., xₙ)
 Point((x₁, x₂, ..., xₙ))

A point in Dim-dimensional space with coordinates in length units (default to meters).

The coordinates of the point are given with respect to the canonical Euclidean basis, and integer coordinates are converted to float.

Examples

# 2D points
 Point(1.0, 2.0) # add default units
 Point(1.0m, 2.0m) # double precision as expected
@@ -10,9 +10,9 @@
 Point(1.0, 2.0, 3.0) # add default units
 Point(1.0m, 2.0m, 3.0m) # double precision as expected
 Point(1f0km, 2f0km, 3f0km) # single precision as expected
-Point(1m, 2m, 3m) # integer is converted to float by design

Notes

  • Integer coordinates are not supported because most geometric processing algorithms assume a continuous space. The conversion to float avoids InexactError and other unexpected results.
source
rand(Point, 100) |> viz
Example block output
Meshes.toMethod
to(point)

Return the vector from the origin to the point.

source
Base.:-Method
-(A::Point, B::Point)

Return the Vec associated with the direction from point B to point A.

source
Base.:+Method
+(A::Point, v::Vec)
-+(v::Vec, A::Point)

Return the point at the end of the vector v placed at a reference (or start) point A.

source
Base.:-Method
-(A::Point, v::Vec)
--(v::Vec, A::Point)

Return the point at the end of the vector -v placed at a reference (or start) point A.

source

Ray

Meshes.RayType
Ray(p, v)

A ray originating at point p, pointed in direction v. It can be called as r(t) with t > 0 to cast it at p + t * v.

source

Line

BezierCurve

Meshes.BezierCurveType
BezierCurve(points)

A recursive Bézier curve with control points points. See https://en.wikipedia.org/wiki/Bézier_curve. A point on the curve b can be evaluated by calling b(t) with t between 0 and 1. The evaluation method defaults to DeCasteljau's algorithm for accurate evaluation. Horner's method, faster with a large number of points but less precise, can be used via b(t, Horner()).

Examples

BezierCurve([(0.,0.),(1.,-1.)])
source
BezierCurve((0.,0.), (1.,0.), (1.,1.)) |> viz
Example block output

ParametrizedCurve

Meshes.ParametrizedCurveType
ParametrizedCurve(fun, range = (0.0, 1.0))

A parametrized curve is a curve defined by a function fun that maps a (unitless) parameter t in the given range to a Point in space.

Examples

ParametrizedCurve(t -> Point(cos(t), sin(t)), (0, 2π))
source
ParametrizedCurve(t -> Point(cos(t), sin(t), 0.2t), (0, 4π)) |> viz
Example block output

Plane

Meshes.PlaneType
Plane(p, u, v)

A plane embedded in R³ passing through point p, defined by non-parallel vectors u and v.

Plane(p, n)

Alternatively specify point p and a given normal vector n to the plane.

source

Box

Meshes.BoxType
Box(min, max)

A (geodesic) box with min and max points on a given manifold.

Examples

Construct a 3D box using points with Cartesian coordinates:

Box((0, 0, 0), (1, 1, 1))

Likewise, construct a 2D box on the plane:

Box((0, 0), (1, 1))

Construct a geodesic box on the ellipsoid:

Box(Point(LatLon(0, 0)), Point(LatLon(1, 1)))
source
Box((0.,0.,0.), (1.,1.,1.)) |> viz
Example block output

Ball/Sphere

Ball((0.,0.,0.), 1.) |> viz
Example block output

Ellipsoid

Meshes.EllipsoidType
Ellipsoid(radii, center=(0, 0, 0), rotation=I)

A 3D ellipsoid with given radii, center and rotation.

source
Ellipsoid((3., 2., 1.)) |> viz
Example block output

Disk/Circle

Meshes.DiskType
Disk(plane, radius)

A disk embedded in 3-dimensional space on a given plane with given radius.

See also Circle.

source
Meshes.CircleType
Circle(plane, radius)

A circle embedded in 3-dimensional space on a given plane with given radius.

See also Disk.

source

Cylinder/CylinderSurface

Meshes.CylinderType
Cylinder(bottom, top, radius)

A solid circular cylinder embedded in R³ with given radius, delimited by bottom and top planes.

Cylinder(start, finish, radius)

Alternatively, construct a right circular cylinder with given radius along the segment with start and finish end points.

Cylinder(start, finish)

Or construct a right circular cylinder with unit radius along the segment with start and finish end points.

Cylinder(radius)

Finally, construct a right vertical circular cylinder with given radius.

See https://en.wikipedia.org/wiki/Cylinder.

source
Meshes.CylinderSurfaceType
CylinderSurface(bottom, top, radius)

A circular cylinder surface embedded in R³ with given radius, delimited by bottom and top planes.

CylinderSurface(start, finish, radius)

Alternatively, construct a right circular cylinder surface with given radius along the segment with start and finish end points.

CylinderSurface(start, finish)

Or construct a right circular cylinder surface with unit radius along the segment with start and finish end points.

CylinderSurface(radius)

Finally, construct a right vertical circular cylinder surface with given radius.

See https://en.wikipedia.org/wiki/Cylinder.

source
Cylinder(1.0) |> viz
Example block output

Cone/ConeSurface

Cone(Disk(Plane((0,0,0), (0,0,1)), 1), (0,0,1)) |> viz
Example block output

Frustum/FrustumSurface

Frustum(
+Point(1m, 2m, 3m) # integer is converted to float by design

Notes

  • Integer coordinates are not supported because most geometric processing algorithms assume a continuous space. The conversion to float avoids InexactError and other unexpected results.
source
rand(Point, 100) |> viz
Example block output
Meshes.toMethod
to(point)

Return the vector from the origin to the point.

source
Base.:-Method
-(A::Point, B::Point)

Return the Vec associated with the direction from point B to point A.

source
Base.:+Method
+(A::Point, v::Vec)
++(v::Vec, A::Point)

Return the point at the end of the vector v placed at a reference (or start) point A.

source
Base.:-Method
-(A::Point, v::Vec)
+-(v::Vec, A::Point)

Return the point at the end of the vector -v placed at a reference (or start) point A.

source

Ray

Meshes.RayType
Ray(p, v)

A ray originating at point p, pointed in direction v. It can be called as r(t) with t > 0 to cast it at p + t * v.

source

Line

BezierCurve

Meshes.BezierCurveType
BezierCurve(points)

A recursive Bézier curve with control points points. See https://en.wikipedia.org/wiki/Bézier_curve. A point on the curve b can be evaluated by calling b(t) with t between 0 and 1. The evaluation method defaults to DeCasteljau's algorithm for accurate evaluation. Horner's method, faster with a large number of points but less precise, can be used via b(t, Horner()).

Examples

BezierCurve([(0.,0.),(1.,-1.)])
source
BezierCurve((0.,0.), (1.,0.), (1.,1.)) |> viz
Example block output

ParametrizedCurve

Meshes.ParametrizedCurveType
ParametrizedCurve(fun, range = (0.0, 1.0))

A parametrized curve is a curve defined by a function fun that maps a (unitless) parameter t in the given range to a Point in space.

Examples

ParametrizedCurve(t -> Point(cos(t), sin(t)), (0, 2π))
source
ParametrizedCurve(t -> Point(cos(t), sin(t), 0.2t), (0, 4π)) |> viz
Example block output

Plane

Meshes.PlaneType
Plane(p, u, v)

A plane embedded in R³ passing through point p, defined by non-parallel vectors u and v.

Plane(p, n)

Alternatively specify point p and a given normal vector n to the plane.

source

Box

Meshes.BoxType
Box(min, max)

A (geodesic) box with min and max points on a given manifold.

Examples

Construct a 3D box using points with Cartesian coordinates:

Box((0, 0, 0), (1, 1, 1))

Likewise, construct a 2D box on the plane:

Box((0, 0), (1, 1))

Construct a geodesic box on the ellipsoid:

Box(Point(LatLon(0, 0)), Point(LatLon(1, 1)))
source
Box((0.,0.,0.), (1.,1.,1.)) |> viz
Example block output

Ball/Sphere

Ball((0.,0.,0.), 1.) |> viz
Example block output

Ellipsoid

Meshes.EllipsoidType
Ellipsoid(radii, center=(0, 0, 0), rotation=I)

A 3D ellipsoid with given radii, center and rotation.

source
Ellipsoid((3., 2., 1.)) |> viz
Example block output

Disk/Circle

Meshes.DiskType
Disk(plane, radius)

A disk embedded in 3-dimensional space on a given plane with given radius.

See also Circle.

source
Meshes.CircleType
Circle(plane, radius)

A circle embedded in 3-dimensional space on a given plane with given radius.

See also Disk.

source

Cylinder/CylinderSurface

Meshes.CylinderType
Cylinder(bottom, top, radius)

A solid circular cylinder embedded in R³ with given radius, delimited by bottom and top planes.

Cylinder(start, finish, radius)

Alternatively, construct a right circular cylinder with given radius along the segment with start and finish end points.

Cylinder(start, finish)

Or construct a right circular cylinder with unit radius along the segment with start and finish end points.

Cylinder(radius)

Finally, construct a right vertical circular cylinder with given radius.

See https://en.wikipedia.org/wiki/Cylinder.

source
Meshes.CylinderSurfaceType
CylinderSurface(bottom, top, radius)

A circular cylinder surface embedded in R³ with given radius, delimited by bottom and top planes.

CylinderSurface(start, finish, radius)

Alternatively, construct a right circular cylinder surface with given radius along the segment with start and finish end points.

CylinderSurface(start, finish)

Or construct a right circular cylinder surface with unit radius along the segment with start and finish end points.

CylinderSurface(radius)

Finally, construct a right vertical circular cylinder surface with given radius.

See https://en.wikipedia.org/wiki/Cylinder.

source
Cylinder(1.0) |> viz
Example block output

Cone/ConeSurface

Cone(Disk(Plane((0,0,0), (0,0,1)), 1), (0,0,1)) |> viz
Example block output

Frustum/FrustumSurface

Frustum(
   Disk(Plane((0,0,0), (0,0,1)), 2),
   Disk(Plane((0,0,10), (0,0,1)), 1)
-) |> viz
Example block output

Torus

Meshes.TorusType
Torus(center, direction, major, minor)

A torus centered at center with axis of revolution directed by direction and with radii major and minor.

source
Torus((0.,0.,0.), (1.,0.,0.), (0.,1.,0.), 0.2) |> viz
Example block output

ParaboloidSurface

Meshes.ParaboloidSurfaceType
ParaboloidSurface(apex, radius, focallength)

A paraboloid surface embedded in R³ and extending up to a distance radius from its focal axis, which is aligned along the z direction and passes through apex (the apex of the paraboloid). The equation of the paraboloid is the following:

\[f(x, y) = \frac{(x - x_0)^2 + (y - y_0)^2}{4f} + z_0\qquad\text{for } x^2 + y^2 < r^2,\]

where $(x_0, y_0, z_0)$ is the apex of the parabola, $f$ is the focal length, and $r$ is the clip radius.

ParaboloidSurface(apex, radius)

This creates a paraboloid surface with focal length equal to 1.

ParaboloidSurface(apex)

This creates a paraboloid surface with focal length equal to 1 and a rim with unit radius.

ParaboloidSurface()

Same as above, but here the apex is at Apex(0, 0, 0).

See also https://en.wikipedia.org/wiki/Paraboloid.

source
ParaboloidSurface((5., 2., 4.), 1.0, 0.25) |> viz
Example block output
+) |> vizExample block output

Torus

Meshes.TorusType
Torus(center, direction, major, minor)

A torus centered at center with axis of revolution directed by direction and with radii major and minor.

source
Torus((0.,0.,0.), (1.,0.,0.), (0.,1.,0.), 0.2) |> viz
Example block output

ParaboloidSurface

Meshes.ParaboloidSurfaceType
ParaboloidSurface(apex, radius, focallength)

A paraboloid surface embedded in R³ and extending up to a distance radius from its focal axis, which is aligned along the z direction and passes through apex (the apex of the paraboloid). The equation of the paraboloid is the following:

\[f(x, y) = \frac{(x - x_0)^2 + (y - y_0)^2}{4f} + z_0\qquad\text{for } x^2 + y^2 < r^2,\]

where $(x_0, y_0, z_0)$ is the apex of the parabola, $f$ is the focal length, and $r$ is the clip radius.

ParaboloidSurface(apex, radius)

This creates a paraboloid surface with focal length equal to 1.

ParaboloidSurface(apex)

This creates a paraboloid surface with focal length equal to 1 and a rim with unit radius.

ParaboloidSurface()

Same as above, but here the apex is at Apex(0, 0, 0).

See also https://en.wikipedia.org/wiki/Paraboloid.

source
ParaboloidSurface((5., 2., 4.), 1.0, 0.25) |> viz
Example block output diff --git a/dev/index.html b/dev/index.html index bc80c1d8e..aa07975bb 100644 --- a/dev/index.html +++ b/dev/index.html @@ -77,7 +77,7 @@ 1.5707963267948966 rad 2.356194490192345 rad 1.5707963267948966 rad - 2.356194490192345 rad

And there is a lot more functionality available like for instance determining whether or not a polygonal area or chain is simple:

issimple(p)
true

Meshes

Efficient (lazy) mesh representations are provided, including CartesianGrid and SimpleMesh, which are specific types of Domain:

Meshes.DomainType
Domain{M,CRS}

A domain is an indexable collection of geometries (e.g. mesh) in a given manifold M with point coordinates specified in a coordinate reference system CRS.

source
grid = CartesianGrid(100, 100)
+  2.356194490192345 rad

And there is a lot more functionality available like for instance determining whether or not a polygonal area or chain is simple:

issimple(p)
true

Meshes

Efficient (lazy) mesh representations are provided, including CartesianGrid and SimpleMesh, which are specific types of Domain:

Meshes.DomainType
Domain{M,CRS}

A domain is an indexable collection of geometries (e.g. mesh) in a given manifold M with point coordinates specified in a coordinate reference system CRS.

source
grid = CartesianGrid(100, 100)
 
 viz(grid, showsegments = true)
Example block output

No memory is allocated:

@allocated CartesianGrid(10000, 10000, 10000)
0

but we can still loop over the elements, which are quadrangles in 2D:

collect(grid)
10000-element Vector{Quadrangle{𝔼{2}, CoordRefSystems.Cartesian2D{CoordRefSystems.NoDatum, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}}}:
  Quadrangle((x: 0.0 m, y: 0.0 m), ..., (x: 0.0 m, y: 1.0 m))
@@ -118,4 +118,4 @@
  Triangle((x: 0.0 m, y: 0.0 m), (x: 0.25 m, y: 0.5 m), (x: 0.0 m, y: 1.0 m))
  Triangle((x: 1.0 m, y: 1.0 m), (x: 0.75 m, y: 0.5 m), (x: 1.0 m, y: 0.0 m))
  Quadrangle((x: 0.0 m, y: 0.0 m), ..., (x: 0.25 m, y: 0.5 m))
- Quadrangle((x: 1.0 m, y: 1.0 m), ..., (x: 0.75 m, y: 0.5 m))
+ Quadrangle((x: 1.0 m, y: 1.0 m), ..., (x: 0.75 m, y: 0.5 m)) diff --git a/dev/io/index.html b/dev/io/index.html index e5e95003b..89a9191b2 100644 --- a/dev/io/index.html +++ b/dev/io/index.html @@ -1,2 +1,2 @@ -Input/Output · Meshes.jl

Input/Output

The GeoIO.jl package can be used to load/save mesh data in various different formats, including VTK, GIS, PLY and many other formats. The package provides two functions GeoIO.load and GeoIO.save, which are self-explanatory:

geotable = GeoIO.load("data.vtr")
GeoIO.save("data.vtu", geotable)

Please check the Geospatial Data Science with Julia book for more information.

+Input/Output · Meshes.jl

Input/Output

The GeoIO.jl package can be used to load/save mesh data in various different formats, including VTK, GIS, PLY and many other formats. The package provides two functions GeoIO.load and GeoIO.save, which are self-explanatory:

geotable = GeoIO.load("data.vtr")
GeoIO.save("data.vtu", geotable)

Please check the Geospatial Data Science with Julia book for more information.

diff --git a/dev/links/index.html b/dev/links/index.html index f8acce914..9597f9917 100644 --- a/dev/links/index.html +++ b/dev/links/index.html @@ -1,2 +1,2 @@ -Index · Meshes.jl

Index

Below is the list of types and functions mentioned in the documentation.

Types

Functions

+Index · Meshes.jl

Index

Below is the list of types and functions mentioned in the documentation.

Types

Functions

diff --git a/dev/objects.inv b/dev/objects.inv index 743e88f04..1c72a9539 100644 Binary files a/dev/objects.inv and b/dev/objects.inv differ diff --git a/dev/predicates/index.html b/dev/predicates/index.html index 17a01f775..6e5179fc1 100644 --- a/dev/predicates/index.html +++ b/dev/predicates/index.html @@ -1,5 +1,5 @@ -Predicates · Meshes.jl

Predicates

This section lists predicates that can be used to check properties of geometric objects, both of themselves and relative to other geometric objects.

One important note to make is that these predicates are not necessarily exact. For example, rather than checking if a point p is exactly in a sphere of radius r centered at c, we check if norm(p-c) ≈ r with an absolute tolerance depending on the point type, so p might be slightly outside the sphere but still be considered as being inside. This absolute tolerance can be adjusted in specific scopes as discussed in the Tolerances section.

Robust predicates are often expensive to apply and approximations typically suffice. If needed, consider ExactPredicates.jl or AdaptivePredicates.jl.

isparametrized

Meshes.isparametrizedFunction
isparametrized(object)

Tells whether or not the geometric object is parametrized, i.e. can be called as object(u₁, u₂, ..., uₙ) with local coordinates (u₁, u₂, ..., uₙ) ∈ [0,1]ⁿ where n is the parametric dimension.

See also paramdim.

source
Meshes.paramdimFunction
paramdim(geometry)

Return the number of parametric dimensions of the geometry. For example, a sphere embedded in 3D has 2 parametric dimensions (polar and azimuthal angles).

See also isparametrized.

source
paramdim(polytope)

Return the parametric dimension or rank of the polytope.

source
paramdim(connectivity)

Return the parametric dimension of the connectivity.

source
paramdim(domain)

Return the number of parametric dimensions of the domain as the number of parametric dimensions of its elements.

source

isperiodic

Meshes.isperiodicFunction
isperiodic(topology)

Tells whether or not the topology is periodic along each parametric dimension.

source
isperiodic(geometry)

Tells whether or not the geometry is periodic along each parametric dimension.

source
isperiodic(grid)

Tells whether or not the grid is periodic along each parametric dimension.

source

issimplex

Meshes.issimplexFunction
issimplex(geometry)

Tells whether or not the geometry is a simplex.

source
issimplex(connectivity)

Tells whether or not the connectivity is a simplex.

source

isclosed

Meshes.isclosedFunction
isclosed(chain)

Tells whether or not the chain is closed.

A closed chain is also known as a ring.

source

isconvex

issimple

hasholes

point₁ ≤ point₂

point₁ ⪯ point₂

point ∈ geometry

Base.inMethod
point ∈ geometry

Tells whether or not the point is in the geometry.

source

geometry₁ ⊆ geometry₂

Base.issubsetMethod
geometry₁ ⊆ geometry₂

Tells whether or not geometry₁ is contained in geometry₂.

source

intersects

outer = [(0,0),(1,0),(1,1),(0,1)]
+Predicates · Meshes.jl

Predicates

This section lists predicates that can be used to check properties of geometric objects, both of themselves and relative to other geometric objects.

One important note to make is that these predicates are not necessarily exact. For example, rather than checking if a point p is exactly in a sphere of radius r centered at c, we check if norm(p-c) ≈ r with an absolute tolerance depending on the point type, so p might be slightly outside the sphere but still be considered as being inside. This absolute tolerance can be adjusted in specific scopes as discussed in the Tolerances section.

Robust predicates are often expensive to apply and approximations typically suffice. If needed, consider ExactPredicates.jl or AdaptivePredicates.jl.

isparametrized

Meshes.isparametrizedFunction
isparametrized(object)

Tells whether or not the geometric object is parametrized, i.e. can be called as object(u₁, u₂, ..., uₙ) with local coordinates (u₁, u₂, ..., uₙ) ∈ [0,1]ⁿ where n is the parametric dimension.

See also paramdim.

source
Meshes.paramdimFunction
paramdim(geometry)

Return the number of parametric dimensions of the geometry. For example, a sphere embedded in 3D has 2 parametric dimensions (polar and azimuthal angles).

See also isparametrized.

source
paramdim(polytope)

Return the parametric dimension or rank of the polytope.

source
paramdim(connectivity)

Return the parametric dimension of the connectivity.

source
paramdim(domain)

Return the number of parametric dimensions of the domain as the number of parametric dimensions of its elements.

source

isperiodic

Meshes.isperiodicFunction
isperiodic(topology)

Tells whether or not the topology is periodic along each parametric dimension.

source
isperiodic(geometry)

Tells whether or not the geometry is periodic along each parametric dimension.

source
isperiodic(grid)

Tells whether or not the grid is periodic along each parametric dimension.

source

issimplex

Meshes.issimplexFunction
issimplex(geometry)

Tells whether or not the geometry is a simplex.

source
issimplex(connectivity)

Tells whether or not the connectivity is a simplex.

source

isclosed

Meshes.isclosedFunction
isclosed(chain)

Tells whether or not the chain is closed.

A closed chain is also known as a ring.

source

isconvex

issimple

hasholes

point₁ ≤ point₂

point₁ ⪯ point₂

point ∈ geometry

Base.inMethod
point ∈ geometry

Tells whether or not the point is in the geometry.

source

geometry₁ ⊆ geometry₂

Base.issubsetMethod
geometry₁ ⊆ geometry₂

Tells whether or not geometry₁ is contained in geometry₂.

source

intersects

outer = [(0,0),(1,0),(1,1),(0,1)]
 hole1 = [(0.2,0.2),(0.4,0.2),(0.4,0.4),(0.2,0.4)]
 hole2 = [(0.6,0.2),(0.8,0.2),(0.8,0.4),(0.6,0.4)]
 poly  = PolyArea([outer, hole1, hole2])
@@ -8,4 +8,4 @@
 ball3 = Ball((0.7,0.3), 0.05)
 ball4 = Ball((0.3,0.3), 0.15)
 
-intersects(poly, ball1)
true
intersects(poly, ball2)
true
intersects(poly, ball3)
true
intersects(poly, ball4)
true

iscollinear

iscoplanar

Meshes.iscoplanarFunction
iscoplanar(A, B, C, D)

Tells whether or not the points A, B, C and D are coplanar.

source
+intersects(poly, ball1)
true
intersects(poly, ball2)
true
intersects(poly, ball3)
true
intersects(poly, ball4)
true

iscollinear

iscoplanar

Meshes.iscoplanarFunction
iscoplanar(A, B, C, D)

Tells whether or not the points A, B, C and D are coplanar.

source
diff --git a/dev/rand/index.html b/dev/rand/index.html index 7d75398ec..8b305cf84 100644 --- a/dev/rand/index.html +++ b/dev/rand/index.html @@ -2,20 +2,20 @@ Random · Meshes.jl

Random

Base.randMethod
rand([rng], G, crs=Cartesian3D)

Generate a random geometry of type G with CRS crs, optionally passing a random number generator rng.

Examples

rand(Point)
 rand(Triangle)
 rand(Point, crs=Cartesian2D)
-rand(Triangle, crs=LatLon)
source
Base.randMethod
rand([rng], G, n, crs=Cartesian3D)

Generate a vector of n random geometries of type G with CRS crs, optionally passing a random number generator rng.

Examples

rand(Point, 10)
+rand(Triangle, crs=LatLon)
source
Base.randMethod
rand([rng], G, n, crs=Cartesian3D)

Generate a vector of n random geometries of type G with CRS crs, optionally passing a random number generator rng.

Examples

rand(Point, 10)
 rand(Triangle, 10)
 rand(Point, 10, crs=Cartesian2D)
-rand(Triangle, 10, crs=LatLon)
source

Random geometries can be generated using the rand function:

rand(Point)
Point with Cartesian{NoDatum} coordinates
-├─ x: 0.3847531664354499 m
-├─ y: 0.8947789142231214 m
-└─ z: 0.6305456515864319 m

By default, the rand function uses the Cartesian3D CRS (Coordinate Reference System). It's possible to change the CRS using the crs keyword argument:

rand(Point, crs=Cartesian2D)
Point with Cartesian{NoDatum} coordinates
-├─ x: 0.442793942799528 m
-└─ y: 0.15907762956518845 m

A vector of geometries can be generated by passing the number of elements as the second argument:

rand(Segment, 5, crs=LatLon)
5-element Vector{Segment{🌐, CoordRefSystems.GeodeticLatLon{CoordRefSystems.WGS84Latest, Unitful.Quantity{Float64, NoDims, Unitful.FreeUnits{(°,), NoDims, nothing}}}}}:
- Segment((lat: 82.4633°, lon: 144.231°), (lat: -77.3492°, lon: 27.1227°))
- Segment((lat: -58.3015°, lon: 68.3571°), (lat: -43.846°, lon: -154.277°))
- Segment((lat: 9.61665°, lon: 128.66°), (lat: 4.00345°, lon: 21.8148°))
- Segment((lat: -25.1312°, lon: -13.0163°), (lat: -19.1492°, lon: -165.479°))
- Segment((lat: -73.9141°, lon: -67.5696°), (lat: 74.6037°, lon: 159.09°))

For reproducibility purposes, a random number generator can be passed as the first argument in both methods:

rng = MersenneTwister(123)
+rand(Triangle, 10, crs=LatLon)
source

Random geometries can be generated using the rand function:

rand(Point)
Point with Cartesian{NoDatum} coordinates
+├─ x: 0.47816974799500434 m
+├─ y: 0.6065862273249142 m
+└─ z: 0.6225021062458898 m

By default, the rand function uses the Cartesian3D CRS (Coordinate Reference System). It's possible to change the CRS using the crs keyword argument:

rand(Point, crs=Cartesian2D)
Point with Cartesian{NoDatum} coordinates
+├─ x: 0.9569101325565309 m
+└─ y: 0.43831396575110926 m

A vector of geometries can be generated by passing the number of elements as the second argument:

rand(Segment, 5, crs=LatLon)
5-element Vector{Segment{🌐, CoordRefSystems.GeodeticLatLon{CoordRefSystems.WGS84Latest, Unitful.Quantity{Float64, NoDims, Unitful.FreeUnits{(°,), NoDims, nothing}}}}}:
+ Segment((lat: 80.7951°, lon: 114.685°), (lat: 50.4319°, lon: 83.4373°))
+ Segment((lat: -23.7789°, lon: -95.7393°), (lat: -27.1755°, lon: -65.3839°))
+ Segment((lat: 46.4611°, lon: -127.224°), (lat: 66.2921°, lon: 19.1005°))
+ Segment((lat: 42.5023°, lon: 173.539°), (lat: 10.1597°, lon: -80.2416°))
+ Segment((lat: 76.1871°, lon: 35.2621°), (lat: -83.6154°, lon: -101.824°))

For reproducibility purposes, a random number generator can be passed as the first argument in both methods:

rng = MersenneTwister(123)
 rand(rng, Triangle)
Triangle
 ├─ Point(x: 0.37453777969575874 m, y: 0.8735343642013971 m, z: 0.29012488666251546 m)
 ├─ Point(x: 0.3368408330598551 m, y: 0.6622706870716968 m, z: 0.7763361853035142 m)
@@ -24,4 +24,4 @@
  Triangle((x: 0.0877252 m, y: 0.92557 m, z: 0.597156 m), (x: 0.74611 m, y: 0.891596 m, z: 0.0626721 m), (x: 0.070898 m, y: 0.0485191 m, z: 0.652385 m))
  Triangle((x: 0.580893 m, y: 0.339631 m, z: 0.644323 m), (x: 0.580265 m, y: 0.226512 m, z: 0.289129 m), (x: 0.630659 m, y: 0.47637 m, z: 0.282868 m))
  Triangle((x: 0.886623 m, y: 0.511879 m, z: 0.503287 m), (x: 0.193622 m, y: 0.470371 m, z: 0.0511627 m), (x: 0.388379 m, y: 0.739729 m, z: 0.925322 m))
- Triangle((x: 0.397732 m, y: 0.47886 m, z: 0.293984 m), (x: 0.176495 m, y: 0.999095 m, z: 0.822975 m), (x: 0.500431 m, y: 0.736043 m, z: 0.149681 m))
+ Triangle((x: 0.397732 m, y: 0.47886 m, z: 0.293984 m), (x: 0.176495 m, y: 0.999095 m, z: 0.822975 m), (x: 0.500431 m, y: 0.736043 m, z: 0.149681 m)) diff --git a/dev/tolerances/index.html b/dev/tolerances/index.html index 794e26731..b0dd33438 100644 --- a/dev/tolerances/index.html +++ b/dev/tolerances/index.html @@ -4,4 +4,4 @@ with(Meshes.ATOL64 => 1e-9, Meshes.ATOL32 => 1f-4) do # do your computations with custom tolerances -end +end diff --git a/dev/transforms/index.html b/dev/transforms/index.html index 50d600382..7345d17bb 100644 --- a/dev/transforms/index.html +++ b/dev/transforms/index.html @@ -1,23 +1,23 @@ -Transforms · Meshes.jl

Transforms

Geometric (e.g. coordinates) transforms are implemented according to the TransformsBase.jl interface. Please read their documentation for more details.

Some transforms have an inverse that can be created with the inverse function. The function isinvertible can be used to check if a transform is invertible.

TransformsBase.isinvertibleFunction
isinvertible(transform)

Tells whether or not the transform is invertible, i.e. whether it implements the inverse function. Defaults to false for new transform types.

Transforms can be invertible in the mathematical sense, i.e., there exists a one-to-one mapping between input and output spaces.

See also inverse, isrevertible.

source

Rotate

Meshes.RotateType
Rotate(R)

Rotate geometry or domain with rotation R from Rotations.jl.

Rotate(u, v)

Rotation mapping the axis directed by u to the axis directed by v. More precisely, it maps the plane passing through the origin with normal vector u to the plane passing through the origin with normal vector v.

Rotate(θ)

Rotate the 2D geometry or domain by angle θ, in radians, using the Angle2d rotation.

Examples

Rotate(one(RotXYZ{Float64})) # identity rotation
+Transforms · Meshes.jl

Transforms

Geometric (e.g. coordinates) transforms are implemented according to the TransformsBase.jl interface. Please read their documentation for more details.

Some transforms have an inverse that can be created with the inverse function. The function isinvertible can be used to check if a transform is invertible.

TransformsBase.isinvertibleFunction
isinvertible(transform)

Tells whether or not the transform is invertible, i.e. whether it implements the inverse function. Defaults to false for new transform types.

Transforms can be invertible in the mathematical sense, i.e., there exists a one-to-one mapping between input and output spaces.

See also inverse, isrevertible.

source

Rotate

Meshes.RotateType
Rotate(R)

Rotate geometry or domain with rotation R from Rotations.jl.

Rotate(u, v)

Rotation mapping the axis directed by u to the axis directed by v. More precisely, it maps the plane passing through the origin with normal vector u to the plane passing through the origin with normal vector v.

Rotate(θ)

Rotate the 2D geometry or domain by angle θ, in radians, using the Angle2d rotation.

Examples

Rotate(one(RotXYZ{Float64})) # identity rotation
 Rotate(AngleAxis(0.2, 1.0, 0.0, 0.0)) # rotate 0.2 radians around X axis
 Rotate(rand(QuatRotation{Float64})) # random rotation
 Rotate(Vec(1, 0, 0), Vec(1, 1, 1)) # rotation from (1, 0, 0) to (1, 1, 1)
-Rotate(π / 2) # 2D rotation with angle in radians
source
grid = CartesianGrid(10, 10)
+Rotate(π / 2) # 2D rotation with angle in radians
source
grid = CartesianGrid(10, 10)
 
 mesh = grid |> Rotate(π/4)
 
 fig = Mke.Figure(size = (800, 400))
 viz(fig[1,1], grid)
 viz(fig[1,2], mesh)
-fig
Example block output

Translate

Meshes.TranslateType
Translate(o₁, o₂, ...)

Translate coordinates of geometry or mesh by given offsets o₁, o₂, ....

source
grid = CartesianGrid(10, 10)
+fig
Example block output

Translate

Meshes.TranslateType
Translate(o₁, o₂, ...)

Translate coordinates of geometry or mesh by given offsets o₁, o₂, ....

source
grid = CartesianGrid(10, 10)
 
 mesh = grid |> Translate(10., 20.)
 
 fig = Mke.Figure(size = (800, 400))
 viz(fig[1,1], grid)
 viz(fig[1,2], mesh)
-fig
Example block output

Scale

Meshes.ScaleType
Scale(s₁, s₂, ...)

Scale geometry or domain with strictly positive scaling factors s₁, s₂, ....

Examples

Scale(1.0, 2.0, 3.0)
source
grid = CartesianGrid(10, 10)
+fig
Example block output

Scale

Meshes.ScaleType
Scale(s₁, s₂, ...)

Scale geometry or domain with strictly positive scaling factors s₁, s₂, ....

Examples

Scale(1.0, 2.0, 3.0)
source
grid = CartesianGrid(10, 10)
 
 mesh = grid |> Scale(2., 3.)
 
@@ -26,7 +26,7 @@
 viz(fig[1,2], mesh)
 fig
Example block output

Affine

Meshes.AffineType
Affine(A, b)

Affine transform Ax + b with matrix A and vector b.

Examples

Affine(AngleAxis(0.2, 1.0, 0.0, 0.0), [-2, 2, 2])
 Affine(Angle2d(π / 2), SVector(2, -2))
-Affine([0 -1; 1 0], [-2, 2])
source
using Rotations: Angle2d
+Affine([0 -1; 1 0], [-2, 2])
source
using Rotations: Angle2d
 
 grid = CartesianGrid(10, 10)
 
@@ -35,7 +35,7 @@
 fig = Mke.Figure(size = (800, 400))
 viz(fig[1,1], grid)
 viz(fig[1,2], mesh)
-fig
Example block output

Stretch

Meshes.StretchType
Stretch(s₁, s₂, ...)

Stretch geometry or domain outwards with strictly positive scaling factors s₁, s₂, ....

Examples

Stretch(1.0, 2.0, 3.0)
source
grid = CartesianGrid(10, 10)
+fig
Example block output

Stretch

Meshes.StretchType
Stretch(s₁, s₂, ...)

Stretch geometry or domain outwards with strictly positive scaling factors s₁, s₂, ....

Examples

Stretch(1.0, 2.0, 3.0)
source
grid = CartesianGrid(10, 10)
 
 mesh = grid |> Stretch(2., 3.)
 
@@ -46,7 +46,7 @@
 10×10 CartesianGrid{2,Float64}
   minimum: Point(-0.5, -0.5)
   maximum: Point(0.5, 0.5)
-  spacing: (0.1, 0.1)
source
# Cartesian grid with coordinates [0,10] x [0,10]
+  spacing: (0.1, 0.1)
source
# Cartesian grid with coordinates [0,10] x [0,10]
 grid = CartesianGrid(10, 10)
 
 # scale coordinates to [-1,1] x [-1,1]
@@ -60,7 +60,7 @@
 Proj(WebMercator)
 Proj(Mercator{WGS84Latest})
 Proj(EPSG{3395})
-Proj(ESRI{54017})

Notes

source
# load coordinate reference system
+Proj(ESRI{54017})

Notes

source
# load coordinate reference system
 using CoordRefSystems: Polar
 
 # triangle with Cartesian coordinates
@@ -74,7 +74,7 @@
 ball |> Morphological(c -> Cartesian(c.x + c.y, c.y, c.x - c.y))
 
 triangle = Triangle(Point(LatLon(0, 0)), Point(LatLon(0, 45)), Point(LatLon(45, 0)))
-triangle |> Morphological(c -> LatLonAlt(c.lat, c.lon, 0.0m))

Notes

source
# triangle with Cartesian coordinates
+triangle |> Morphological(c -> LatLonAlt(c.lat, c.lon, 0.0m))

Notes

source
# triangle with Cartesian coordinates
 triangle = Triangle((0, 0), (1, 0), (1, 1))
 
 # transform triangle coordinates
@@ -82,7 +82,7 @@
 ├─ Point(x: 0.0 m, y: 0.0 m, z: 0.0 m)
 ├─ Point(x: 1.0 m, y: 0.0 m, z: 0.0 m)
 └─ Point(x: 1.0 m, y: 1.0 m, z: 0.0 m)

LengthUnit

Meshes.LengthUnitType
LengthUnit(unit)

Convert the length unit of coordinates of a geometry or domain to unit.

Examples

LengthUnit(u"cm")
-LengthUnit(u"km")
source
using Unitful: m, cm
+LengthUnit(u"km")
source
using Unitful: m, cm
 
 # convert meters to centimeters
 Point(1m, 2m, 3m) |> LengthUnit(cm)
Point with Cartesian{NoDatum} coordinates
@@ -91,7 +91,7 @@
 └─ z: 300.0 cm

Shadow

Meshes.ShadowType
Shadow(dims)

Project the geometry or domain onto the given dims, producing a "shadow" of the original object.

Examples

Shadow(:xy)
 Shadow("xz")
 Shadow(1, 2)
-Shadow((1, 3))
source
ball = Ball((0, 0, 0), 1)
+Shadow((1, 3))
source
ball = Ball((0, 0, 0), 1)
 disk = ball |> Shadow("xy")
 
 
@@ -102,14 +102,14 @@
 Slice(lat=(latmin, latmax), lon=(lonmin, lonmax))

Retain the domain elements within x limits [xmax,xmax], y limits [ymax,ymax] and z limits [zmin,zmax] in length units (default to meters), or within lat limits [latmin,latmax] and lon limits [lonmin,lonmax] in degree units.

Examples

Slice(x=(1000km, 3000km))
 Slice(x=(1000km, 2000km), y=(2000km, 5000km))
 Slice(lon=(0°, 90°))
-Slice(lon=(0°, 45°), lat=(0°, 45°))
source
grid = CartesianGrid(10, 10)
+Slice(lon=(0°, 45°), lat=(0°, 45°))
source
grid = CartesianGrid(10, 10)
 subgrid = grid |> Slice(x=(1.5, 6.5), y=(3.5, 8.5))
 
 fig = Mke.Figure(size = (800, 400))
 viz(fig[1,1], grid)
 viz(fig[1,2], subgrid)
 fig
Example block output

Repair

Meshes.RepairType
Repair(K)

Perform repairing operation with code K.

Available operations

  • K = 0: duplicated vertices and faces are removed
  • K = 1: unused vertices are removed
  • K = 2: non-manifold faces are removed
  • K = 3: degenerate faces are removed
  • K = 4: non-manifold vertices are removed
  • K = 5: non-manifold vertices are split by threshold
  • K = 6: close vertices are merged (given a radius)
  • K = 7: faces are coherently oriented
  • K = 8: zero-area ears are removed
  • K = 9: rings of polygon are sorted
  • K = 10: outer rings of polygon are expanded
  • K = 11: rings of polygon are coherently oriented
  • K = 12: degenerate rings of polygon are removed

Examples

# remove duplicates and degenerates
-mesh |> Repair(0) |> Repair(3)
source
# mesh with unreferenced point
+mesh |> Repair(0) |> Repair(3)
source
# mesh with unreferenced point
 points = [(0, 0, 0), (0, 0, 1), (5, 5, 5), (0, 1, 0), (1, 0, 0)]
 connec = connect.([(1, 2, 4), (1, 2, 5), (1, 4, 5), (2, 4, 5)])
 mesh   = SimpleMesh(points, connec)
@@ -124,7 +124,7 @@
   ├─ Triangle(1, 2, 3)
   ├─ Triangle(1, 2, 4)
   ├─ Triangle(1, 3, 4)
-  └─ Triangle(2, 3, 4)

Bridge

Meshes.BridgeType
Bridge(δ=0)

Transform polygon with holes into a single outer ring via bridges of given width δ as described in Held 1998.

References

source
# polygon with two holes
+  └─ Triangle(2, 3, 4)

Bridge

Meshes.BridgeType
Bridge(δ=0)

Transform polygon with holes into a single outer ring via bridges of given width δ as described in Held 1998.

References

source
# polygon with two holes
 outer = [(0, 0), (1, 0), (1, 1), (0, 1)]
 hole1 = [(0.2, 0.2), (0.2, 0.4), (0.4, 0.4), (0.4, 0.2)]
 hole2 = [(0.6, 0.2), (0.6, 0.4), (0.8, 0.4), (0.8, 0.2)]
@@ -136,7 +136,7 @@
 fig = Mke.Figure(size = (800, 400))
 viz(fig[1,1], poly)
 viz(fig[1,2], bpoly)
-fig
Example block output

Smoothing

Meshes.LambdaMuSmoothingType
LambdaMuSmoothing(n, λ, μ)

Perform n smoothing iterations with parameters λ and μ.

See also LaplaceSmoothing, TaubinSmoothing.

References

source
Meshes.LaplaceSmoothingFunction
LaplaceSmoothing(n, λ=0.5)

Perform n iterations of Laplace smoothing with parameter λ.

References

source
Meshes.TaubinSmoothingFunction
TaubinSmoothing(n, λ=0.5)

Perform n iterations of Taubin smoothing with parameter 0 < λ < 1.

References

source
using PlyIO
+fig
Example block output

Smoothing

Meshes.LambdaMuSmoothingType
LambdaMuSmoothing(n, λ, μ)

Perform n smoothing iterations with parameters λ and μ.

See also LaplaceSmoothing, TaubinSmoothing.

References

source
Meshes.LaplaceSmoothingFunction
LaplaceSmoothing(n, λ=0.5)

Perform n iterations of Laplace smoothing with parameter λ.

References

source
Meshes.TaubinSmoothingFunction
TaubinSmoothing(n, λ=0.5)

Perform n iterations of Taubin smoothing with parameter 0 < λ < 1.

References

source
using PlyIO
 
 # helper function to read *.ply files
 function readply(fname)
@@ -163,4 +163,4 @@
 fig = Mke.Figure(size = (800, 1200))
 viz(fig[1,1], mesh)
 viz(fig[2,1], smesh)
-fig
Example block output +fig
Example block output diff --git a/dev/vectors/index.html b/dev/vectors/index.html index cb9a4e1fc..2c99c0d5d 100644 --- a/dev/vectors/index.html +++ b/dev/vectors/index.html @@ -14,4 +14,4 @@ Vec(1.0, 2.0, 3.0) # add default units Vec(1.0m, 2.0m, 3.0m) # double precision as expected Vec(1f0km, 2f0km, 3f0km) # single precision as expected -Vec(1m, 2m, 3m) # integer is converted to float by design

Notes

source +Vec(1m, 2m, 3m) # integer is converted to float by design

Notes

source diff --git a/dev/visualization/86aa1ebb.png b/dev/visualization/86aa1ebb.png deleted file mode 100644 index 13dae63a1..000000000 Binary files a/dev/visualization/86aa1ebb.png and /dev/null differ diff --git a/dev/visualization/9b1c86ef.png b/dev/visualization/9b1c86ef.png new file mode 100644 index 000000000..c30d5c62f Binary files /dev/null and b/dev/visualization/9b1c86ef.png differ diff --git a/dev/visualization/index.html b/dev/visualization/index.html index 51fc54670..772f61a3e 100644 --- a/dev/visualization/index.html +++ b/dev/visualization/index.html @@ -8,8 +8,8 @@ # visualize boundary with separate call viz(polygon) -viz!(boundary(polygon))

Notes

source
Meshes.viz!Function
viz!(object; [options])

Visualize Meshes.jl object in an existing scene with options forwarded to viz.

source

Geometries

We can visualize a single geometry or multiple geometries in a vector:

triangles = rand(Triangle, 10, crs=Cartesian2D)
+viz!(boundary(polygon))

Notes

source
Meshes.viz!Function
viz!(object; [options])

Visualize Meshes.jl object in an existing scene with options forwarded to viz.

source

Geometries

We can visualize a single geometry or multiple geometries in a vector:

triangles = rand(Triangle, 10, crs=Cartesian2D)
 
-viz(triangles, color = 1:10)
Example block output

Domains

Alternatively, we can visualize domains with topological information such as Mesh and show facets efficiently:

grid = CartesianGrid(10, 10, 10)
+viz(triangles, color = 1:10)
Example block output

Domains

Alternatively, we can visualize domains with topological information such as Mesh and show facets efficiently:

grid = CartesianGrid(10, 10, 10)
 
-viz(grid, showsegments = true, segmentcolor = :teal)
Example block output +viz(grid, showsegments = true, segmentcolor = :teal)Example block output