#include <Algebraic.h>
Inheritance diagram for Algebraic:


This class implements arbitrary polynomials of three variables.
Definition at line 15 of file Algebraic.h.
Public Member Functions | |
| Algebraic () | |
| Constucts a constant Algebraic. | |
| Algebraic (int degree) | |
| ~Algebraic () | |
| virtual double | proc (gmVector3 x) |
| virtual gmVector3 | grad (gmVector3 v) |
| grad returns the gradient of the function (proc()) for a point or region. | |
| virtual gmMatrix3 | hess (gmVector3 v) |
| hess returns the Hessian of the function (proc()) for a point or region. | |
| virtual Intervald | proc (Box< double >) |
| proc of an interval-vector (aka a Box) X. | |
| virtual Box3d | grad (Box< double >) |
| virtual IMatrix3d | hess (Box< double >) |
| int | degree () |
| Degree of polynomial. | |
| void | degree (int) |
| int | getNumCoef () |
| Number of coefficients. | |
| int | getCoefIndex (int i, int j, int k) |
| Return the ordinal of the x^i y^j z^k coefficient. | |
| double | getCoef (int i, int j, int k) |
| Returns scalar factor of the x^i y^j z^k term. | |
| void | setCoef (int i, int j, int k, double a) |
| Sets coefficient of x^i y^j z^k to a. | |
| virtual void | procq (gmVector3, double *) |
| Computes dproc()/dq for an algebraic. | |
| virtual void | procq (Box< double >, Intervald *) |
| Computes dproc()/dq in Interval form for an algebraic. | |
| virtual void | gradq (Box< double >, Intervald *, Intervald *, Intervald *) |
| Computes dgrad()/dq = d^2proc/dxdq and stores it in three arrays. | |
| virtual void | getq (double *) |
| Get copy of the implicit model parameters. | |
| virtual void | _setq (double *) |
| Overridden by subclasses to set Qs. | |
| virtual int | qlen () |
| Number of implicit model parameters for this implicit object including its children. | |
| virtual void | getqname (char **qn) |
| The name of each parameter. | |
| MAKE_NAME () | |
Static Public Member Functions | |
| int | coefficients (int) |
| Compute the number of terms for a degree d trivariate polynomial. | |
Protected Member Functions | |
| void | initPowerArrays () |
| Initialize the m_x,m_y and m_z arrays to their corresponding exponents in coefficient order. | |
| void | initXYZPowerArrays (gmVector3 v) |
| Fills m_[xyz]Pow cache with powers of x, y and z. | |
| void | initDerivCoefs (void) |
| void | calcNumCoef () |
| Set the number of coefficients in m_numCoef based on the current degree held in m_d. | |
| double | dx (gmVector3 v) |
| double | dy (gmVector3 v) |
| double | dz (gmVector3 v) |
| double | dx2 (gmVector3 v) |
| double | dy2 (gmVector3 v) |
| double | dz2 (gmVector3 v) |
| double | dxdy (gmVector3 v) |
| double | dxdz (gmVector3 v) |
| double | dydz (gmVector3 v) |
Protected Attributes | |
| int | m_d |
| Degree. | |
| int | m_numCoef |
| Number of terms. | |
| int * | m_x |
| Array storing the exponents of x in coefficient order. | |
| int * | m_y |
| Array storing the exponents of y in coefficient order. | |
| int * | m_z |
| Array storing the exponents of z in coefficient order. | |
| double * | m_xPow |
| Cached array of powers of input value of x in coefficient order. | |
| double * | m_yPow |
| Cached array of powers of input value of y in coefficient order. | |
| double * | m_zPow |
| Cached array of powers of input value of z in coefficient order. | |
Private Member Functions | |
| void | init (int) |
| Initialization routine called by constructors. | |
| Intervald | m_alrp (int, Intervald) |
| Linear interpolate - 4D critical points. | |
Private Attributes | |
| double * | m_a |
| Array of coefficients. | |
|
|
Constucts a constant Algebraic.
Definition at line 37 of file Algebraic.cpp. References init(). |
|
|
Definition at line 42 of file Algebraic.cpp. References init(). |
|
|
Definition at line 104 of file Algebraic.cpp. |
|
|
Overridden by subclasses to set Qs. _setq() is called directly only in subclasses of Implicit. Outside the Implicit class hierarchy, always call setq(). So, if you want to save the old set of Qs, a subclass should override _setq(). In fact, the default _setq() in Implicit does nothing, so you have to override it to do the work of setting the current Q array. However, on the off chance you have a subclass where you do not want to save the old Qs, then override setq() to do the work of settings the current Qs. Typically you will want to save the old Qs so subclasses will usually override (and call) _setq(). Reimplemented from Implicit. Definition at line 592 of file Algebraic.cpp. |
|
|
Set the number of coefficients in m_numCoef based on the current degree held in m_d.
Definition at line 303 of file Algebraic.cpp. References coefficients(), m_d, and m_numCoef. |
|
|
Compute the number of terms for a degree d trivariate polynomial. Degree d algebraic has (d^3 + 6d^2 + 11d + 6)/6 coefficients. 0: 1 1: 3 + 1 = 4 2: 6 + 4 = 10 3: 10 + 10 = 20 # of terms of degree d = d+1 + # of terms of degree d-1. Why? Multiply x times terms of degree d-1, then all that is left are terms containing only y and z. There are d+1 of these. E.g. yyy yyz yzz zzz Hence terms(d) = d+1 + terms(d-1) and terms(0) = 1. This yields terms(d) = sum[i = 1..d+1] i = (d+2)*(d+1)/2 (Recall sum[i = 1..n] i = (n+1)*n/2) = 1/2 d^2 + 3/2 d + 1. The # of terms of degree d or less is thus sum[i = 0..d] terms(i) = sum[i = 0..d] 1/2 d^2 + 3/2 d + 1 = 1/2 * d*(d+1)*(2d+1)/6 + 3/2 * d*(d+1)/2 + d+1 (Recall sum[i = 1..n] i^2 = n(n+1)(2n+1)/6) = 1/12 * (2d^3 + 3d^2 + d) + 3/4 * (d^2 + d) + d + 1 = d^3/6 + d^2 + 1 10/12 d + 1. Definition at line 295 of file Algebraic.cpp. Referenced by calcNumCoef(), getCoefIndex(), and ImpFileManager::readImplicit(). |
|
|
Definition at line 47 of file Algebraic.cpp. References calcNumCoef(), initPowerArrays(), m_a, m_d, m_numCoef, m_x, m_xPow, m_y, m_yPow, m_z, and m_zPow. |
|
|
Degree of polynomial.
Definition at line 264 of file Algebraic.cpp. References m_d. |
|
|
Definition at line 404 of file Algebraic.cpp. References initXYZPowerArrays(), m_a, m_numCoef, m_x, m_xPow, m_y, m_yPow, m_z, and m_zPow. Referenced by grad(). |
|
|
Definition at line 446 of file Algebraic.cpp. References initXYZPowerArrays(), m_a, m_numCoef, m_x, m_xPow, m_y, m_yPow, m_z, and m_zPow. Referenced by hess(). |
|
|
Definition at line 488 of file Algebraic.cpp. References initXYZPowerArrays(), m_a, m_numCoef, m_x, m_xPow, m_y, m_yPow, m_z, and m_zPow. Referenced by hess(). |
|
|
Definition at line 502 of file Algebraic.cpp. References initXYZPowerArrays(), m_a, m_numCoef, m_x, m_xPow, m_y, m_yPow, m_z, and m_zPow. Referenced by hess(). |
|
|
Definition at line 418 of file Algebraic.cpp. References initXYZPowerArrays(), m_a, m_numCoef, m_x, m_xPow, m_y, m_yPow, m_z, and m_zPow. Referenced by grad(). |
|
|
Definition at line 460 of file Algebraic.cpp. References initXYZPowerArrays(), m_a, m_numCoef, m_x, m_xPow, m_y, m_yPow, m_z, and m_zPow. Referenced by hess(). |
|
|
Definition at line 516 of file Algebraic.cpp. References initXYZPowerArrays(), m_a, m_numCoef, m_x, m_xPow, m_y, m_yPow, m_z, and m_zPow. Referenced by hess(). |
|
|
Definition at line 432 of file Algebraic.cpp. References initXYZPowerArrays(), m_a, m_numCoef, m_x, m_xPow, m_y, m_yPow, m_z, and m_zPow. Referenced by grad(). |
|
|
Definition at line 474 of file Algebraic.cpp. References initXYZPowerArrays(), m_a, m_numCoef, m_x, m_xPow, m_y, m_yPow, m_z, and m_zPow. Referenced by hess(). |
|
||||||||||||||||
|
Returns scalar factor of the x^i y^j z^k term.
Definition at line 243 of file Algebraic.cpp. References getCoefIndex(), and m_a. Referenced by Quadric::Q(). |
|
||||||||||||||||
|
Return the ordinal of the x^i y^j z^k coefficient. Resulting index used for m_a, m_x, m_y, m_z, m_xPow, m_yPow and m_zPow. Coefficient order is constant first, then x, then y, then z. For a quadric, coefficient order is: 1, x, y, x^2, xy, y^2, z, xz, yz, z^2.
x y \ z xx xy yy \ xz yz \ zz xxx xxy xyy yyy \ xxz xyz yyz \ xzz yzz \ zzz Coordinates: level: d = i+j+k (degree) horizontal: j vertical: k Answer is: coefficients(d) - sum[kk=1..d+1-k](kk) + j = coefficients(d) - sum[kk=1..i+j+1](kk) + j (since d = i+j+k) = coefficients(d) - (i+j+1)(i+j+2)/2 + j = coefficients(d) - (i*i + 2*i*j + j*j + 3*i + 3*j + 2)/2 + j
Definition at line 349 of file Algebraic.cpp. References coefficients(). Referenced by getCoef(), initPowerArrays(), and setCoef(). |
|
|
Number of coefficients.
Definition at line 259 of file Algebraic.cpp. References m_numCoef. |
|
|
Get copy of the implicit model parameters.
Reimplemented from Implicit. Definition at line 584 of file Algebraic.cpp. |
|
|
The name of each parameter. The names of the parameters of the function (if any) are put into an array which gets returned.
Reimplemented from Implicit. Definition at line 603 of file Algebraic.cpp. |
|
|
Reimplemented from Implicit. Definition at line 180 of file Algebraic.cpp. References dx(), Intervald, m_a, m_alrp(), m_numCoef, m_x, m_y, and m_z. |
|
|
grad returns the gradient of the function (proc()) for a point or region. Basically, the gradient returns a vector of partial derivatives, or more formally grad(proc()) = (dproc/dx,dproc/dy,dproc/dz).
Reimplemented from Implicit. Definition at line 143 of file Algebraic.cpp. |
|
||||||||||||||||||||
|
Computes dgrad()/dq = d^2proc/dxdq and stores it in three arrays.
Assume f(x,y,z) = a x^i y^j z^k. Then df/dx = a i x^(i-1) y^j z^k. Then d^2f/dxda = i x^(i-1) y^j z^k. Reimplemented from Implicit. Definition at line 570 of file Algebraic.cpp. |
|
|
Reimplemented from Implicit. Definition at line 201 of file Algebraic.cpp. |
|
|
hess returns the Hessian of the function (proc()) for a point or region. Basically, the Hessian is a matrix of second partial derivatives, or more formally hess(proc()) = d^2proc/dx^2, d^2proc/dxdy d^2proc/dxdz \ d^2proc/dxdy, d^2proc/dy^2 d^2proc/dydz \ d^2proc/dxdz, d^2proc/dydz d^2proc/dz^2
Reimplemented from Implicit. Definition at line 148 of file Algebraic.cpp. |
|
|
Initialization routine called by constructors. This function allows all of the main object init code to be in one place. Definition at line 17 of file Algebraic.cpp. References calcNumCoef(), initPowerArrays(), m_a, m_d, m_numCoef, m_x, m_xPow, m_y, m_yPow, m_z, and m_zPow. Referenced by Algebraic(). |
|
|
|
|
|
Initialize the m_x,m_y and m_z arrays to their corresponding exponents in coefficient order.
Definition at line 362 of file Algebraic.cpp. References getCoefIndex(), Implicit::k(), m_d, m_x, m_y, and m_z. |
|
|
Fills m_[xyz]Pow cache with powers of x, y and z. Efficiently computes powers by using results of lower powers.
Definition at line 387 of file Algebraic.cpp. References m_d, m_xPow, m_yPow, and m_zPow. Referenced by dx(), dx2(), dxdy(), dxdz(), dy(), dy2(), dydz(), dz(), dz2(), proc(), and procq(). |
|
||||||||||||
|
Linear interpolate - 4D critical points. We use the "current" and the "last" coefficients to calculate an interval of the coefficients over a given time interval. This is used for 4D critical point finding. Definition at line 122 of file Algebraic.cpp. References Implicit::getqold(), Intervald, m_a, and m_numCoef. |
|
|
Reimplemented in Cone, Cylinder, Ellipsoid, Quadric, and Torus. |
|
|
proc of an interval-vector (aka a Box) X. If X is a 4D box then we assume q is lerp between qold and q. x[3] = [told,t] m_alrp (i,x[3]) returns [(a_i)old,a_i] Reimplemented from Implicit. Definition at line 169 of file Algebraic.cpp. References Intervald, m_a, m_alrp(), m_numCoef, m_x, m_y, and m_z. |
|
|
Implements Implicit. Definition at line 132 of file Algebraic.cpp. References initXYZPowerArrays(), m_a, m_numCoef, m_x, m_xPow, m_y, m_yPow, m_z, and m_zPow. |
|
||||||||||||
|
Computes dproc()/dq in Interval form for an algebraic. Each term of the algebraic is of the form a x^i y^j z^k so its derivative with respect to a is just x^i y^j z^k. Reimplemented from Implicit. Definition at line 548 of file Algebraic.cpp. |
|
||||||||||||
|
Computes dproc()/dq for an algebraic. Each term of the algebraic is of the form a x^i y^j z^k so its derivative with respect to a is just x^i y^j z^k. Reimplemented from Implicit. Definition at line 534 of file Algebraic.cpp. References initXYZPowerArrays(), m_numCoef, m_x, m_xPow, m_y, m_yPow, m_z, and m_zPow. |
|
|
Number of implicit model parameters for this implicit object including its children.
Reimplemented from Implicit. Definition at line 598 of file Algebraic.cpp. References m_numCoef. |
|
||||||||||||||||||||
|
Sets coefficient of x^i y^j z^k to a.
Definition at line 254 of file Algebraic.cpp. References getCoefIndex(), and m_a. Referenced by Quadric::Quadric(), Torus::Torus(), and Quadric::Transform(). |
|
|
Array of coefficients. Should be accessed through getCoef and setCoef. Definition at line 65 of file Algebraic.h. Referenced by _setq(), degree(), dx(), dx2(), dxdy(), dxdz(), dy(), dy2(), dydz(), dz(), dz2(), getCoef(), getq(), grad(), hess(), init(), m_alrp(), proc(), setCoef(), and ~Algebraic(). |
|
|
Degree.
Definition at line 72 of file Algebraic.h. Referenced by calcNumCoef(), degree(), init(), initPowerArrays(), and initXYZPowerArrays(). |
|
|
Number of terms. Initialized by calcNumCoef. Accessed via getNumCoef. Definition at line 78 of file Algebraic.h. Referenced by _setq(), calcNumCoef(), degree(), dx(), dx2(), dxdy(), dxdz(), dy(), dy2(), dydz(), dz(), dz2(), getNumCoef(), getq(), getqname(), grad(), gradq(), hess(), init(), m_alrp(), proc(), procq(), and qlen(). |
|
|
Array storing the exponents of x in coefficient order.
Definition at line 81 of file Algebraic.h. Referenced by degree(), dx(), dx2(), dxdy(), dxdz(), dy(), dy2(), dydz(), dz(), dz2(), getqname(), grad(), gradq(), hess(), init(), initPowerArrays(), proc(), procq(), and ~Algebraic(). |
|
|
Cached array of powers of input value of x in coefficient order.
Definition at line 90 of file Algebraic.h. Referenced by degree(), dx(), dx2(), dxdy(), dxdz(), dy(), dy2(), dydz(), dz(), dz2(), init(), initXYZPowerArrays(), proc(), procq(), and ~Algebraic(). |
|
|
Array storing the exponents of y in coefficient order.
Definition at line 84 of file Algebraic.h. Referenced by degree(), dx(), dx2(), dxdy(), dxdz(), dy(), dy2(), dydz(), dz(), dz2(), getqname(), grad(), gradq(), hess(), init(), initPowerArrays(), proc(), procq(), and ~Algebraic(). |
|
|
Cached array of powers of input value of y in coefficient order.
Definition at line 93 of file Algebraic.h. Referenced by degree(), dx(), dx2(), dxdy(), dxdz(), dy(), dy2(), dydz(), dz(), dz2(), init(), initXYZPowerArrays(), proc(), procq(), and ~Algebraic(). |
|
|
Array storing the exponents of z in coefficient order.
Definition at line 87 of file Algebraic.h. Referenced by degree(), dx(), dx2(), dxdy(), dxdz(), dy(), dy2(), dydz(), dz(), dz2(), getqname(), grad(), gradq(), hess(), init(), initPowerArrays(), proc(), procq(), and ~Algebraic(). |
|
|
Cached array of powers of input value of z in coefficient order.
Definition at line 96 of file Algebraic.h. Referenced by degree(), dx(), dx2(), dxdy(), dxdz(), dy(), dy2(), dydz(), dz(), dz2(), init(), initXYZPowerArrays(), proc(), procq(), and ~Algebraic(). |
1.3.4