-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4a8b88
commit 7fc71a6
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |