⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 point.h

📁 Bubble Oscillation Algorithm. It is used to implement balancing load traffic, which is similar to wh
💻 H
字号:
//////////////////////////////////////////////////////////////////////
//  Title:        Geographic Load Balancing for Cellular Networks 
//		          by emulating the behavior of air bubbles 
//
//  Description:  This project is for dynamically balancing the traffic load 
//                  over a cellular network with fully adaptive antennas by 
//		    emulating the behaviours of a bubble array. Since 
//                  we assume fully adaptive base station antenna in this  
//                  version, antenna agent and simulator are not needed. 
//
//  Copyright:    Copyright (c) 2003
//  Company:      Elec. Eng. Dept., Queen Mary, University of London
//  @author       Lin Du (lin.du@elec.qmul.ac.uk)
//  @version      1.0
//
//////////////////////////////////////////////////////////////////////

#if !defined(Point_H_INCLUDED)
#define Point_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <math.h>

const double M_PI = 3.14159265;

class Point {
public:
	Point();
	Point(double X, double Y);

	double getX() const;
	double getY() const;

	void set(double X, double Y);
	void set(const Point &p);

  // Return distance between two point
  double static distance(const double X1, const double Y1, const double X2, const double Y2) {
    return sqrt((Y1-Y2) * (Y1-Y2) + (X1-X2) * (X1-X2));
  }
	double distance(double X, double Y) const;
	double distance(const Point &p) const;
  // Return the square of distance, for performance consideration.
	double distance2(const double X1, const double Y1, const double X2, const double Y2) const;
	double distance2(double X, double Y) const;
	double distance2(const Point &p) const;

  // Return the angle(from first/this point to second point) in degree
  double static Point::angle(const double X1, const double Y1, const double X2, const double Y2) {
    double ang = rad2Deg(atan2(Y2-Y1, X2-X1));
    if (ang < 0) ang += 360.0;
    return ang;
  }
	double angle(double X, double Y) const;
	double angle(const Point &p) const;

  // Convert the angle from radian to degree.
  double static Point::rad2Deg(const double rad) {
	  return rad*180.0/M_PI;
  }
  // Convert the angle from degree to radian.
  double static Point::deg2Rad(const double deg) {
	  return deg*M_PI/180.0;
  }

	// The following two methods are defined for vectors
	// Return the angle from zero point to this point) in degree
	double angle() const;
	// Return the magnitude of the point ( equal to the distance to the point(0,0) )
	double magnitude() const; 

  friend bool operator>(const Point &p1, const Point &p2);
  friend bool operator<(const Point &p1, const Point &p2);

  friend Point operator+(const Point &p1, const Point &p2);
  friend Point operator-(const Point &p1, const Point &p2);
  friend Point operator*(const Point &p1, const double val);
  friend Point operator/(const Point &p1, const double val);
  Point& operator+=(const Point &p1);
  Point& operator-=(const Point &p1);
  Point& operator*=(const double val);
  Point& operator/=(const double val);

private: 
	double dX;
	double dY;
};

#endif //!defined(Point_H_INCLUDED)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -