bezier.h revision 04d58df841d9eb087eb99074f5c99235b801189b
/**
* @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>
#include <valarray>
/*
* 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++){
}
}
void
double l, double r) const;
//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;
for(unsigned i = 0; i <= order(); i++) {
}
return true;
}
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++){
}
}
//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;
}
Bezier forward_difference(unsigned k) {
for(unsigned i = 0; i < n; i++) {
fd[i] = 0;
for(unsigned j = i; j < n; j++) {
}
}
return fd;
}
Bezier elevate_degree() const {
unsigned n = size();
for(unsigned i = 1; i < n; i++) {
}
return ed;
}
Bezier reduce_degree() const {
unsigned n = size();
unsigned middle = n/2;
for(unsigned i = 1; i < middle; i++) {
}
for(unsigned i = n-1; i >= middle; i--) {
}
return ed;
}
}
return ed;
}
unsigned n = order();
for(unsigned i = 0; i < n; i++) {
}
return b;
}
};
inline
unsigned m = f.order();
unsigned n = g.order();
// h_k = sum_(i+j=k) (m i)f_i (n j)g_j / (m+n k)
for(unsigned i = 0; i <= m; i++) {
for(unsigned j = 0; j <= n; j++) {
}
}
for(unsigned k = 0; k <= m+n; k++) {
}
return h;
}
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();
}
}
out_file << "Bezier(";
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 :