Skip to content

Commit 8913c4d

Browse files
added quiver example
1 parent f4ffb7c commit 8913c4d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

examples/vector_fields/quiver/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ add_executable(example_quiver_5 quiver_5.cpp)
1414
target_link_libraries(example_quiver_5 PUBLIC matplot)
1515

1616

17+
add_executable(example_quiver_6 quiver_6.cpp)
18+
target_link_libraries(example_quiver_6 PUBLIC matplot)
1719

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <cmath>
2+
#include <matplot/matplot.h>
3+
4+
int main() {
5+
using namespace matplot;
6+
auto [x, y] = meshgrid(iota(-2.5, 0.25, 2.5), iota(-2.5, 0.25, 2.5));
7+
vector_2d u =
8+
transform(x, y, [](double x, double y) { return cos(x)*sin(x + y); });
9+
vector_2d v =
10+
transform(x, y, [](double x, double y) { return sin(y)*cos(x + y); });
11+
12+
vector_2d m =
13+
transform(u, v, [](double u, double v) { return sqrt(u * u + v * v); });
14+
15+
quiver(x, y, u, v, m, 0.2)->normalize(true).line_width(1.5);
16+
17+
show();
18+
return 0;
19+
}

0 commit comments

Comments
 (0)