This commit is contained in:
2018-12-11 00:09:01 +01:00
parent bbdad5a857
commit 1bc0d1e44b
5 changed files with 85 additions and 317 deletions

View File

@@ -1,16 +1,16 @@
#pragma once
// link: https://www.codeproject.com/Articles/25237/Bezier-Curves-Made-Simple
class BezierCurve
{
static double FactorialLookup[33];
public:
// just check if n is appropriate, then return the result
static double factorial(int n)
{
// if (n < 0) { throw new Exception("n is less than 0"); }
// if (n > 32) { throw new Exception("n is greater than 32"); }
return FactorialLookup[n]; /* returns the value n! as a SUMORealing point number */
return FactorialLookup[n];
}
static double Ni(int n, int i)
@@ -27,10 +27,8 @@ public:
static double Bernstein(int n, int i, double t)
{
double basis;
double ti; /* t^i */
double tni; /* (1 - t)^i */
/* Prevent problems with pow */
double ti;
double tni;
if (t == 0.0 && i == 0)
ti = 1.0;
@@ -49,9 +47,6 @@ public:
static glm::vec2 Bezier2D(const std::vector<glm::vec2>& b, double t)
{
// if ((1.0 - t) < 5e-6)
// t = 1.0;
double px = 0.0;
double py = 0.0;
const int npts = (int)b.size();