-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtriangle.h
More file actions
executable file
·53 lines (46 loc) · 2.44 KB
/
triangle.h
File metadata and controls
executable file
·53 lines (46 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//======================================================================================
/** \file triangle.h
* This file contains methods and constructor for a class that triangulates position.
*
* Revisions:
* \li 6-01-08 JBC&MR created file base off of control.h
* \li 6-01-08 BC&MR tested and finished methods
* License:
* This file released under the Lesser GNU Public License. The program is intended
* for educational use only, but its use is not restricted thereto.
*/
//======================================================================================
#ifndef _TRIANGLE_ // To prevent *.h file from being included in a source file more than once
#define _TRIANGLE_
#include <stdlib.h> // Include standard library header files
#include <avr/io.h>
#include "rs232.h" // Include header for serial port class
//-------------------------------------------------------------------------------------
/** \brief Converts local coordinates and angles to global coordinates, and vice versa.
*
* This class converts local coords and angle to global x-y-coords and the other way with the help of lookuptables.
* Just pass global_to_angle the x-y- coords and receive an angle in degrees. Or:
* Pass angle_to_global a boolean variable (true for receiving the x-coord and false for receiving the y-coord) and
* an angle in degrees and a distance (e.g. in tiles)
*/
class triangle
{
protected:
base_text_serial* ptr_to_serial; //!< Debug serial port
int cam_pos_x; //!< x-value of global position of camera standard
int cam_pos_y; //!< y-value of global position of camera standard
int cam_init_angle; //!< the angle the camera is facing at initialization
public:
// This constructor sets up the triangulation. The constructor is passed the serial port
triangle (base_text_serial*);
// Sets position of cam
void set_position(int, int, int);
// Here you can get the position of the cam again, written for radio task, to send the coords, too
int get_position(bool);
// This method allows a program to compute a angle from a global coordinate
int global_to_angle (signed int, signed int);
// This method allows a program to compute a global x or y from an angle and distance
// If the first variable is true, then you'll get the x-value, else the y-value
int angle_to_global (bool, signed int, signed int);
};
#endif