-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdrawing_functions.c
122 lines (100 loc) · 2.98 KB
/
drawing_functions.c
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
* This file is part of vis-o-mex.
*
* Copyright (C) 2010-2011 Greg Horn <ghorn@stanford.edu>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
* drawing_functions.c
* Orphan functions which were cluttering up visualizer.c
* but are too short to have their own files.
*/
#include <GL/gl.h>
#include <ap_types.h>
void
draw_grid()
{
glPushMatrix();
unsigned dx = 100; // meters per grid line
double radius = 1500;
glLineWidth(1.0f);
// lines which run east/west
glColor4f(1.0f,1.0f,1.0f,1.0f);
for (double north=-radius; north<radius+0.1; north+=dx){
glBegin(GL_LINE_STRIP);
glVertex3f(north, -radius, -0.5f);
glVertex3f(north, radius, -0.5f);
glEnd();
}
// lines which run north/south
for (double east=-radius; east<radius+0.1; east+=dx){
glBegin(GL_LINE_STRIP);
glVertex3f( -radius, east, -0.5f);
glVertex3f( radius, east, -0.5f);
glEnd();
}
glPopMatrix();
}
void
draw_wind_est( est2User_t * e2u )
{
glPushMatrix();
float windsock_height = 20.0f;
glLineWidth(5.0f);
glColor4f( 0.0f, 1.0f, 1.0f, e2u->ae2u.wind_est.wind_est_trust );
glBegin(GL_LINE_STRIP);
glVertex3f( 0.0f,0.0f, -windsock_height );
double scale = 3.0f;
glVertex3f( scale*e2u->ae2u.wind_est.wind_ned.x,
scale*e2u->ae2u.wind_est.wind_ned.y,
-windsock_height + scale*e2u->ae2u.wind_est.wind_ned.z );
glEnd();
glColor4f( 1.0f, 1.0f, 0.0f, 1.0f );
glBegin(GL_LINE_STRIP);
glVertex3f( 0.0f, 0.0f, -windsock_height );
glVertex3f( 0.0f, -scale*15.0f, -windsock_height );
glEnd();
glPopMatrix();
}
void
draw_axes_from_euler(float yaw, float pitch, float roll,
float x, float y, float z,
float size, float width)
{
glPushMatrix();
glLineWidth(width);
glTranslatef(x,y,z);
glRotatef( yaw, 0.0f, 0.0f, 1.0f);
glRotatef( pitch, 0.0f, 1.0f, 0.0f);
glRotatef( roll, 1.0f, 0.0f, 0.0f);
glColor3f(1.0f,0.0f,0.0f);
glBegin(GL_LINE_STRIP);
glVertex3f(0.0f,0.0f,0.0f);
glVertex3f(size,0.0f,0.0f);
glEnd();
glColor3f(0.0f,1.0f,0.0f);
glBegin(GL_LINE_STRIP);
glVertex3f(0.0f,0.0f,0.0f);
glVertex3f(0.0f,size,0.0f);
glEnd();
glColor3f(0.0f,0.0f,1.0f);
glBegin(GL_LINE_STRIP);
glVertex3f(0.0f,0.0f,0.0f);
glVertex3f(0.0f,0.0f,size);
glEnd();
glPopMatrix();
glLineWidth(1.0f);
}