HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_Polynomial2.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: Two variable polyomials of arbitrary degree (C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __UT_Polynomial2_H__
13 #define __UT_Polynomial2_H__
14 
15 #include "UT_API.h"
16 #include <stdlib.h>
17 #include <iosfwd>
18 #include "UT_Matrix.h"
19 
20 #define UT_BASIS_NONE 0
21 #define UT_BASIS_BEZIER 1
22 #define UT_BASIS_POWER 2
23 #define UT_BASIS_LINOP 3 // Linear operator, not a polynomial.
24 
25 
26 
28 public:
30  UT_Polynomial2(int udeg, int vdeg);
31  ~UT_Polynomial2();
32 
33  // Allocate space:
34  void init(int udeg, int vdeg);
35 
36  // Enlarge/reduce the polynomial's range:
37  void resize(int udeg, int vdeg);
38 
39  // Makes it the unit polynomial
40  void makeIdentity();
41  void zero();
42 
43  // Swaps u & v.
44  void transpose();
45 
46  // These create conversion functions, which are linear operators
47  // to allow conversion between the bases.
48  // Uses current size of the poly to determine degree.
49  // As this is a linear operator, both u & v size should be equal
50  void makeBezBasisOp();
51  void makePowBasisOp();
52  // This = op * this
53  void applyOpLeft(const UT_Polynomial2 &op);
54  // this = this * op.
55  void applyOpRight(const UT_Polynomial2 &op);
56 
57  // Polynomial functions. Note that they are commutative under
58  // multiplication.
59  // Result is stored in this.
60  void add(const UT_Polynomial2 &poly);
61  void mult(const UT_Polynomial2 &poly);
62  void mult(fpreal scale);
63  // this = this(polyu, polyv)
64  void compose(const UT_Polynomial2 &polyu,
65  const UT_Polynomial2 &polyv,
66  fpreal tol = 1e-5);
67 
68  void setBasis(int newbasis) { myBasisType = newbasis; }
69  int getBasis() const { return myBasisType; }
70 
71  int degreeU() const { return myMatrix.getNRH(); }
72  int degreeV() const { return myMatrix.getNCH(); }
73 
74  // Trys to reduce degree as far as possible.
75  void reduceDegree(fpreal tol = 1e-5);
76 
77  // Convert this to the specified type.
78  UT_Polynomial2 *convertToBezier() const;
79  UT_Polynomial2 *convertToPower() const;
80  // Copy this.
81  UT_Polynomial2 *copy() const;
82 
83  float &operator()(int u, int v) { return myMatrix(u,v); }
84  fpreal operator()(int u, int v) const
85  { return myMatrix(u, v); }
86 
87  UT_Polynomial2 &operator=(const UT_Polynomial2 &p);
88 
89 private:
90  UT_MatrixF myMatrix;
91  int myBasisType;
92 };
93 
94 #endif
const GLdouble * v
Definition: glcorearb.h:836
#define UT_API
Definition: UT_API.h:13
float & operator()(int u, int v)
GLsizei GLboolean transpose
Definition: glcorearb.h:831
GA_API const UT_StringHolder scale
int degreeU() const
void setBasis(int newbasis)
fpreal operator()(int u, int v) const
double fpreal
Definition: SYS_Types.h:270
int degreeV() const
int getBasis() const