PSSource.cpp
Go to the documentation of this file.
00001 /*********************************************************************
00002 *
00003 * Software License Agreement (BSD License)
00004 *
00005 *  Copyright (c) 2010, ISR University of Coimbra.
00006 *  All rights reserved.
00007 *
00008 *  Redistribution and use in source and binary forms, with or without
00009 *  modification, are permitted provided that the following conditions
00010 *  are met:
00011 *
00012 *   * Redistributions of source code must retain the above copyright
00013 *     notice, this list of conditions and the following disclaimer.
00014 *   * Redistributions in binary form must reproduce the above
00015 *     copyright notice, this list of conditions and the following
00016 *     disclaimer in the documentation and/or other materials provided
00017 *     with the distribution.
00018 *   * Neither the name of the ISR University of Coimbra nor the names of its
00019 *     contributors may be used to endorse or promote products derived
00020 *     from this software without specific prior written permission.
00021 *
00022 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033 *  POSSIBILITY OF SUCH DAMAGE.
00034 *
00035 * Author: Gonçalo Cabrita and Pedro Sousa on 02/15/2010
00036 *********************************************************************/
00037 #include <string.h>
00038 #include <stdio.h>
00039 #include <math.h>
00040 #include <cstdlib>
00041 
00042 #include "PSSources.h"
00043 
00044 // *****************************************************************************
00045 // Constructor.
00046 plumesim::PSSource::PSSource()
00047 {
00048         // Nothing...
00049 }
00050 
00051 // *****************************************************************************
00052 // Destructor.
00053 plumesim::PSSource::~PSSource()
00054 {
00055         // Clean up...
00056 }
00057 
00058 // *****************************************************************************
00059 // Setup routine.
00060 int plumesim::PSSource::setup()
00061 {
00062         return 0;
00063 }
00064 
00065 // *****************************************************************************
00066 // Cleanup routine.
00067 int plumesim::PSSource::cleanup()
00068 {
00069         return 0;
00070 }
00071 
00072 // *****************************************************************************
00073 // Generate points.
00074 int plumesim::PSSource::generatePoints()
00075 {
00076         return 0;
00077 }
00078 
00079 // *****************************************************************************
00080 // Sends the chemical reading for a given position.
00081 int plumesim::PSSource::getChemicalReading(PSPoint3d * point, PSOdorData * odor_data)
00082 {
00083         return 0;
00084 }
00085 
00086 // *****************************************************************************
00087 // If the class is time invariant or not.
00088 bool plumesim::PSSource::ChangesOverTime()
00089 {
00090         return changesOverTime;
00091 }
00092 
00093 // *****************************************************************************
00094 // If the class is still processing data.
00095 bool plumesim::PSSource::IsPlaying()
00096 {
00097         return isPlaying;
00098 }
00099 
00100 // *****************************************************************************
00101 // Uniform distribution, [0 ... 1]
00102 float plumesim::PSSource::drand()
00103 {
00104         return ((rand()+1.0)/(RAND_MAX+1.0));
00105 }
00106 
00107 // *****************************************************************************
00108 // Normal distribution, centered on 0, std dev 1
00109 double plumesim::PSSource::randomNormal()
00110 {
00111         return (sqrt(-2*log(drand()))*cos(2*M_PI*drand()));
00112 }
00113 
00114 // *****************************************************************************
00115 // Count the points in a sphere
00116 int plumesim::PSSource::countPoints(PSPoint3d * center, double radius)
00117 {       
00118         int pointCount = 0;
00119         for(int i=0 ; i<plumePoints.size() ; i++)
00120         {
00121                 if(sqrt((center->px - plumePoints[i].px)*(center->px - plumePoints[i].px) + (center->py - plumePoints[i].py)*(center->py - plumePoints[i].py) + (center->pz - plumePoints[i].pz)*(center->pz - plumePoints[i].pz)) <= radius) pointCount++;
00122         }
00123         return pointCount;
00124 }
00125 
00126 // EOF
00127 


plumesim
Author(s): Gonçalo Cabrita and Pedro Sousa
autogenerated on Mon Jan 6 2014 11:27:16