17#include "wuzp/trafo/internal/validity.hpp"
26template <
typename ValuesT_>
27ValuesT_ minkowskiMetric() {
28 auto result = identity<ValuesT_>();
29 for (
int index = 1; index < Rows<ValuesT_>::value; ++index) {
30 result.set(index, index,
typename ValuesT_::ValueT{-1});
55 :
public PassiveTransformation<LorentzTransformation<ValuesT_, ValueT_, FromT_, ToT_, DimensionV_>, FromT_, ToT_> {
71 template <
typename... Args>
74 internal::checkValidity(*
this,
"The matrix of a Lorentz transformation must preserve the Minkowski metric: Lambda^T eta Lambda = eta.");
79 template <
typename... Args>
89 const QuantitiesT metric{internal::minkowskiMetric<ValuesT>()};
99 const auto metric = internal::minkowskiMetric<ValuesT>();
100 const auto& values = quantities_.getValues();
101 return internal::maxAbsDifference(
ValuesT{values.transpose().innerProduct(metric.innerProduct(values))}, metric) <= tolerance;
106 template <
template <
typename,
int,
int>
typename ValuesOtherT_,
typename ValueOtherT_,
typename FromOtherT_,
typename ToOtherT_,
107 int DimensionOtherV_>
110 static_assert(internal::SameFrames<
LorentzTransformation, std::remove_cvref_t<
decltype(other)>>::value);
111 return quantities_.isApprox(other.
getQuantities(), precision);
124template <
template <
typename,
int,
int>
typename ValuesT_,
typename ValueT_,
typename FromT_,
typename ToT_,
int DimensionV_>
125struct IsChangeOfBasis<LorentzTransformation<ValuesT_, ValueT_, FromT_, ToT_, DimensionV_>> : std::true_type {};
129template <
template <
typename,
int,
int>
typename ValuesT_,
typename ValueT_,
typename FromT_,
typename ToT_>
131template <
template <
typename,
int,
int>
typename ValuesT_,
typename ValueT_,
typename FromT_,
typename ToT_>
133template <
template <
typename,
int,
int>
typename ValuesT_,
typename ValueT_,
typename FromT_,
typename ToT_>
138template <
template <
typename,
int,
int>
typename ValuesT_,
typename ValueT_,
typename FromT_,
typename ToT_,
int DimensionV_,
141 :
TransformationTraits<typename LorentzTransformation<ValuesT_, ValueT_, FromT_, ToT_, DimensionV_>::LinearTransformationT, Object> {};
144template <
template <
typename,
int,
int>
typename ValuesLhsT_,
typename ValueLhsT_,
typename FromLhsT_,
typename ToLhsT_,
int DimensionLhsV_,
145 template <
typename,
int,
int>
typename ValuesRhsT_,
typename ValueRhsT_,
typename FromRhsT_,
typename ToRhsT_,
int DimensionRhsV_>
157template <
template <
typename,
int,
int>
typename ValuesLhsT_,
typename ValueLhsT_,
typename FromLhsT_,
typename ToLhsT_,
int DimensionLhsV_,
158 template <
typename,
int,
int>
typename ValuesRhsT_,
typename ValueRhsT_,
typename FromRhsT_,
typename ToRhsT_,
int DimensionRhsV_,
159 typename... UnitsRhsT_>
162 :
CompositionTraits<typename LorentzTransformation<ValuesLhsT_, ValueLhsT_, FromLhsT_, ToLhsT_, DimensionLhsV_>::LinearTransformationT,
163 PassiveLinearTransformation<ValuesRhsT_, ValueRhsT_, FromRhsT_, ToRhsT_, DimensionRhsV_, UnitsRhsT_...>> {};
165template <
template <
typename,
int,
int>
typename ValuesLhsT_,
typename ValueLhsT_,
typename FromLhsT_,
typename ToLhsT_,
int DimensionLhsV_,
166 typename... UnitsLhsT_,
template <
typename,
int,
int>
typename ValuesRhsT_,
typename ValueRhsT_,
typename FromRhsT_,
167 typename ToRhsT_,
int DimensionRhsV_>
171 PassiveLinearTransformation<ValuesLhsT_, ValueLhsT_, FromLhsT_, ToLhsT_, DimensionLhsV_, UnitsLhsT_...>,
172 typename LorentzTransformation<ValuesRhsT_, ValueRhsT_, FromRhsT_, ToRhsT_, DimensionRhsV_>::LinearTransformationT> {};
174template <
template <
typename,
int,
int>
typename ValuesLhsT_,
typename ValueLhsT_,
typename FromLhsT_,
typename ToLhsT_,
int DimensionLhsV_,
175 template <
typename,
int,
int>
typename ValuesRhsT_,
typename ValueRhsT_,
typename FromRhsT_,
typename ToRhsT_,
int DimensionRhsV_>
178 static_assert(internal::SameFrames<std::remove_cvref_t<
decltype(lhs)>, std::remove_cvref_t<
decltype(rhs)>>::value);
182template <
template <
typename,
int,
int>
typename ValuesLhsT_,
typename ValueLhsT_,
typename FromLhsT_,
typename ToLhsT_,
int DimensionLhsV_,
183 template <
typename,
int,
int>
typename ValuesRhsT_,
typename ValueRhsT_,
typename FromRhsT_,
typename ToRhsT_,
int DimensionRhsV_>
186 return !(lhs == rhs);
189template <
template <
typename,
int,
int>
typename ValuesT_,
typename ValueT_,
typename FromT_,
typename ToT_,
int DimensionV_>
196template <
template <
typename,
int,
int>
typename ValuesT_,
typename ValueT_>
209template <
typename QuantitiesT_,
typename CoordinateSystemT_>
211 static_assert(internal::RejectBatch<Indices<Up>, QuantitiesT_>::value);
213 "getInvariant() computes the interval with the Minkowski metric, so the vector must be expressed in a Minkowski "
214 "coordinate system, e.g. CoordinateSystem<Spacetime, Minkowski>.");
217 return pow<2>(quantities.template get<0, 0>()) - quantities.template block<1, 0, dimension - 1, 1>().squaredNorm();
237template <
template <
typename,
int,
int>
typename ValuesT_,
typename ValueT_,
typename FromT_,
typename ToT_,
int DimensionV_>
246 if (!(squaredBeta.getValue() < 1)) {
247 throw std::invalid_argument(
"The magnitude of the velocity of a Lorentz boost must be smaller than the speed of light.");
249 const auto lorentzFactor{
pow<-1, 2>(QuantityT{ValueT_{1}} - squaredBeta)};
252 const auto spatialFactor{
pow<2>(lorentzFactor) /
254 QuantitiesT quantities;
256 for (
int row = 0; row < DimensionV_; ++row) {
257 for (
int col = 0; col < row + 1; ++col) {
261 quantity = lorentzFactor;
262 }
else if (col == 0) {
264 }
else if (col == row) {
265 quantity = QuantityT{ValueT_{1}} + spatialFactor *
pow<2>(velocity.
getQuantities().get(row - 1, 0));
269 quantities.set(row, col, quantity);
273 for (
int row = 0; row < DimensionV_; ++row) {
274 for (
int col = row + 1; col < DimensionV_; ++col) {
275 quantities.set(row, col, quantities.get(col, row));
const QuantitiesT & getQuantities() const &
The alias template ValueMatrix<ValueT_, RowsV_, ColsV_> of any value matrix backend,...
Whether constructing a Class from the arguments copies or moves it, i.e. whether they are a single Cl...
A coordinate system with the Minkowski metric, e.g. CoordinateSystem<Spacetime, Minkowski>: an inerti...
LorentzTransformation< ValuesT_, ValueT_, FromT_, ToT_, 3 > LorentzTransformation3
auto getSpeedOfLight()
The speed of light, as a quantity of the value matrix backend ValuesT_, e.g. getSpeedOfLight<wuzp_eig...
Quantities< ValueT_, TypeMatrixImpl< MatrixSize< 1, 1 >, std::tuple< UnitT_ > > > Quantity
Container to store a single quantity.
bool operator!=(const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs)
LorentzTransformation< ValuesT_, ValueT_, FromT_, ToT_, DimensionV_ > createBoostMatrix(const VelocityVector< DimensionV_ - 1, ValuesT_, ValueT_, FromT_ > &velocity)
The passive Lorentz boost from From to To, in the standard form with the time component first and in ...
std::ostream & operator<<(std::ostream &lhs, const Quantities< ValuesT_, UnitsT_ > &rhs)
Tensor< Indices< Up >, QuantityVectorT_, CoordinateSystemT_, Relative > Vector
auto innerProduct(const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs)
auto getInvariant(const Vector< QuantitiesT_, CoordinateSystemT_ > &vector)
The Minkowski interval eta_ij v^i v^j = v_0^2 - v_1^2 - ... - v_n^2 of a vector whose first component...
bool operator==(const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs)
LorentzTransformation< ValuesT_, ValueT_, FromT_, ToT_, 2 > LorentzTransformation2
auto pow(const Quantities< ValuesT_, UnitsT_ > &quantities)
The quantities raised to a rational power P/Q, elementwise, e.g. pow<Rational<1, 2>>(area) is a lengt...
LorentzTransformation< ValuesT_, ValueT_, FromT_, ToT_, 4 > LorentzTransformation4
HomogeneousVector< DimensionV_, ValuesT_, ValueT_, typename AccessUnits< AccessImplementation< ValueT_ > >::Velocity, CoordinateSystemT_ > VelocityVector
The units for values of the arithmetic type ValueT_, e.g. double, specialized for AccessImplementatio...
The composition lhs * rhs of two transformations, which applies rhs first, then lhs: (lhs * rhs)....
static constexpr ValueT_ value()
static constexpr ValueT_ value()