Loading...
Searching...
No Matches
integer_vector_3d.hpp
Go to the documentation of this file.
1#pragma once
2
3/**
4 * IntegerVector3D: an integer 3D vector for Miller indices and FFT grid indices.
5 *
6 * Provides element access by index and equality comparison.
7 */
8
10
11namespace q3 {
12
13/// Integer 3-vector for Miller indices / FFT grid indices
14struct [[nodiscard]] IntegerVector3D {
15 int x{}, y{}, z{};
16 IntegerVector3D() = default;
17 constexpr IntegerVector3D(int x_component, int y_component, int z_component)
18 : x(x_component), y(y_component), z(z_component) {}
19 [[nodiscard]] int operator[](int component_index) const {
20 return (component_index == 0) ? x : (component_index == 1) ? y : z;
21 }
22 int& operator[](int component_index) {
23 return (component_index == 0) ? x : (component_index == 1) ? y : z;
24 }
25 [[nodiscard]] bool operator==(const IntegerVector3D& other) const {
26 return x == other.x && y == other.y && z == other.z;
27 }
28};
29
30} // namespace q3
Integer 3-vector for Miller indices / FFT grid indices.
bool operator==(const IntegerVector3D &other) const
int operator[](int component_index) const
constexpr IntegerVector3D(int x_component, int y_component, int z_component)
IntegerVector3D()=default
int & operator[](int component_index)