/*************************************************************************** * Copyright (C) gempa GmbH * * All rights reserved. * * Contact: gempa GmbH (seiscomp-dev@gempa.de) * * * * GNU Affero General Public License Usage * * This file may be used under the terms of the GNU Affero * * Public License version 3.0 as published by the Free Software Foundation * * and appearing in the file LICENSE included in the packaging of this * * file. Please review the following information to ensure the GNU Affero * * Public License version 3.0 requirements will be met: * * https://www.gnu.org/licenses/agpl-3.0.html. * * * * Other Usage * * Alternatively, this file may be used in accordance with the terms and * * conditions contained in a signed written agreement between you and * * gempa GmbH. * ***************************************************************************/ #ifndef SEISCOMP_MATH_MT_CONVERSIONS_H #define SEISCOMP_MATH_MT_CONVERSIONS_H #include #include #include namespace Seiscomp { namespace Math { struct NODAL_PLANE { double str; double dip; double rake; }; struct AXIS { double str; double dip; double val; int expo; }; /** * Calculates the strike and dip of an axis from a cartesian vector */ template void vec2angle(const Math::Vector3 &v, T &strike, T &dip); /** * Calculates the axis of a cartesian vector from strike and dip. */ template void angle2vec(T strike, T dip, Math::Vector3 &v); /** * Calculates the fault normal and slip vector from principle axis P and T */ template bool pa2nd(const Math::Vector3 &t, const Math::Vector3 &p, Math::Vector3 &n, Math::Vector3 &d); /** * Calculates principle axis P and T from fault normal and slip vector */ template bool nd2pa(const Math::Vector3 &n, const Math::Vector3 &d, Math::Vector3 &t, Math::Vector3 &p); /** * Calculates the nodal plane from the normal and slip vector of the fault plane. * The result is in radiants. */ template bool nd2np(const Math::Vector3 &n, const Math::Vector3 &d, NODAL_PLANE &np); /** * Calculates the the normal and slip vector of the fault plane * from a nodal plane. The nodal plane attributes are expected to be * in radiants. */ template bool np2nd(const NODAL_PLANE &np, Math::Vector3 &n, Math::Vector3 &d); /** * Calculates a tensor from fault normal and slip vector */ template bool nd2tensor(const Math::Vector3 &n, const Math::Vector3 &d, Math::Tensor2S &t); /** * Calculates a tensor from a nodal plane */ template bool np2tensor(const NODAL_PLANE &np, Math::Tensor2S &t); /** * Converts a nodal plane from radiants to degree */ void np2deg(NODAL_PLANE &np); /** * Computes the double couples from normal and slip vector */ template bool nd2dc(const Math::Vector3 &n, const Math::Vector3 &d, NODAL_PLANE *NP1, NODAL_PLANE *NP2); template void rtp2tensor(T mrr, T mtt, T mpp, T mrt, T mrp, T mtp, Math::Tensor2S &tensor); template double spectral2clvd(Math::Tensor2S &tensor); template void spectral2axis(const Math::Spectral2S &spec, AXIS &t, AXIS &n, AXIS &p, int expo); template void axis2spectral(const AXIS &t, const AXIS &n, const AXIS &p, int expo, Math::Spectral2S &spec); template void axis2tensor(const AXIS &t, const AXIS &n, const AXIS &p, int expo, Math::Tensor2S &tensor); template void spectral2matrix(const Math::Spectral2S &t, Math::Matrix3 &m); template bool tensor2matrix(const Math::Tensor2S &t, Math::Matrix3 &m); #include "conversions.ipp" } } #endif