PolarScanMatching(PSM)
1
|
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
Macros | |
#define | DR_MARKER_CIRCLE 1 |
Constant used with dr_marker() to draw a small circle. More... | |
#define | DR_MARKER_TRIANGLE 2 |
Constant used with dr_marker() to draw a small triange. More... | |
#define | DR_MARKER_CROSS 3 |
Constant used with dr_marker() to draw a small cross. More... | |
Functions | |
void | dr_init (int screen_x_max, int screen_y_max, double xmin, double ymin, double xmax, double ymax) |
Initialize the drawing module. More... | |
void | dr_close (void) |
Close the drawing window. More... | |
void | plot_object (int obj_index) |
void | dr_line (double x1, double y1, double x2, double y2, const char *color) |
Plot a line between [x1,y1] and [x2,y2] using color. More... | |
void | dr_circle (double x, double y, double r, const char *color) |
Plot a circle of radius r at [x,y] using color. More... | |
void | dr_cov_ellipse (double x, double y, double cxx, double cxy, double cyy, const char *color) |
Plot a covariance ellipse to depict uncertainty. More... | |
void | dr_marker (double x, double y, int type, const char *color) |
Place a marker to (x,y). Possible markers are: DR_MARKER_CIRCLE, DR_MARKER_TRIANGLE, DR_MARKER_CROSS. More... | |
void | dr_text (double x, double y, int hz_al, int vr_al, const char *text, const char *color) |
Place a text to (x,y). More... | |
void | dr_text_pix (int px, int py, const char *text, const char *color) |
Temporary code to output text to screen coordinates. More... | |
void | dr_replot (void) |
Redraw the screen content. More... | |
void | dr_scale (double xmin, double ymin, double xmax, double ymax) |
Scale the shown area. Prior rescaling, the area is normalized to keep the aspect ratio. More... | |
void | dr_erase (void) |
Clear the screen and erase the drawn objects from memory. More... | |
void | dr_zoom (void) |
Interactive zooming until enter, space or 'q' is pressed. More... | |
void | dr_fit (void) |
Scale all drawn objects to fit the screen. More... | |
void | dr_save (const char *filename) |
Save the screen into a PNG image (needs extra packages). More... | |
void | dr_equal (int equal) |
Enable or disable equal drawing unit per pixel ratio for both axis. More... | |
void | dr_print_database (void) |
Debug function to print buffer. More... | |
Variables | |
const char * | dr_COLORS [] = {"red","green","blue","gray","yellow","magenta","pink","lightgray","brown"} |
Array of colors one can use for drawing. More... | |
const int | dr_COLORS_CNT = 9 |
The number of colours available for drawing. More... | |
#define DR_MARKER_CIRCLE 1 |
Constant used with dr_marker() to draw a small circle.
#define DR_MARKER_CROSS 3 |
Constant used with dr_marker() to draw a small cross.
#define DR_MARKER_TRIANGLE 2 |
Constant used with dr_marker() to draw a small triange.
void dr_circle | ( | double | x, |
double | y, | ||
double | r, | ||
const char * | color | ||
) |
Plot a circle of radius r at [x,y] using color.
x | X coordinate of the center of the circle. |
y | Y coordinate of the center of the circle. |
r | Radius of the circle. |
color | The color of the circle as "red", "green",... see dr_COLORS. |
void dr_close | ( | void | ) |
Close the drawing window.
void dr_cov_ellipse | ( | double | x, |
double | y, | ||
double | cxx, | ||
double | cxy, | ||
double | cyy, | ||
const char * | color | ||
) |
Plot a covariance ellipse to depict uncertainty.
The covariance ellipse is drawn by breaking it up into line segments.
Acknowledgement: the core equations are from Lindsay's kzoom.
x | X coordinate of the mean of the distribution. |
y | Y coordinate of the mean of the distribution. |
cxx | The variance of the X coordinate. |
cxy | The XY covariance. |
cyy | The variance of the Y coordinate. |
color | The color of the ellipse as "red", "green",... see dr_COLORS. |
void dr_equal | ( | int | equal | ) |
Enable or disable equal drawing unit per pixel ratio for both axis.
equal | 1 - enabled, 0 - disabled |
void dr_erase | ( | void | ) |
Clear the screen and erase the drawn objects from memory.
void dr_fit | ( | void | ) |
Scale all drawn objects to fit the screen.
void dr_init | ( | int | screen_x_max, |
int | screen_y_max, | ||
double | xmin, | ||
double | ymin, | ||
double | xmax, | ||
double | ymax | ||
) |
Initialize the drawing module.
screen_y_max | [pixel] The height of the drawing screen in pixels. |
screen_x_max | [pixel] The width of the drawing screen in pixels. |
xmin | Minimum x coordinate of the drawing area in drawing units. |
ymin | Minimum y coordinate of the drawing area in drawing units. |
xmax | Maximum x coordinate of the drawing area in drawing units. |
ymax | Maximum y coordinate of the drawing area in drawing units. |
void dr_line | ( | double | x1, |
double | y1, | ||
double | x2, | ||
double | y2, | ||
const char * | color | ||
) |
Plot a line between [x1,y1] and [x2,y2] using color.
x1 | x coordinate of the first point. |
y1 | y coordinate of the first point. |
x2 | x coordinate of the second point. |
y2 | y coordinate of the second point. |
color | The color of the line as "red", "green",... see dr_COLORS. |
void dr_marker | ( | double | x, |
double | y, | ||
int | type, | ||
const char * | color | ||
) |
Place a marker to (x,y). Possible markers are: DR_MARKER_CIRCLE, DR_MARKER_TRIANGLE, DR_MARKER_CROSS.
x | X coordinate of the marker. |
y | Y coordinate of the marker. |
type | The type of the marker. One of DR_MARKER_CIRCLE, DR_MARKER_TRIANGLE, DR_MARKER_CROSS. |
color | The color of the marker as "red", "green",... see dr_COLORS. |
void dr_print_database | ( | void | ) |
Debug function to print buffer.
void dr_replot | ( | void | ) |
Redraw the screen content.
void dr_save | ( | const char * | filename | ) |
Save the screen into a PNG image (needs extra packages).
filename | The name of the file under which the image is saved. |
void dr_scale | ( | double | xmin, |
double | ymin, | ||
double | xmax, | ||
double | ymax | ||
) |
Scale the shown area. Prior rescaling, the area is normalized to keep the aspect ratio.
xmin | Minimum X coordinate of the shown area. |
ymin | Minimum Y coordinate of the shown area. |
xmax | Maximum X coordinate of the shown area. |
ymax | Maximum X coordinate of the shown area. |
void dr_text | ( | double | x, |
double | y, | ||
int | hz_al, | ||
int | vr_al, | ||
const char * | text, | ||
const char * | color | ||
) |
Place a text to (x,y).
x | X coordinate of the text. |
y | Y coordinate of the text. |
hz_al | Horizontal alignment. - CURRENTLY NOT USED. |
vr_al | Horizontal alignment. - CURRENTLY NOT USED. |
text | The text to be shown. |
color | The color of the marker as "red", "green",... see dr_COLORS. |
void dr_text_pix | ( | int | px, |
int | py, | ||
const char * | text, | ||
const char * | color | ||
) |
Temporary code to output text to screen coordinates.
px | [Pixel] X coordinate of the text. |
py | [Pixel] Y coordinate of the text. |
text | The text to be shown. |
color | The color of the marker as "red", "green",... see dr_COLORS. |
void dr_zoom | ( | void | ) |
Interactive zooming until enter, space or 'q' is pressed.
Use mouse or numeric keypad to pan/zoom. On the numeric keypad 9,3 will zoom in/out, 2,8 will move the drawing up/down, 4,6 will move left/right. Push r to redraw and c to reset to initial zoom level and view position.
When using the mouse, left click on figure top/bottom will move the drawing down/up, clicking on the left or right side of the figure will move the drawing right or left. Moving the wheel will zoom in and out.
void plot_object | ( | int | obj_index | ) |
const char* dr_COLORS[] = {"red","green","blue","gray","yellow","magenta","pink","lightgray","brown"} |
Array of colors one can use for drawing.
const int dr_COLORS_CNT = 9 |
The number of colours available for drawing.