Test-cases for compatibility with Eigen.
More...
#include "../vnix/units.hpp"
#include "catch.hpp"
#include <eigen3/Eigen/Geometry>
Go to the source code of this file.
|
| TEST_CASE ("Matrix methods can be called.","[dimval]") |
|
Test-cases for compatibility with Eigen.
- Copyright
- 2019 Thomas E. Vaughan; all rights reserved.
- License: BSD three-clause; see LICENSE.
Definition in file eigen-compat-test.cpp.
TEST_CASE |
( |
"Matrix methods can be called." |
, |
|
|
"" |
[dimval] |
|
) |
| |
Definition at line 13 of file eigen-compat-test.cpp.
14 using namespace Eigen;
17 AngleAxisf r(M_PI / 6, Vector3f(0, 0, 1));
18 auto f =
newtons(Vector3f(1, 0, 0));
19 REQUIRE((f[0] /
N).to_number() == 1.0);
20 REQUIRE((f[1] /
N).to_number() == 0.0);
21 REQUIRE((f[2] /
N).to_number() == 0.0);
22 auto f2 = r.toRotationMatrix() * f;
23 REQUIRE((f2[0] /
N).to_number() == Approx(cos(M_PI / 6)));
24 REQUIRE((f2[1] /
N).to_number() == Approx(sin(M_PI / 6)));
25 REQUIRE((f2[2] /
N).to_number() == 0.0);
26 auto d =
meters(Vector3f(0, 1, 0));
27 REQUIRE((d[0] /
m).to_number() == 0.0);
28 REQUIRE((d[1] /
m).to_number() == 1.0);
29 REQUIRE((d[2] /
m).to_number() == 0.0);
31 REQUIRE((v[0] / (
m /
s)).to_number() == Approx(0.0));
32 REQUIRE((v[1] / (
m /
s)).to_number() == Approx(0.4));
33 REQUIRE((v[2] / (
m /
s)).to_number() == Approx(0.0));
36 REQUIRE((d2[0] /
m).to_number() == Approx(0.0));
37 REQUIRE((d2[1] /
m).to_number() == Approx(2.2));
38 REQUIRE((d2[2] /
m).to_number() == Approx(0.0));
40 REQUIRE((e1/
J).to_number() == Approx(sin(M_PI / 6) * 2.2));
41 auto e2 = f2.cross(d2);
42 REQUIRE((e2[0]/
J).to_number() == Approx(0.0));
43 REQUIRE((e2[1]/
J).to_number() == Approx(0.0));
44 REQUIRE((e2[2]/
J).to_number() == Approx(cos(M_PI / 6) * 2.2));
constexpr auto N
Constant-expression symbol for N.
Single-precision dimensions and units.
constexpr auto s
Constant-expression symbol for s.
constexpr auto J
Constant-expression symbol for J.
constexpr auto meters(T v)
Produce dimensioned quantity from number of meters.
constexpr auto m
Constant-expression symbol for m.
Model of a statically dimensioned physical quantity.
Classes and functions supporting a model of physically dimensioned quantities.
constexpr auto newtons(T v)
Produce dimensioned quantity from number of newtons.