00001 #ifndef OPENTISSUE_CORE_MATH_INTERVAL_INTERVAL_VECTOR_H 00002 #define OPENTISSUE_CORE_MATH_INTERVAL_INTERVAL_VECTOR_H 00003 // 00004 // OpenTissue Template Library 00005 // - A generic toolbox for physics-based modeling and simulation. 00006 // Copyright (C) 2008 Department of Computer Science, University of Copenhagen. 00007 // 00008 // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php 00009 // 00010 #include <OpenTissue/configuration.h> 00011 00012 #include <OpenTissue/core/math/math_vector3.h> 00013 00014 namespace OpenTissue 00015 { 00016 namespace math 00017 { 00018 namespace interval 00019 { 00020 00032 template<typename interval_type> 00033 inline interval_type operator*( OpenTissue::math::Vector3<interval_type > const & vi, OpenTissue::math::Vector3<typename interval_type::base_type > const & vr) 00034 { 00035 typedef typename interval_type::base_type T; 00036 //typedef typename interval_type::value_traits value_traits; // Argh!!! boost interval type do not have this:-( 00037 typedef typename math::ValueTraits<T> value_traits; 00038 00039 T x = vr[0]; 00040 T tmp_lower = (x< value_traits::zero() ? vi[0].upper() : vi[0].lower() ) * x; 00041 T tmp_upper = (x< value_traits::zero() ? vi[0].lower() : vi[0].upper() ) * x; 00042 00043 T y = vr[1]; 00044 tmp_lower += (y< value_traits::zero() ? vi[1].upper() : vi[1].lower() ) * y; 00045 tmp_upper += (y< value_traits::zero() ? vi[1].lower() : vi[1].upper() ) * y; 00046 00047 T z = vr[2]; 00048 tmp_lower += (z< value_traits::zero() ? vi[2].upper() : vi[2].lower() ) * z; 00049 tmp_upper += (z< value_traits::zero() ? vi[2].lower() : vi[2].upper() ) * z; 00050 00051 return interval_type(tmp_lower, tmp_upper); 00052 } 00053 00054 } // namespace interval 00055 } // namespace math 00056 } // namespace OpenTissue 00057 00058 // OPENTISSUE_CORE_MATH_INTERVAL_INTERVAL_VECTOR_H 00059 00060 #endif