Skip to content

Commit

Permalink
Add page for example usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeingold committed Sep 4, 2024
1 parent f4a8b88 commit 7fc71a6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ makedocs(
"Home" => [
"About" => "index.md",
"Support Matrix" => "supportmatrix.md",
"Integration Algorithms" => "algorithms.md"
"Integration Algorithms" => "algorithms.md",
"Example Usage" => "usage.md"
],
"Derivations" => [
"Integrating a Triangle" => "triangle.md"
Expand Down
31 changes: 31 additions & 0 deletions docs/src/usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Example Usage

## Integrating along a Bezier curve

```julia
using Meshes
using MeshIntegrals

# Define a unit circle on the xy-plane
origin = Point(0,0,0)
= Vec(0,0,1)
xy_plane = Plane(origin,ẑ)
unit_circle_xy = Circle(xy_plane, 1.0)

# Approximate unit_circle_xy with a high-order Bezier curve
unit_circle_bz = BezierCurve(
[Point(cos(t), sin(t), 0.0) for t in range(0,2pi,length=361)]
)

# A Real-valued function
f(x, y, z) = abs(x + y)
f(p) = f(to(p)...)

integral(f, unit_circle_xy, GaussKronrod())
# 0.000170 seconds (5.00 k allocations: 213.531 KiB)
# ans == 5.656854249525293 m^2

integral(f, unit_circle_bz, GaussKronrod())
# 0.017122 seconds (18.93 k allocations: 78.402 MiB)
# ans = 5.551055333711397 m^2
```

0 comments on commit 7fc71a6

Please sign in to comment.