### [REFAC] moved method from class to separate namespace

parent 3b3a2a0d
 ... ... @@ -382,7 +382,7 @@ std::pair WMPickingDVR::calculateIntervalsWYSIWYP( const std::vector vecFirstDerivative; std::vector vecSecondDerivative; calculateDerivativesWYSIWYP( vecAlphaAcc, vecFirstDerivative, vecSecondDerivative ); PickingDVRHelper::calculateDerivativesWYSIWYP( vecAlphaAcc, vecFirstDerivative, vecSecondDerivative ); // Upper bounds temporary variable ... will not be returned std::vector vecIndicesUpperBounds; ... ... @@ -436,118 +436,6 @@ std::pair WMPickingDVR::calculateIntervalsWYSIWYP( const std::vector& values, std::vector& vecFirstDerivative, std::vector& vecSecondDerivative ) { //Fourth Order Finite Differencing by Daniel Gerlicher unsigned int n = values.size(); double deriv = 0.0; double coeff = 1.0 / 12.0; //Calculate first derivative for( unsigned int j = 0; j < n; j++ ) { //Forward Diff if( j == 0 ) { deriv = coeff * ( -25 * values[j] + 48 * values[j+1] - 36 * values[j+2] + 16 * values[j+3] - 3 * values[j+4] ); } else if( j == 1 ) { deriv = coeff * ( -3 * values[j-1] - 10 * values[j] + 18 * values[j+1] - 6 * values[j+2] + 1 * values[j+3] ); } //Backward Diff else if( j == n - 1 ) { deriv = coeff * ( 25 * values[j] - 48 * values[j-1] + 36 * values[j-2] - 16 * values[j-3] + 3 * values[j-4] ); } else if( j == n - 2 ) { deriv = coeff * ( +3 * values[j+1] + 10 * values[j] - 18 * values[j-1] + 6 * values[j-2] - 1 * values[j-3] ); } //Center else { deriv = coeff * ( -1 * values[j+2] + 8 * values[j+1] - 8 * values[j-1] + 1 * values[j-2] ); } vecFirstDerivative.push_back( deriv ); } //Calculate Second derivative, by applying the first derivative for( unsigned int j = 0; j < n; j++ ) { //Forward Diff if( j == 0 ) { deriv = coeff * ( -25 * vecFirstDerivative[j] + 48 * vecFirstDerivative[j+1] - 36 * vecFirstDerivative[j+2] + 16 * vecFirstDerivative[j+3] - 3 * vecFirstDerivative[j+4] ); } else if( j == 1 ) { deriv = coeff * ( -3 * vecFirstDerivative[j-1] - 10 * vecFirstDerivative[j] + 18 * vecFirstDerivative[j+1] - 6 * vecFirstDerivative[j+2] + 1 * vecFirstDerivative[j+3] ); } //Backward Diff else if( j == n - 1 ) { deriv = coeff * ( 25 * vecFirstDerivative[j] - 48 * vecFirstDerivative[j-1] + 36 * vecFirstDerivative[j-2] - 16 * vecFirstDerivative[j-3] + 3 * vecFirstDerivative[j-4] ); } else if( j == n - 2 ) { deriv = coeff * ( +3 * vecFirstDerivative[j+1] + 10 * vecFirstDerivative[j] - 18 * vecFirstDerivative[j-1] + 6 * vecFirstDerivative[j-2] - 1 * vecFirstDerivative[j-3] ); } //Center else { deriv = coeff * ( -1 * vecFirstDerivative[j+2] + 8 * vecFirstDerivative[j+1] - 8 * vecFirstDerivative[j-1] + 1 * vecFirstDerivative[j-2] ); } vecSecondDerivative.push_back( deriv ); } } void WMPickingDVR::updatePositionIndicator( osg::Vec3f position ) { osg::ref_ptr< osg::Geometry > geometry; ... ...
 ... ... @@ -133,17 +133,6 @@ private: std::pair calculateIntervalsWYSIWYP( const std::vector& vecAlphaAcc, std::vector& vecIndicesLowerBounds ); /** * Computes the first and second derivatives of a vector of values * * \param values Values for which the derivatives will be computed * \param vecFirstDerivative The first derivative of the values * \param vecSecondDerivative The second derivative of the values */ void calculateDerivativesWYSIWYP( const std::vector& values, std::vector& vecFirstDerivative, std::vector& vecSecondDerivative ); /** * Set the new position of the graphical representation * of the picked position. ... ...
 //--------------------------------------------------------------------------- // // Project: OpenWalnut ( http://www.openwalnut.org ) // // Copyright 2017 OpenWalnut Community // For more information see http://www.openwalnut.org/copying // // This file is part of OpenWalnut. // // OpenWalnut is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // OpenWalnut is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with OpenWalnut. If not, see . // //--------------------------------------------------------------------------- #include #include "WMPickingDVRHelper.h" namespace PickingDVRHelper { /** * Computes the first and second derivatives of a vector of values * * \param values Values for which the derivatives will be computed * \param vecFirstDerivative The first derivative of the values * \param vecSecondDerivative The second derivative of the values */ void calculateDerivativesWYSIWYP( const std::vector& values, std::vector& vecFirstDerivative, std::vector& vecSecondDerivative ) { //Fourth Order Finite Differencing by Daniel Gerlicher unsigned int n = values.size(); double deriv = 0.0; double coeff = 1.0 / 12.0; //Calculate first derivative for( unsigned int j = 0; j < n; j++ ) { //Forward Diff if( j == 0 ) { deriv = coeff * ( -25 * values[j] + 48 * values[j+1] - 36 * values[j+2] + 16 * values[j+3] - 3 * values[j+4] ); } else if( j == 1 ) { deriv = coeff * ( -3 * values[j-1] - 10 * values[j] + 18 * values[j+1] - 6 * values[j+2] + 1 * values[j+3] ); } //Backward Diff else if( j == n - 1 ) { deriv = coeff * ( 25 * values[j] - 48 * values[j-1] + 36 * values[j-2] - 16 * values[j-3] + 3 * values[j-4] ); } else if( j == n - 2 ) { deriv = coeff * ( +3 * values[j+1] + 10 * values[j] - 18 * values[j-1] + 6 * values[j-2] - 1 * values[j-3] ); } //Center else { deriv = coeff * ( -1 * values[j+2] + 8 * values[j+1] - 8 * values[j-1] + 1 * values[j-2] ); } vecFirstDerivative.push_back( deriv ); } //Calculate Second derivative, by applying the first derivative for( unsigned int j = 0; j < n; j++ ) { //Forward Diff if( j == 0 ) { deriv = coeff * ( -25 * vecFirstDerivative[j] + 48 * vecFirstDerivative[j+1] - 36 * vecFirstDerivative[j+2] + 16 * vecFirstDerivative[j+3] - 3 * vecFirstDerivative[j+4] ); } else if( j == 1 ) { deriv = coeff * ( -3 * vecFirstDerivative[j-1] - 10 * vecFirstDerivative[j] + 18 * vecFirstDerivative[j+1] - 6 * vecFirstDerivative[j+2] + 1 * vecFirstDerivative[j+3] ); } //Backward Diff else if( j == n - 1 ) { deriv = coeff * ( 25 * vecFirstDerivative[j] - 48 * vecFirstDerivative[j-1] + 36 * vecFirstDerivative[j-2] - 16 * vecFirstDerivative[j-3] + 3 * vecFirstDerivative[j-4] ); } else if( j == n - 2 ) { deriv = coeff * ( +3 * vecFirstDerivative[j+1] + 10 * vecFirstDerivative[j] - 18 * vecFirstDerivative[j-1] + 6 * vecFirstDerivative[j-2] - 1 * vecFirstDerivative[j-3] ); } //Center else { deriv = coeff * ( -1 * vecFirstDerivative[j+2] + 8 * vecFirstDerivative[j+1] - 8 * vecFirstDerivative[j-1] + 1 * vecFirstDerivative[j-2] ); } vecSecondDerivative.push_back( deriv ); } } }
 ... ... @@ -2,7 +2,7 @@ // // Project: OpenWalnut ( http://www.openwalnut.org ) // // Copyright 2015 A. Betz, D. Gerlicher, OpenWalnut Community, Nemtics, BSV@Uni-Leipzig // Copyright 2015-2017 A. Betz, D. Gerlicher, OpenWalnut Community // For more information see http://www.openwalnut.org/copying // // This file is part of OpenWalnut. ... ... @@ -25,6 +25,22 @@ #ifndef WMPICKINGDVRHELPER_H #define WMPICKINGDVRHELPER_H #include namespace PickingDVRHelper { /** * Computes the first and second derivatives of a vector of values * * \param values Values for which the derivatives will be computed * \param vecFirstDerivative The first derivative of the values * \param vecSecondDerivative The second derivative of the values */ void calculateDerivativesWYSIWYP( const std::vector& values, std::vector& vecFirstDerivative, std::vector& vecSecondDerivative ); } /** * Color converter for different scalings, i.e. [0,1] vs. [0,255] */ ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment