solve-bezier.cpp revision 6553067c3efe2755cef7c7dde1e3623ebfcabbab
#include <cmath>
#include <algorithm>
/*** Find the zeros of a Bezier. The code subdivides until it is happy with the linearity of the
* function. This requires an O(degree^2) subdivision for each step, even when there is only one
* solution.
*
* We try fairly hard to correctly handle multiple roots.
*/
//#define debug(x) do{x;}while(0)
#define debug(x)
namespace Geom{
template<class t>
class Bernsteins{
public:
//std::vector<double> dsolutions;
{}
void subdivide(double const *V,
double t,
double *Left,
double *Right);
};
template <typename T>
out_file << "[";
for(unsigned i = 0; i < b.size(); i++) {
out_file << b[i] << ", ";
}
return out_file << "]";
}
unsigned N = order+1;
for (unsigned i = 0; i < N; i++)
// Triangle computation
const double omt = (1-t);
for (unsigned i = 1; i < N; i++) {
for (unsigned j = 0; j < N - i; j++) {
}
}
return Right;
}
double left_t,
double right_t)
{
}
int sign;
double left_bound = 0;
double dt = 0;
{
{
break;
}
}
if (dt == 0) return;
}
if (left_t < new_left_t) {
} else {
}
}
}
}
void
//convex_hull_marching(bz, bz, solutions, left_t, right_t);
//return;
//A constant bezier, even if identically zero, has no roots
if (bz.isConstant())
return;
while(bz[0] == 0) {
}
if(d != 0) {
double r = bz[0] / d;
if(0 <= r && r <= 1)
}
}
return;
}
//std::cout << "initial = " << bz << std::endl;
Bernsteins B(solutions);
//std::cout << solutions << std::endl;
}
unsigned depth,
double left_t,
double right_t)
{
size_t n_crossings = 0;
//std::cout << "w[0] = " << bz[0] << std::endl;
int sign;
{
//std::cout << "w[" << i << "] = " << w[i] << std::endl;
if (sign != 0)
{
{
++n_crossings;
}
}
}
//std::cout << "n_crossings = " << n_crossings << std::endl;
if (n_crossings == 0) return; // no solutions here
{
//std::cout << "depth = " << depth << std::endl;
/* Stop recursion when the tree is deep enough */
/* if deep enough, return 1 solution at midpoint */
{
//printf("bottom out %d\n", depth);
return;
}
return;
}
/* Otherwise, solve recursively after subdividing control polygon */
// If subdivision is working poorly, split around the leftmost root of the derivative
if (depth > 2) {
double dsplit_t = 0.5;
if(dsolutions.size() > 0) {
dsplit_t = dsolutions[0];
<< split_t << "\n");
}
} else {
// split at midpoint, because it is cheap
{
{
}
}
}
}
}
}
// suggested by Sederberg.
{
u = 1.0 - t;
tn = 1.0;
{
tn *= t;
}
}
double s = 0, t = 1;
double e = 1e-14;
int side = 0;
for (size_t n = 0; n < 100; ++n)
{
<< ", accepting solution " << r
<< "after " << n << "iterations\n");
return r;
}
{
side = -1;
}
{
side = +1;
}
else break;
}
return r;
}
};
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :