Stellarium 0.12.3
InterpolatedPosition.hpp
1 /*
2  * Stellarium Telescope Control Plug-in
3  *
4  * Copyright (C) 2006 Johannes Gajdosik
5  * Copyright (C) 2009-2010 Bogdan Marinov
6  *
7  * This module was originally written by Johannes Gajdosik in 2006
8  * as a core module of Stellarium. In 2009 it was significantly extended with
9  * GUI features and later split as an external plug-in module by Bogdan Marinov.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
24  */
25 
26 #ifndef _INTERPOLATED_POSITION_HPP_
27 #define _INTERPOLATED_POSITION_HPP_
28 
29 #ifndef INT64_MAX
30 #define INT64_MAX 0x7FFFFFFFFFFFFFFFLL
31 #endif
32 
33 #include "VecMath.hpp"
34 
37 struct Position
38 {
39  qint64 server_micros;
40  qint64 client_micros;
41  Vec3d pos;
42  int status;
43 };
44 
46 public:
49 
50  void add(Vec3d& position, qint64 clientTime, qint64 serverTime, int status = 0);
52  Vec3d get(qint64 time) const;
54  void reset();
55  bool isKnown() const {return (position_pointer->client_micros != INT64_MAX);}
56 
57 private:
58  Position positions[16];
59  Position *position_pointer;
60  Position *const end_position;
61 };
62 
63  #endif //_INTEPOLATED_POSITION_HPP_