www.pudn.com > 人体步态跟踪识别bate版.rar > Position.cpp


// Position.cpp: implementation of the CPosition class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
#include "humantrack.h" 
#include "Position.h" 
#include "math.h" 
 
#ifdef _DEBUG 
#undef THIS_FILE 
static char THIS_FILE[]=__FILE__; 
#define new DEBUG_NEW 
#endif 
 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
 
CPosition::CPosition() 
{ 
 x = 0;  
 y = 0;  
 z = 0;  
 theta = 0; 
} 
CPosition::CPosition(double x1, double y1, double z1, double theta1) 
{ 
x = x1;  
y = y1;  
z = z1; 
theta = theta1; 
} 
CPosition::~CPosition() 
{ 
 
} 
 
double CPosition::distance(CPosition l) 
{ 
	if(l.x == 0 && l.y==0 && l.z==0 && l.theta==0)  
		return 0;  
	return sqrt(pow(x - l.x, 2) +pow(y - l.y, 2) +pow(z - l.z, 2)); 
} 
 
bool CPosition::equals(CPosition l) 
{ 
	if(l.x == 0 && l.y==0 && l.z==0 && l.theta==0)  
		return false; 
	 
	if(x == l.x && y == l.y && z == l.z &&theta == l.theta)  
		return true; 
	 
	return false; 
} 
 
void CPosition::setValue(double x1, double y1, double z1, double theta1) 
{ 
	 
	x = x1;  
	y = y1; 
	z = z1;  
	theta = theta1; 
} 
 
CString CPosition::toString() 
{ 
	CString s; 
	s.Format("[ %f,%f,%f,%f ]",x,y,z,theta); 
	return s; 
	//new CString("[" + x + ", " + y +", " + z + ", " + theta + "]"); 
} 
 
bool CPosition::IsEmpty() 
{ 
if (x=0 && y==0 && z==0 && theta==0) 
 return true; 
else 
return false; 
}