/* * Copyright 2015-2020 Michele "King_DuckZ" Santullo * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "vectorwrapper/vectorwrapper.hpp" #include "vectorwrapper/size_type.hpp" #include #include #if defined VWR_OUTER_NAMESPACE namespace VWR_OUTER_NAMESPACE { #endif namespace vwr { template typename std::common_type::scalar_type, typename Vec::scalar_type>::type dot ( const Vec& parLeft, const Vec& parRight ); template typename std::common_type::scalar_type, typename Vec::scalar_type>::type cross ( const Vec& parLeft, const Vec& parRight ); template Vec::type> cross ( const Vec& parLeft, const Vec& parRight ); template Vec::type> min ( const Vec& parLeft, const Vec& parRight ); template Vec::type> max ( const Vec& parLeft, const Vec& parRight ); namespace implem { template inline Vec::type> min ( bt::number_seq, const Vec& parLeft, const Vec& parRight ) { return {parLeft[Indices] < parRight[Indices] ? parLeft[Indices] : parRight[Indices]...}; } template inline Vec::type> max ( bt::number_seq, const Vec& parLeft, const Vec& parRight ) { return {parLeft[Indices] < parRight[Indices] ? parRight[Indices] : parLeft[Indices]...}; } } //namespace implem template inline typename std::common_type::scalar_type, typename Vec::scalar_type>::type dot (const Vec& parLeft, const Vec& parRight) { auto retval = parLeft.x() * parRight.x(); for (size_type z = 1; z < S; ++z) { retval += parLeft[z] * parRight[z]; } return retval; } template inline typename std::common_type::scalar_type, typename Vec::scalar_type>::type cross (const Vec& parLeft, const Vec& parRight) { return parLeft.x() * parRight.y() - parLeft.y() * parRight.x(); } template inline Vec::type> cross (const Vec& parLeft, const Vec& parRight) { return Vec::type>( parLeft.y() * parRight.z() - parLeft.z() * parRight.y(), parLeft.z() * parRight.x() - parLeft.x() * parRight.z(), parLeft.x() * parRight.y() - parLeft.y() * parRight.x() ); } template inline Vec::type> min ( const Vec& parLeft, const Vec& parRight ) { return implem::min(bt::number_range(), parLeft, parRight); } template inline Vec::type> max ( const Vec& parLeft, const Vec& parRight ) { return implem::max(bt::number_range(), parLeft, parRight); } } //namespace vwr #if defined VWR_OUTER_NAMESPACE } //namespace VWR_OUTER_NAMESPACE #endif