Loading [MathJax]/extensions/TeX/AMSmath.js
ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Variables
_
a
b
c
f
g
i
k
m
n
o
p
r
s
w
Typedefs
a
b
c
d
e
f
g
h
i
l
m
o
p
q
t
v
Enumerations
Enumerator
d
h
m
n
r
s
t
Concepts
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
~
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
i
j
k
l
m
o
p
q
r
s
t
u
v
Enumerations
Enumerator
a
i
l
n
o
p
s
u
v
Related Symbols
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
v
w
Variables
a
b
c
g
h
i
m
p
s
t
u
v
w
Typedefs
Enumerations
Enumerator
Macros
c
d
f
g
h
i
k
m
n
o
p
q
r
s
t
u
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Concepts
Loading...
Searching...
No Matches
orthonormal_vec.hpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2010-2022 The ESPResSo project
3
*
4
* This file is part of ESPResSo.
5
*
6
* ESPResSo is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* ESPResSo is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#pragma once
21
22
#include "
utils/Vector.hpp
"
23
24
#include <cstddef>
25
#include <numbers>
26
27
namespace
Utils
{
28
/**
29
* @brief Return a vector that is orthonormal to vec
30
*/
31
template
<
typename
T, std::
size_t
N>
32
Vector<T, N>
calc_orthonormal_vector
(
Vector<T, N>
const
&vec) {
33
/* Calculate orthonormal vector using Gram-Schmidt orthogonalization of a
34
trial vector. Only works if the trial vector is not parallel, so we have to
35
try a second one in that case
36
*/
37
Vector<Vector<T, N>
, 2> try_vectors = {
Vector<T, N>::broadcast
(T(0)),
38
Vector<T, N>::broadcast
(T(0))};
39
try_vectors[0][0] = T(1);
40
try_vectors[1][1] = T(1);
41
42
Vector<T, N>
ret;
43
for
(
auto
v : try_vectors) {
44
auto
orth_component = v - (v * vec) / vec.
norm2
() * vec;
45
auto
norm = orth_component.
norm
();
46
if
(norm >= 1. / std::numbers::sqrt2) {
47
ret = orth_component / norm;
48
break
;
49
}
50
}
51
return
ret;
52
}
32
Vector<T, N>
calc_orthonormal_vector
(
Vector<T, N>
const
&vec) {
…
}
53
54
}
// namespace Utils
Vector.hpp
Vector implementation and trait types for boost qvm interoperability.
Utils::Vector
Definition
Vector.hpp:49
Utils::Vector::norm2
T norm2() const
Definition
Vector.hpp:138
Utils::Vector::norm
T norm() const
Definition
Vector.hpp:139
Utils::Vector::broadcast
static DEVICE_QUALIFIER constexpr Vector< T, N > broadcast(typename Base::value_type const &value) noexcept
Create a vector that has all entries set to the same value.
Definition
Vector.hpp:111
Utils
Definition
Variant.hpp:40
Utils::calc_orthonormal_vector
Vector< T, N > calc_orthonormal_vector(Vector< T, N > const &vec)
Return a vector that is orthonormal to vec.
Definition
orthonormal_vec.hpp:32
src
utils
include
utils
math
orthonormal_vec.hpp
Generated on Mon Apr 21 2025 01:14:21 for ESPResSo by
1.9.8