-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathPolarCurve.h
91 lines (71 loc) · 2.96 KB
/
PolarCurve.h
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
#pragma once
#include "Curve.h"
#include "F1P.h"
#include <cmath>
#include <limits>
namespace nV {
namespace Graphics {
#define ADD_POINT_ANGLE_POLAR_CURVE 0.08
#define MAX_DERIVATIVE 20 //before 20
#define MAX_GRAPHSCALE 3
#define MIN_GRAPHSCALE 0.1
#define MAX_DELETE_AMOUNT 5
#define MAX_GET_POINT_ON_RANGE_DEPTH 20
#define MIN_X_DIS 0.001
#define MIN_DELTA_DIS_POLAR_CURVE 0.01
#define MAX_DERIVATIVE_ABSOULUTE 5000
class PolarCurve : public Curve {
public:
double tmin, tmax, spt, rmax, rmin, spr;
double dt, graphScale;
//ArrayList<double> arrayT; //存每个点的t值,与verts一一对应
F1P *f;
ArrayList<ArrayList<double> *> arrayTtotal;
//about color functions
F1P *cf;
public:
PolarCurve(F1P *f, double start, double end);
PolarCurve(F1P *ff, double start, double end, F1P *cff);
~PolarCurve();
protected:
int getBaseNum();
void makePoints();
void useColorFunction();
void addVerts(LineStrip* lineStrip, ArrayList<double> &arrayT);
inline double getK(double t, double dt);
double getNaNk(double t, double dt);
void makeplotrange(F1P *f, bool havananrange, std::vector<domain *> &nanrangeset, double &ymax_f, double &ymin_f, double xmax_f, double xmin_f);
private:
void getyrange(double &ymax, double &ymin, double &graphScale, double &spx, double &spy,
const std::vector<Point2d *> &vert, const std::vector<bool> &flag,
const std::vector<bool> &nanflag);
void detectnanborder(F1P *f, std::vector<domain *> &nanrangeset,
std::vector<uint> &nannodesite, const std::vector<bool> &nanflag,
const std::vector<bool> &derivativeflag,
const std::vector<Point2d *> &vert);
double getrightborder(F1P *f, double lx, double rx, uint deepth);
double getPointOnRangeFromLeft(F1P *f_x, double x1, double x2, int depth);
double getPointOnRangeFromRight(F1P *f_x, double x1, double x2, int depth);
void getsingularityset(std::vector<bool>::iterator flag,
std::vector<bool>::iterator nanflag, uint size,
std::vector<singularitynode *> &singularityset,
double t_xmax, double t_xmin, ArrayList<double>::iterator d,
ArrayList<Point2d *>::iterator vert);
};
inline double PolarCurve::getK(double t, double dt) {
double deritivate = (f->getDerivative(t, dt)*cos(t) + f->getSingleData(t)*(-sin(t))) / (f->getDerivative(t, dt)*sin(t) + f->getSingleData(t)*cos(t));
if(!isNaN(deritivate)) {
return deritivate;
} else {
return MAX_DERIVATIVE_ABSOULUTE;
}
}
inline double PolarCurve::getNaNk(double t, double dt) {
double derivative = (f->getDerivative(t, dt)*cos(t) + f->getSingleData(t)*(-sin(t))) / (f->getDerivative(t, dt)*sin(t) + f->getSingleData(t)*cos(t));
if(derivative == std::numeric_limits<double>::infinity()) {
derivative = std::numeric_limits<double>::quiet_NaN();
}
return derivative;
}
}
}