00001
00002
00003
00004
00005
00006 #ifndef __XYMATH_H
00007 #define __XYMATH_H
00008
00009 #include <math.h>
00010 #include "xybool.h"
00011
00012 #ifndef MIN
00013 #define MIN(a, b) ((a) < (b) ? (a) : (b)) // mínimo entre dois valores
00014 #endif
00015
00016 #ifndef MAX
00017 #define MAX(a, b) ((a) > (b) ? (a) : (b)) // máximo entre dois valores
00018 #endif
00019
00020
00021 #define MIN3(a, b, c) ((a) < (b) ? MIN(a, c) : MIN(b, c))
00022
00023 #define MAX3(a, b, c) ((a) > (b) ? MAX(a, c) : MAX(b, c))
00024
00025 const double XY_PI = 3.14159265359;
00026
00027
00028 double mtTolerance(double v);
00029
00030
00031 xybool mtEqual(double v1, double v2);
00032
00033 xybool mtEqual(double v1, double v2, double tol);
00034
00035
00036 xybool mtLessEqual(double v1, double v2);
00037
00038
00039 double mtDistance(double x0, double y0, double x1, double y1);
00040
00041
00042 double mtDistance(int x0, int y0, int x1, int y1);
00043
00044
00045 void mtRotate(double xi, double yi, double angle, double* xr, double* yr);
00046
00047
00048 void mtRotate(int xi, int yi, double angle, int* xr, int* yr);
00049
00050
00051 xybool mtIntercept(double xmin1, double ymin1, double xmax1, double ymax1,
00052 double xmin2, double ymin2, double xmax2, double ymax2);
00053
00054
00055 xybool mtIntercept(int xmin1, int ymin1, int xmax1, int ymax1,
00056 int xmin2, int ymin2, int xmax2, int ymax2);
00057
00058
00059 xybool mtInclude(double xmin1, double ymin1, double xmax1, double ymax1,
00060 double xmin2, double ymin2, double xmax2, double ymax2);
00061
00062
00063 xybool mtInclude(int xmin1, int ymin1, int xmax1, int ymax1,
00064 int xmin2, int ymin2, int xmax2, int ymax2);
00065
00066
00067 xybool mtPointInRect(int px, int py, int x1, int y1, int x2, int y2);
00068
00069
00070 xybool mtPointInRect(double px, double py, double x1, double y1,double x2, double y2);
00071
00072
00073 xybool mtPointInLine(double px, double py, double x1, double y1,double x2, double y2);
00074
00075
00076 xybool mtPointInLineEx(double px, double py, double x1, double y1,double x2, double y2);
00077
00078
00079 xybool mtPointInMark(int px, int py, int x1, int y1, int tol);
00080
00081
00082 xybool mtPointInCircle (int px, int py, int x0, int y0, int x1, int y1);
00083
00084
00085 xybool mtPointInsideCircle (int px, int py, int cx, int cy, int radius);
00086
00087 int mtDecade( double val );
00088
00089 #endif
00090