解决求导问题
parent
f4900b8df2
commit
6dc7119923
|
@ -20,9 +20,9 @@ Point CubicBezier::calculateControlPoint(Point a, Point b) {
|
|||
}
|
||||
|
||||
void CubicBezier::findPointsOfDivison(vector<double> &p, vector<double>& res) {
|
||||
double a = -3 * p[0] + 9 * p[1] - 9 * p[2] + 3 * p[3];
|
||||
double b = 6 * p[0] - 12 * p[1] + 6 * p[2];
|
||||
double c = -3 * p[0] + 3 * p[1];
|
||||
double a = -3 * p[0] + 3 * p[1] - 3 * p[2] + 3 * p[3];
|
||||
double b = 6 * p[0] - 4 * p[1] + 2 * p[2];
|
||||
double c = -3 * p[0] + p[1];
|
||||
double deta = b * b - 4 * a * c, t = 0;
|
||||
if (fabs(a) > eps) {
|
||||
if (deta < eps) return;
|
||||
|
@ -112,7 +112,7 @@ int CubicBezier::judgeBoundIntersection(double xy, double l, double r, bool isY)
|
|||
be = *vY.begin();
|
||||
en = *vY.rbegin();
|
||||
}
|
||||
if ((be - xy) * (en - xy) > eps) return 0;
|
||||
if ((be - xy) * (en - xy) >= eps) return 0;
|
||||
double t = findTByValue(xy, isY);
|
||||
double value = getLineValueByT(t, !isY);
|
||||
if (l <= value && value <= r && fabs(t) > eps && fabs(1 - t) > eps) {
|
||||
|
|
|
@ -309,10 +309,10 @@ void RendererWidget::paintGL()
|
|||
depthMipmapProgramPtr->bind();
|
||||
for (int i = 0; i <= 3; i++)
|
||||
glBindImageTexture(i, gbuffers[7], i, GL_FALSE, 0, GL_READ_WRITE, GL_R32F);
|
||||
glDispatchCompute(ceil(depthWidth / 2 / 8.), ceil(depthHeight / 2 / 8.), 1);
|
||||
glDispatchCompute(ceil(depthWidth / 2. / 8.), ceil(depthHeight / 2. / 8.), 1);
|
||||
for (int i = 0; i <= 3; i++)
|
||||
glBindImageTexture(i, gbuffers[7], i + 3, GL_FALSE, 0, GL_READ_WRITE, GL_R32F);
|
||||
glDispatchCompute(ceil(depthWidth / 2 / 8 / 8.), ceil(depthHeight / 2 / 8 / 8.), 1);
|
||||
glDispatchCompute(ceil(depthWidth / 2. / 8. / 8.), ceil(depthHeight / 2. / 8. / 8.), 1);
|
||||
depthMipmapProgramPtr->release();
|
||||
|
||||
shadowMappingProgramPtr->bind();
|
||||
|
|
|
@ -31,7 +31,7 @@ int StraightLine::judgeBoundIntersection(double xy, double l, double r, bool isY
|
|||
swap(be.x, be.y);
|
||||
swap(en.x, en.y);
|
||||
}
|
||||
if ((be.x - xy) * (en.x - xy) > eps) return 0;
|
||||
if ((be.x - xy) * (en.x - xy) >= eps) return 0;
|
||||
if (direction(isY)) {
|
||||
float t = findTByValue(xy, isY);
|
||||
float value = getLineValueByT(t, !isY);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
vector<vector<Point>> SvgParser::parse(const std::string path, float width, float height)
|
||||
{
|
||||
std::string tmp;
|
||||
vector<float> point;
|
||||
vector<double> point;
|
||||
vector<Point> line;
|
||||
vector<vector<Point>> lines;
|
||||
for (char c : path.substr(1))
|
||||
|
@ -18,11 +18,11 @@ vector<vector<Point>> SvgParser::parse(const std::string path, float width, floa
|
|||
{
|
||||
if (tmp != "")
|
||||
{
|
||||
point.push_back(std::stof(tmp));
|
||||
point.push_back(std::stod(tmp));
|
||||
tmp = "";
|
||||
if (point.size() == 2)
|
||||
{
|
||||
line.push_back(Point{ std::clamp(point[0] / width * 2 - 1, -1.f, 1.f) , std::clamp(1 - point[1] / height * 2 , -1.f, 1.f)});
|
||||
line.push_back(Point{ std::clamp(point[0] / width * 2 - 1, -1., 1.) , std::clamp(1 - point[1] / height * 2 , -1., 1.)});
|
||||
point.clear();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue