Changeset 4496


Ignore:
Timestamp:
08/04/04 16:57:28 (20 years ago)
Author:
merck
Message:
MMerck: Code to calculate spot position to floating point accuracy.
Location:
trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol/videospot.cpp

    r4176 r4496  
    1818#include "videospot.h"
    1919#include "stdlib.h"
     20#include "math.h"
    2021
    2122VideoSpot::VideoSpot()
     
    2728}
    2829
    29 VideoSpot::VideoSpot( int p_iX, int p_iY )
     30VideoSpot::VideoSpot( double p_dX, double p_dY, int p_iNumPixel )
    3031{
    31         m_iNumPixel = 10;
    32         m_iXSum = p_iX;
    33         m_iYSum = p_iY;
    34         m_iWSum = 1;
     32        m_iNumPixel = p_iNumPixel;
     33        m_iXSum = (int) rint(p_dX * 100.);
     34        m_iYSum = (int) rint(p_dY * 100.);
     35        m_iWSum = 100;
     36}
     37
     38VideoSpot::VideoSpot( const VideoSpot& p_Spot )
     39{
     40        m_iNumPixel = p_Spot.m_iNumPixel;
     41        m_iXSum = p_Spot.m_iXSum;
     42        m_iYSum = p_Spot.m_iYSum;
     43        m_iWSum = p_Spot.m_iWSum;
     44}
     45
     46VideoSpot& VideoSpot::operator=( const VideoSpot& p_Spot )
     47{
     48  if (this == &p_Spot) return *this;   // Gracefully handle self assignment
     49
     50        this->m_iNumPixel = p_Spot.m_iNumPixel;
     51        this->m_iXSum = p_Spot.m_iXSum;
     52        this->m_iYSum = p_Spot.m_iYSum;
     53        this->m_iWSum = p_Spot.m_iWSum;
     54        return *this;
    3555}
    3656
     
    4262bool VideoSpot::contains( int p_iX, int p_iY )
    4363{
    44         if( ( abs( p_iX - getX() ) < 10 )
     64        if( ( fabs( p_iX - getX() ) < 10. )
    4565                        &&
    46                         ( abs( p_iY - getY() ) < 10 ) )
     66                        ( fabs( p_iY - getY() ) < 10. ) )
    4767                return true;
    4868        else
     
    5373bool VideoSpot::contains2( int p_iX, int p_iY )
    5474{
    55         if( ( abs( p_iX - getX() ) < 25 )
     75        if( ( fabs( p_iX - getX() ) < 25. )
    5676                        &&
    57                         ( abs( p_iY - getY() ) < 25 ) )
     77                        ( fabs( p_iY - getY() ) < 25. ) )
    5878                return true;
    5979        else
     
    6484void VideoSpot::append( int p_iX, int p_iY, int p_iWeight )
    6585{
    66 //      if( contains( p_iX , p_iY  ) )
    67 //              m_glPixels.append( new VideoPixel( p_iX, p_iY, p_iWeight ) );
    68                 m_iXSum += p_iX * p_iWeight;
    69                 m_iYSum += p_iY * p_iWeight;
    70                 m_iWSum += p_iWeight;
    71                 m_iNumPixel++;
     86        m_iXSum += p_iX * p_iWeight;
     87        m_iYSum += p_iY * p_iWeight;
     88        m_iWSum += p_iWeight;
     89        m_iNumPixel++;
    7290}
    7391
    7492/** No descriptions */
    75 int VideoSpot::getX()
     93double VideoSpot::getX()
    7694{
    77         return ( m_iXSum / m_iWSum );
     95        return ( (double) m_iXSum / (double) m_iWSum );
    7896}
    7997
    8098/** No descriptions */
    81 int VideoSpot::getY()
     99double VideoSpot::getY()
    82100{
    83         return ( m_iYSum / m_iWSum );
     101        return ( (double) m_iYSum / (double) m_iWSum );
    84102}
    85103/** No descriptions */
  • trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol/videospot.h

    r4175 r4496  
    2929public:
    3030        VideoSpot();
    31         VideoSpot(  int p_iX, int p_iY  );
     31        VideoSpot(  double p_iX, double p_iY, int p_iNumPixel  );
     32
     33  VideoSpot( const VideoSpot& p_Spot );
     34  VideoSpot& operator=( const VideoSpot& p_Spot );
     35
    3236        virtual ~VideoSpot();
    3337  /** No descriptions */
     
    3842  virtual void append( int p_iX, int p_iY, int p_iWeight );
    3943  /** No descriptions */
    40   virtual int getX();
     44  virtual double getX();
    4145  /** No descriptions */
    42   virtual int getY();
     46  virtual double getY();
     47  /** No descriptions */
     48  virtual int getNumPixel() { return m_iNumPixel; }
    4349  /** No descriptions */
    4450  virtual bool isValid();
    45 public: // Public attributes
    46   /**  */
    47 //  QList<VideoPixel> m_qlPixels;
     51
    4852private: // Private attributes
    4953  /**  */
     
    5155  /**  */
    5256  int m_iYSum;
    53 public: // Public attributes
    5457  /**  */
    5558  int m_iNumPixel;
Note: See TracChangeset for help on using the changeset viewer.