00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __UT_Polynomial2_H__
00021 #define __UT_Polynomial2_H__
00022
00023 #include "UT_API.h"
00024 #include <stdlib.h>
00025 #include <iostream.h>
00026 #include "UT_Matrix.h"
00027
00028 #define UT_BASIS_NONE 0
00029 #define UT_BASIS_BEZIER 1
00030 #define UT_BASIS_POWER 2
00031 #define UT_BASIS_LINOP 3 // Linear operator, not a polynomial.
00032
00033
00034
00035 class UT_API UT_Polynomial2 {
00036 public:
00037 UT_Polynomial2();
00038 UT_Polynomial2(int udeg, int vdeg);
00039 ~UT_Polynomial2();
00040
00041
00042 void init(int udeg, int vdeg);
00043
00044
00045 void resize(int udeg, int vdeg);
00046
00047
00048 void makeIdentity();
00049 void zero();
00050
00051
00052 void transpose();
00053
00054
00055
00056
00057
00058 void makeBezBasisOp();
00059 void makePowBasisOp();
00060
00061 void applyOpLeft(const UT_Polynomial2 &op);
00062
00063 void applyOpRight(const UT_Polynomial2 &op);
00064
00065
00066
00067
00068 void add(const UT_Polynomial2 &poly);
00069 void mult(const UT_Polynomial2 &poly);
00070 void mult(fpreal scale);
00071
00072 void compose(const UT_Polynomial2 &polyu,
00073 const UT_Polynomial2 &polyv,
00074 fpreal tol = 1e-5);
00075
00076 void setBasis(int newbasis) { myBasisType = newbasis; }
00077 int getBasis() const { return myBasisType; }
00078
00079 int degreeU() const { return myMatrix.getNRH(); }
00080 int degreeV() const { return myMatrix.getNCH(); }
00081
00082
00083 void reduceDegree(fpreal tol = 1e-5);
00084
00085
00086 UT_Polynomial2 *convertToBezier() const;
00087 UT_Polynomial2 *convertToPower() const;
00088
00089 UT_Polynomial2 *copy() const;
00090
00091 float &operator()(int u, int v) { return myMatrix(u,v); }
00092 fpreal operator()(int u, int v) const
00093 { return myMatrix(u, v); }
00094
00095 UT_Polynomial2 &operator=(const UT_Polynomial2 &p);
00096
00097 private:
00098 UT_Matrix myMatrix;
00099 int myBasisType;
00100 };
00101
00102 #endif