//+------------------------------------------------------------------+ //| Sphere.mqh | //| Copyright 2000-2025, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #include #include //+------------------------------------------------------------------+ //| Class CSphere. | //| Appointment: Class of the graphical object "Sphere". | //+------------------------------------------------------------------+ class CSphere : public CArrayObj { private: int m_id; // sphere idintifier color m_color; // sphere color int m_num_parallel; // number of parallels int m_num_meridian; // number of meridians int m_radius; // sphere radius in pixels int m_center_X; // coordinate of the center X int m_center_Y; // coordinate of the center Y CSphere *m_orbite_center; // "sun" double m_orbite_radius; // orbital radius double m_orbite_fi_X; // angle of inclination to the axis X double m_orbite_fi_Y; // angle of inclination to the axis Y double m_orbite_fi_Z; // angle of inclination to the axis Z double m_d_fi_orb; // angular velocity of the orbit //--- working variables double m_fi_orb; double m_fi_x; double m_fi_y; double m_fi_z; public: CSphere(void); ~CSphere(void); //--- methods of access to protected data int CenterX(void) const { return(m_center_X); } int CenterY(void) const { return(m_center_Y); } //--- bool Create(const int id,const color c,const int x,const int y,const int r,const int p,const int m,const string str); void SetOrbite(CSphere *sun,const double fi_x,const double fi_y,const double fi_z,const double d_fi_orb); void Recalculate(void); }; //+------------------------------------------------------------------+ //| Constructor | //+------------------------------------------------------------------+ CSphere::CSphere(void) : m_id(0), m_color(0), m_num_parallel(0), m_num_meridian(0), m_radius(0), m_center_X(0), m_center_Y(0), m_orbite_center(NULL), m_orbite_radius(0.0), m_orbite_fi_X(0.0), m_orbite_fi_Y(0.0), m_orbite_fi_Z(0.0), m_d_fi_orb(0.0), m_fi_orb(0.0), m_fi_x(0.0), m_fi_y(0.0), m_fi_z(0.0) { } //+------------------------------------------------------------------+ //| Destructor | //+------------------------------------------------------------------+ CSphere::~CSphere(void) { } //+------------------------------------------------------------------+ //| Create object | //+------------------------------------------------------------------+ bool CSphere::Create(const int id,const color c,const int x,const int y,const int r,const int p,const int m,const string str) { CArrayObj *arr; CChartObjectLabel *label; //--- m_id=id; m_color =c; m_num_parallel=(p>r/3) ? r/3 : p; m_num_meridian=(m>r/3) ? r/3 : m; m_radius =r; m_center_X =x; m_center_Y =y; if(!Reserve(p)) return(false); //--- loop parallels for(int i=0;i