bezier.h revision 40742313779ee5e43be93a9191f1c86412cf183b
/**
* @file
* @brief Bezier polynomial
*//*
* Authors:
* MenTaLguY <mental@rydia.net>
* Michael Sloan <mgsloan@gmail.com>
* Nathan Hurst <njh@njhurst.com>
*
* Copyright 2007 Authors
*
* modify it either under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* (the "LGPL") or, at your option, under the terms of the Mozilla
* Public License Version 1.1 (the "MPL"). If you do not alter this
* notice, a recipient may use your version of this file under either
* the MPL or the LGPL.
*
* You should have received a copy of the LGPL along with this library
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* You should have received a copy of the MPL along with this library
* in the file COPYING-MPL-1.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
* the specific language governing rights and limitations.
*
*/
#ifndef LIB2GEOM_SEEN_BEZIER_H
#define LIB2GEOM_SEEN_BEZIER_H
#include <valarray>
#include <boost/optional.hpp>
/*
* Bernstein :
* Evaluate a Bernstein function at a particular parameter value
* Fill in control points for resulting sub-curves.
*
*/
unsigned N = order+1;
for (unsigned i = 0; i < N; i++)
row[i] = v[i];
// Triangle computation
const double omt = (1-t);
if(left)
if(right)
for (unsigned i = 1; i < N; i++) {
for (unsigned j = 0; j < N - i; j++) {
}
if(left)
if(right)
}
return (row[0]);
/*
Coord vtemp[order+1][order+1];
// Copy control points
std::copy(v, v+order+1, vtemp[0]);
// Triangle computation
for (unsigned i = 1; i <= order; i++) {
for (unsigned j = 0; j <= order - i; j++) {
vtemp[i][j] = lerp(t, vtemp[i-1][j], vtemp[i-1][j+1]);
}
}
if(left != NULL)
for (unsigned j = 0; j <= order; j++)
left[j] = vtemp[j][0];
if(right != NULL)
for (unsigned j = 0; j <= order; j++)
right[j] = vtemp[order-j][j];
return (vtemp[order][0]);*/
}
inline T bernsteinValueAt(double t, T const *c_, unsigned n) {
double u = 1.0 - t;
double bc = 1;
double tn = 1;
for(unsigned i=1; i<n; i++){
}
}
//std::copy(c, c+order()+1, &c_[0]);
}
Bezier() {}
}
return *this;
}
struct Order {
unsigned order;
};
//Construct an arbitrary order bezier
}
}
//Construct an order-1 bezier (linear Bézier)
}
//Construct an order-2 bezier (quadratic Bézier)
}
//Construct an order-3 bezier (cubic Bézier)
}
{
}
void clear()
{
}
//IMPL: FragmentConcept
typedef Coord output_type;
inline bool isZero() const {
for(unsigned i = 0; i <= order(); i++) {
if(c_[i] != 0) return false;
}
return true;
}
inline bool isConstant() const {
for(unsigned i = 1; i <= order(); i++) {
}
return true;
}
inline bool isFinite() const {
for(unsigned i = 0; i <= order(); i++) {
}
return true;
}
int n = order();
int i;
u = 1.0 - t;
bc = 1;
tn = 1;
for(i=1; i<n; i++){
}
//return subdivideArr(t, &c_[0], NULL, NULL, order());
}
// inline SBasis toSBasis() const {
// SBasis sb;
// bezier_to_sbasis(sb, (*this));
// return sb;
// //return bezier_to_sbasis(&c_[0], order());
// }
//Only mutator
inline Coord const &operator[](unsigned ix) const { return const_cast<std::valarray<Coord>&>(c_)[ix]; }
//inline Coord const &operator[](unsigned ix) const { return c_[ix]; }
/**
* The size of the returned vector equals n_derivs+1.
*/
/* This is inelegant, as it uses several extra stores. I think there might be a way to
* evaluate roughly in situ. */
// initialize return vector with zeroes, such that we only need to replace the non-zero derivs
// initialize temp storage variables
for(unsigned i = 0; i < size(); i++) {
}
}
//val_n_der[di] = (subdivideArr(t, &d_[0], NULL, NULL, order() - di));
}
}
return val_n_der;
}
}
return solutions;
}
find_bernstein_roots(&const_cast<std::valarray<Coord>&>(c_)[0], order(), solutions, 0, ivl.min(), ivl.max());
return solutions;
}
};
inline
return sb;
//return bezier_to_sbasis(&c_[0], order());
}
//TODO: implement others
for(unsigned i = 0; i <= a.order(); i++)
result[i] = a[i] + v;
return result;
}
for(unsigned i = 0; i <= a.order(); i++)
result[i] = a[i] - v;
return result;
}
for(unsigned i = 0; i <= a.order(); i++)
result[i] = a[i] * v;
return result;
}
for(unsigned i = 0; i <= a.order(); i++)
result[i] = a[i] / v;
return result;
}
for(unsigned i = 0; i <= a.order(); i++)
return result;
}
//TODO: implement better?
if(from == 0) {
}
}
// XXX Todo: how to handle differing orders
for(unsigned i = 0; i <= a[0].order(); i++) {
Point p;
for(unsigned d = 0; d < 2; d++) p[d] = a[d][i];
}
return result;
}
//if(a.order() == 1) return Bezier(0.0);
for(unsigned i = 0; i < a.order(); i++) {
}
return der;
}
inte[0] = 0;
}
return inte;
}
return ret;
}
//TODO: better bounds exact
return bounds_exact(b.toSBasis());
}
//return bounds_local(b.toSBasis(), i);
if (i) {
} else {
return OptInterval();
}
}
for(unsigned i = 0; i < b.size(); i++) {
out_file << b[i] << ", ";
}
return out_file;
}
}
#endif // LIB2GEOM_SEEN_BEZIER_H
/*
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 :