PLaSK library

Loading...
Searching...
No Matches
common.hpp
Go to the documentation of this file.
1/*
2 * This file is part of PLaSK (https://plask.app) by Photonics Group at TUL
3 * Copyright (c) 2022 Lodz University of Technology
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14#ifndef PLASK__VECTOR__COMMON_H
15#define PLASK__VECTOR__COMMON_H
16
21 namespace plask {
22
23
25 template <int dim, typename T=double>
26 struct Vec {};
27
32 template <int dim, typename T, int i>
33 struct VecComponent {
34
35 static const int DIMS = dim;
36
37 T c[dim];
38
43 VecComponent<dim,T,i>& operator=(const T& val) { c[i] = val; return *this; }
44
48 operator T() const { return c[i]; }
49};
50
51
52 namespace axis {
53 const std::size_t lon_index = 0;
54 const std::size_t tran_index = 1;
55 const std::size_t up_index = 2;
56} // axis
57
58/*
59 * Rotate @p r over up axis to lie on lon-tran plane.
60 * @param r cuboid
61 * @return rectangle
62 */
69} // namespace plask
70
71#endif // PLASK__VECTOR__COMMON_H