A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/alandefreitas/matplotplusplus/commit/e17c93419529c8a17e7fb07c12c3cf779f2189ec below:

Fix quiver scaling to respect user input (#280) · alandefreitas/matplotplusplus@e17c934 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+22

-6

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+22

-6

lines changed Original file line number Diff line number Diff line change

@@ -16,7 +16,7 @@ int main() {

16 16

auto V = get_v();

17 17

auto W = get_w();

18 18 19 -

quiver3(Z, U, V, W);

19 +

quiver3(Z, U, V, W, 5);

20 20

view(-35, 45);

21 21 22 22

show();

Original file line number Diff line number Diff line change

@@ -4551,15 +4551,23 @@ namespace matplot {

4551 4551

double v_max = *std::max_element(v.begin(), v.end());

4552 4552

double y_max = ydiffmin != y_diff.end() ? *ydiffmin : v_max;

4553 4553 4554 +

// scale u, v with same ratio to retain direction

4555 +

double mag_max = 1;

4556 +

for (size_t i = 0; i < u.size(); ++i) {

4557 +

double mag = sqrt(u[i] * u[i] + v[i] * v[i]);

4558 +

mag_max = mag > mag_max ? mag : mag_max;

4559 +

}

4560 +

double val_max = std::min(x_max, y_max);

4561 + 4554 4562

auto u_scaled =

4555 4563

(scale != 0.)

4556 4564

? transform(

4557 -

u, [&](double u) { return (u / u_max) * scale * x_max; })

4565 +

u, [&](double u) { return (u / mag_max) * scale * val_max; })

4558 4566

: u;

4559 4567

auto v_scaled =

4560 4568

(scale != 0.)

4561 4569

? transform(

4562 -

v, [&](double v) { return (v / v_max) * scale * y_max; })

4570 +

v, [&](double v) { return (v / mag_max) * scale * val_max; })

4563 4571

: v;

4564 4572 4565 4573

vectors_handle l = std::make_shared<class vectors>(

@@ -4640,20 +4648,28 @@ namespace matplot {

4640 4648

double w_max = *std::max_element(w.begin(), w.end());

4641 4649

double z_max = zdiffmin != z_diff.end() ? *zdiffmin : w_max;

4642 4650 4651 +

// scale u, v, w with same ratio to retain direction

4652 +

double mag_max = 1;

4653 +

for (size_t i = 0; i < u.size(); ++i) {

4654 +

double mag = sqrt(u[i] * u[i] + v[i] * v[i] + w[i] * w[i]);

4655 +

mag_max = mag > mag_max ? mag : mag_max;

4656 +

}

4657 +

double val_max = std::min(std::min(x_max, y_max), z_max);

4658 + 4643 4659

auto u_scaled =

4644 4660

(scale != 0.)

4645 4661

? transform(

4646 -

u, [&](double u) { return (u / u_max) * scale * x_max; })

4662 +

u, [&](double u) { return (u / mag_max) * scale * val_max; })

4647 4663

: u;

4648 4664

auto v_scaled =

4649 4665

(scale != 0.)

4650 4666

? transform(

4651 -

v, [&](double v) { return (v / v_max) * scale * y_max; })

4667 +

v, [&](double v) { return (v / mag_max) * scale * val_max; })

4652 4668

: v;

4653 4669

auto w_scaled =

4654 4670

(scale != 0.)

4655 4671

? transform(

4656 -

w, [&](double w) { return (w / w_max) * scale * z_max; })

4672 +

w, [&](double w) { return (w / mag_max) * scale * val_max; })

4657 4673

: w;

4658 4674 4659 4675

vectors_handle l = std::make_shared<class vectors>(

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4