https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Euler2RGBTest.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#include "gtest/gtest.h"
11
12// Moose includes
13#include "Euler2RGB.h"
14
15TEST(Euler2RGBTest, test)
16{
17 const unsigned int nsamples = 23;
18
19 struct Samples
20 {
21 Real phi1, phi, phi2;
22 unsigned int phase, sym;
23 Real expect[3];
24 } samples[nsamples] = {
25 // symmetries 43 62 42 32 22 2 0
26 {0.1, 1.5, 0.7, 1, 43, {6225789, 16738084, 5635933}},
27 {2.1, 2.5, 1.4, 1, 43, {2251519, 10534399, 9240454}},
28 {5.9, 0.5, 4.4, 1, 43, {7536546, 3112447, 16776397}},
29
30 {0.1, 1.5, 0.7, 1, 62, {5422335, 16729118, 4521910}},
31 {2.1, 2.5, 1.4, 1, 62, {16711664, 9043825, 16756345}},
32 {5.9, 0.5, 4.4, 1, 62, {7012242, 14211583, 16740231}},
33
34 {0.1, 1.5, 0.7, 1, 42, {4609535, 16729625, 3889663}},
35 {2.1, 2.5, 1.4, 1, 42, {12264959, 9406975, 16759651}},
36 {5.9, 0.5, 4.4, 1, 42, {6648831, 11091455, 16746350}},
37
38 {0.1, 1.5, 0.7, 1, 32, {5353983, 16729877, 4027391}},
39 {2.1, 2.5, 1.4, 1, 32, {13929983, 8604927, 16761430}},
40 {5.9, 0.5, 4.4, 1, 32, {6487904, 12844963, 16736146}},
41
42 {0.1, 1.5, 0.7, 1, 22, {5963751, 16730129, 4908543}},
43 {2.1, 2.5, 1.4, 1, 22, {16774907, 10603519, 16762950}},
44 {5.9, 0.5, 4.4, 1, 22, {7919615, 14876658, 16751694}},
45
46 {0.1, 1.5, 0.7, 1, 2, {4980617, 16730380, 4325278}},
47 {2.1, 2.5, 1.4, 1, 2, {14155669, 9961385, 16764465}},
48 {5.9, 0.5, 4.4, 1, 2, {7185663, 12357375, 16725925}},
49
50 // phase 0 or unknown sym
51 {0.1, 1.5, 0.7, 0, 2, {0, 0, 0}},
52 {2.1, 2.5, 1.4, 1, 0, {0, 0, 0}},
53
54 // out of bounds angle
55 {6.9, 0.5, 4.4, 1, 2, {0, 0, 0}},
56 {5.9, 4.5, 4.4, 1, 2, {0, 0, 0}},
57 {5.9, 0.5, 8.4, 1, 2, {0, 0, 0}}
58
59 // TODO: negative angles are not checked yet!
60 };
61
62 for (unsigned int i = 0; i < nsamples; ++i)
63 for (unsigned int sd = 1; i <= 3; ++i)
64 {
65 Point RGB = euler2RGB(
66 sd, samples[i].phi1, samples[i].phi, samples[i].phi2, samples[i].phase, samples[i].sym);
67
68 Real RGBint = 0.0;
69 for (unsigned int j = 0; j < 3; ++j)
70 RGBint = 256 * RGBint + (RGB(j) >= 1 ? 255 : std::floor(RGB(j) * 256.0));
71
72 EXPECT_NEAR(samples[i].expect[sd - 1], RGBint, 0.00001) << "case " << i + 1 << " failed";
73 }
74}
TEST(Euler2RGBTest, test)
Point euler2RGB(unsigned int sd, Real phi1, Real PHI, Real phi2, unsigned int phase, unsigned int sym)
This function rotates a set of three Bunge Euler angles into the standard Stereographic triangle,...
Definition Euler2RGB.C:46