File: FloatVector3D.cpp

package info (click to toggle)
bornagain 23.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 103,948 kB
  • sloc: cpp: 423,131; python: 40,997; javascript: 11,167; awk: 630; sh: 318; ruby: 173; xml: 130; makefile: 51; ansic: 24
file content (65 lines) | stat: -rw-r--r-- 1,395 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      Img3D/Type/FloatVector3D.cpp
//! @brief     Definitions
//!
//! @homepage  http://www.bornagainproject.org
//! @license   GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
//  ************************************************************************************************

#include "Img3D/Type/FloatVector3D.h"

namespace Img3D {

F3 F3fromR3(const R3& o)
{
    return {static_cast<float>(o.x()), static_cast<float>(o.y()), static_cast<float>(o.z())};
}

FloatRange::FloatRange(float r1, float r2)
    : min(qMin(r1, r2))
    , max(qMax(r1, r2))
{
}

float FloatRange::size() const
{
    return max - min;
}

float FloatRange::mid() const
{
    return (min + max) / 2;
}


F3Range::F3Range(FloatRange x_, FloatRange y_, FloatRange z_)
    : x(x_)
    , y(y_)
    , z(z_)
{
}

F3Range::F3Range(F3 _1, F3 _2)
    : x(FloatRange(_1.x(), _2.x()))
    , y(FloatRange(_1.y(), _2.y()))
    , z(FloatRange(_1.z(), _2.z()))
{
}

F3 F3Range::size() const
{
    return {x.size(), y.size(), z.size()};
}

F3 F3Range::mid() const
{
    return {x.mid(), y.mid(), z.mid()};
}

} // namespace Img3D