Files
Jungfraujoch/common/Coord.h
2025-10-20 20:43:44 +02:00

63 lines
1.6 KiB
C++

// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#ifndef INDEX_COORD_H
#define INDEX_COORD_H
#include <ostream>
#include <vector>
class Coord {
public:
float x,y,z;
Coord();
Coord(const float in[3]);
Coord(float x, float y, float z);
void swap(Coord& other) noexcept;
Coord operator+(const Coord &in) const;
Coord operator-(const Coord &in) const;
Coord operator*(float in) const;
Coord operator/(float in) const;
Coord operator-() const;
Coord& operator+=(const Coord &in);
Coord& operator-=(const Coord &in);
Coord& operator*=(float in);
Coord& operator/=(float in);
bool operator==(const Coord &other) const;
Coord operator%(const Coord &in) const; // Cross product
float operator*(const Coord &in) const; // Dot product
const float& operator[](int64_t val) const;
float& operator[](int64_t val);
float Length() const;
Coord Normalize() const;
friend std::ostream &operator<<( std::ostream &output, const Coord &in );
};
Coord operator*(float in1, const Coord& in2);
inline void swap(Coord& a, Coord& b) noexcept;
float angle_deg(const Coord &in1, const Coord &in2);
class RotMatrix {
float v[3][3];
public:
RotMatrix();
RotMatrix(float alpha, const Coord &dir);
Coord operator*(const Coord &in) const;
RotMatrix operator*(const RotMatrix &other) const;
RotMatrix invert() const;
RotMatrix transpose() const;
RotMatrix operator!() const;
std::vector<float> arr() const;
};
#endif //INDEX_COORD_H