/*# --------------------------------------------------------------------- # # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image # pour la Sant�) # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton # Previous Authors : Laurent Guigues, Jean-Pierre Roux # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil # # This software is governed by the CeCILL-B license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL-B # license as circulated by CEA, CNRS and INRIA at the following URL # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html # or in the file LICENSE.txt. # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL-B license and that you accept its terms. # ------------------------------------------------------------------------ */ #include "vectorFunctions.h" #include //Constructor vectorFunctions::vectorFunctions() { } //Destructor vectorFunctions::~vectorFunctions() { } //--------------------------------------------------------------- //Copy Vector1 in Vector2 (double) void vectorFunctions::copyVector(std::vector*Vector1,std::vector*Vector2) { int size = Vector1->size(); Vector2->clear(); int i; if(size != 0) { for(i=0; ipush_back( (*Vector1)[i] ); } } } //--------------------------------------------------------------- //Copy Vector1 in Vector2 (int) void vectorFunctions::copyintVector(std::vector*Vector1,std::vector*Vector2) { int size = Vector1->size(); Vector2->clear(); int i; if( size != 0) { for(i=0; ipush_back( (*Vector1)[i] ); } } } //------------------------------------------------------------------------------------------------------------------------------------------ //Print 2 vectors of the same size void vectorFunctions::printVector(std::vector*Vector1,std::vector*Vector2) { int i; if( Vector1->size() == Vector2->size() ) { for(i=0; isize(); i++) { printf("\n v1(%d) = %f, v2(%d) = %f",i,(*Vector1)[i],i,(*Vector2)[i]); } } } //------------------------------------------------------------------------------------------------------------------------------------------ //Returns the average value of the vector double vectorFunctions::promVector(std::vector*Vector1, bool OnNormal) { int i; double suma = 0,prom; std::vector tempv; int size = Vector1->size(); if(size != 0) { if(OnNormal == false) { for(i=0; isize(); } int pos; double maxval; copyVector(Vector1,&tempv); if(OnNormal == true) { pos = maxVector(Vector1,&maxval); for(i=0; i*Vector1,double *val) { int i, pos; double max = -1; if(Vector1->size() != 0) { for(i=0; isize(); i++) { if( (*Vector1)[i]>max ) { max = (*Vector1)[i]; pos = i; } } *val = max; return pos; } return -1; } //------------------------------------------------------------------------------------------------------------------------------------------ //Returns the minimum value of the vector int vectorFunctions::minVector(std::vector*Vector1,double *val) { int i, pos; double min = 99999; if(Vector1->size() != 0) { for(i=0; isize(); i++) { if( (*Vector1)[i]*VectorX, std::vector*VectorY, double px, double py) { int i, pos = -1; double min = 10000, dist; if(VectorX->size() != 0) { for(i=0; isize(); i++) { dist = sqrt(pow(px-(*VectorX)[i],2) + pow(py-(*VectorY)[i],2)); if(dist*vecX, std::vector*vecY, std::vector*vecZ, double x, double y, double z) { int i,flag = -1; double apr = 1.5; if(vecX->size() != 0) { for(i=0; isize(); i++) { if( ((*vecX)[i]-apr <= x)&&(x <=(*vecX)[i]+apr)&&((*vecY)[i]-apr <= y)&&(y <=(*vecY)[i]+apr)&&((*vecZ)[i]-apr <= z)&&(z <=(*vecZ)[i]+apr) ) { flag = i; return i; } } return flag; } return -1; }