Simbody  3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SimTK::Geo::BicubicBezierPatch_< P > Class Template Reference

A primitive useful for computations involving a single bicubic Bezier patch. More...

Public Member Functions

 BicubicBezierPatch_ ()
 Construct an uninitialized patch; control points will be garbage. More...
 
 BicubicBezierPatch_ (const Mat< 4, 4, Vec3P > &controlPoints)
 Construct a bicubic Bezier patch using the given control points B. More...
 
Vec3P evalP (RealP u, RealP w) const
 Evaluate a point P(u,w) on this patch given values for the parameters u and w in [0,1]. More...
 
void evalP1 (RealP u, RealP w, Vec3P &Pu, Vec3P &Pw) const
 Evaluate the tangents Pu=dP/du, Pw=dP/dw on this patch given values for the parameters u and w in [0,1]. More...
 
void evalP2 (RealP u, RealP w, Vec3P &Puu, Vec3P &Puw, Vec3P &Pww) const
 Evaluate the second derivatives Puu=d2P/du2, Pww=d2P/dw2, and cross derivative Puw=Pwu=d2P/dudw on this patch given values for the parameters u and w in [0,1]. More...
 
void evalP3 (RealP u, RealP w, Vec3P &Puuu, Vec3P &Puuw, Vec3P &Puww, Vec3P &Pwww) const
 Evaluate the third derivatives Puuu=d3P/du3, Pwww=d3P/dw3, and cross derivatives Puuw=Pwuu=Puwu=d3P/du2dw and Puww=Pwwu=Pwuw=d3P/dudw2 on this patch given values for the parameters u and w in [0,1]. More...
 
const Mat< 4, 4, Vec3P > & getControlPoints () const
 Return a reference to the Bezier control points B that are stored in this object. More...
 
Mat< 4, 4, Vec3P > & updControlPoints ()
 Return a writable reference to the Bezier control points B that are stored in this object. More...
 
Mat< 4, 4, Vec3PcalcAlgebraicCoefficients () const
 Calculate the algebraic coefficients A from the stored Bezier control points. More...
 
Mat< 4, 4, Vec3PcalcHermiteCoefficients () const
 Calculate the Hermite coefficients H from the stored Bezier control points. More...
 
CubicBezierCurve_< P > getBoundaryCurveU0 () const
 Return the u=0 boundary curve as a Bezier curve segment. More...
 
CubicBezierCurve_< P > getBoundaryCurveU1 () const
 Return the u=1 boundary curve as a Bezier curve segment. More...
 
CubicBezierCurve_< P > getBoundaryCurveW0 () const
 Return the w=0 boundary curve as a Bezier curve segment. More...
 
CubicBezierCurve_< P > getBoundaryCurveW1 () const
 Return the w=1 boundary curve as a Bezier curve segment. More...
 
CubicBezierCurve_< P > calcIsoCurveU (RealP u0) const
 Given a particular value u0 for patch coordinate u, create a cubic Bezier curve segment P(w)=P(u0,w) for the isoparametric curve along the patch at fixed u=u0. More...
 
CubicBezierCurve_< P > calcIsoCurveW (RealP w0) const
 Given a particular value w0 for patch coordinate w, create a cubic Bezier curve segment P(u)=P(u,w0) for the isoparametric curve along the patch at fixed w=w0. More...
 
void splitU (RealP u, BicubicBezierPatch_< P > &patch0, BicubicBezierPatch_< P > &patch1) const
 Split this patch into two along the u direction, along an isoparametric curve of constant u=t such that 0 < t < 1. More...
 
void splitW (RealP w, BicubicBezierPatch_< P > &patch0, BicubicBezierPatch_< P > &patch1) const
 Split this patch into two along the w direction, along an isoparametric curve of constant w=t such that 0 < t < 1. More...
 
void split (RealP u, RealP w, BicubicBezierPatch_< P > &patch00, BicubicBezierPatch_< P > &patch01, BicubicBezierPatch_< P > &patch10, BicubicBezierPatch_< P > &patch11) const
 Split this patch into four subpatches at a particular parametric point (u,w) such that 0 < u,w < 1, with each resulting subpatch covering part of the original parametric domain in each direction. More...
 
Geo::Sphere_< P > calcBoundingSphere () const
 Return a sphere that surrounds the entire patch in the 0<= u,w <=1 range. More...
 
Geo::AlignedBox_< P > calcAxisAlignedBoundingBox () const
 Return an axis-aligned bounding box (AABB) that surrounds the entire patch segment in the 0<= u,w <=1 range. More...
 
Geo::OrientedBox_< P > calcOrientedBoundingBox () const
 Return an oriented bounding box (OBB) that surrounds the entire curve segment in the 0<= u,w <=1 range. More...
 

Static Public Member Functions

Utility methods

These static methods work with given control points.

static Vec3P evalPUsingB (const Mat< 4, 4, Vec3P > &B, RealP u, RealP w)
 Given Bezier control points B and values for the curve parameters u and w in [0..1], return the point P(u,w)=Fb(u)*B*~Fb(w) at that location, where Fb is a vector of Bezier basis functions. More...
 
static void evalP1UsingB (const Mat< 4, 4, Vec3P > &B, RealP u, RealP w, Vec3P &Pu, Vec3P &Pw)
 Given Bezier control points B and values for the curve parameters u and w in [0..1], return the tangents Pu(u,w)=dFb(u)*B*~Fb(w) and Pw(u,w)=Fb(u)*B*~dFb(w) at that location. More...
 
static void evalP2UsingB (const Mat< 4, 4, Vec3P > &B, RealP u, RealP w, Vec3P &Puu, Vec3P &Puw, Vec3P &Pww)
 Given Bezier control points B and values for the curve parameters u and w in [0..1], return the second derivatives Puu(u,w)=d2Fb(u)*B*~Fb(w), Puw(u,w)=dFb(u)*B*~dFb(w) and Pww(u,w)=Fb(u)*B*~d2Fb(w) at that location. More...
 
static void evalP3UsingB (const Mat< 4, 4, Vec3P > &B, RealP u, RealP w, Vec3P &Puuu, Vec3P &Puuw, Vec3P &Puww, Vec3P &Pwww)
 Given Bezier control points B and values for the curve parameters u and w in [0..1], return the third derivatives Puuu(u,w)=d3Fb(u)*B*~Fb(w), Puuw(u,w)=d2Fb(u)*B*~dFb(w), Puww(u,w)=dFb(u)*B*~d2Fb(w) and Pwww(u,w)=Fb(u)*B*~d3Fb(w) at that location. More...
 
static CubicBezierCurve_< P > calcIsoCurveU (const Mat< 4, 4, Vec3P > &B, RealP u0)
 Given a particular value u0 for patch coordinate u, create a cubic Bezier curve segment P(w)=P(u0,w) for the isoparametric curve along the patch at fixed u=u0. More...
 
static CubicBezierCurve_< P > calcIsoCurveW (const Mat< 4, 4, Vec3P > &B, RealP w0)
 Given a particular value w0 for patch coordinate w, create a cubic Bezier curve segment P(u)=P(u,w0) for the isoparametric curve along the patch at fixed w=w0. More...
 
static Mat< 4, 4, Vec3PcalcAFromB (const Mat< 4, 4, Vec3P > &B)
 Given the Bezier control points B, return the equivalent vector algebraic coefficients A. More...
 
static Mat< 4, 4, Vec3PcalcBFromA (const Mat< 4, 4, Vec3P > &A)
 Given the vector algebraic coefficients A, return the equivalent Bezier control points B. More...
 
static Mat< 4, 4, Vec3PcalcHFromB (const Mat< 4, 4, Vec3P > &B)
 Given the Bezier control points B, return the equivalent vector Hermite coefficients H. More...
 
static Mat< 4, 4, Vec3PcalcBFromH (const Mat< 4, 4, Vec3P > &H)
 Given the vector Hermite coefficients H, return the equivalent Bezier control points B. More...
 

Detailed Description

template<class P>
class SimTK::Geo::BicubicBezierPatch_< P >

A primitive useful for computations involving a single bicubic Bezier patch.

Note that a bicubic Bezier spline surface would not necessarily be composed of these, but could use the static methods here for patch computations.

Theory

The primary reference for this implementation is the book "Geometric Modeling, 3rd ed." by Michael E. Mortenson, Industrial Press 2006, chapter 8. We follow Mortenson's notation here (with some name changes) and equation numbers are from the text. See CubicHermiteCurve_ and BicubicHermitePatch_ comments for introductory material; here we add the Bezier description to the algebraic and Hermite (geometric) forms described there.

We use B for Bezier control points (rather than P), and H for Hermite coefficients (rather than B). We call the Bezier basis matrix Mb (same as Mortenson) but call the Hermite basis matrix Mh (rather than Mf).

The 16 control points are laid out like this, matching Mortenson, with the Hermite coefficient matrix for comparison:

        [ b11 b12 b13 b14 ] u=0        [ h00  h01  w00  w01 ]    u=dp/du
    B = [ b21 b22 b23 b24 ]  .     H = [ h10  h11  w10  w11 ]    w=dp/dw
        [ b31 b32 b33 b34 ]  .         [ u00  u01  t00  t01 ]    t=d2p/dudw
        [ b41 b42 b43 b44 ] u=1        [ u10  u11  t10  t11 ]      ("twist")
          w=0   . .   w=1

We store those in a 4x4 hypermatrix; subtract one from each control point index to get the matrix indices (sorry).

To convert between Bezier and Hermite or algebraic forms, use

    A = Mb B ~Mb  (although Mb is symmetric so ~Mb=Mb)
    H = (Mh^-1 Mb) B ~(Mh^-1 Mb)
    B = (Mb^-1 Mh) H ~(Mb^-1 Mh)

where the parenthesized (very simple) matrices are given explicitly in the Theory section for CubicBezierCurve_. The results are:

    [    b11         b14           3(b12-b11)             3(b14-b13)     ]
H = [    b41         b44           3(b42-b41)             3(b44-b43)     ]
    [ 3(b21-b11)  3(b24-b14)  9(b22-b21-{b12-b11})  9({b24-b14}+b13-b23) ]
    [ 3(b41-b31)  3(b44-b34)  9({b42-b41}+b31-b32)  9({b44-b34}+b33-b43) ]

The braces in the twist terms mark common subexpressions, so the conversion from Bezier to Hermite takes 3x28=84 flops (all entries are 3-vectors).

    [   h00            h00+w00/3               h01-w01/3          h01    ]
B = [h00+u00/3 {h00+u00/3}+w00/3+t00/9 {h01+u01/3}-w01/3-t01/9 h01+u01/3 ]
    [h10-u10/3 {h10-u10/3}+w10/3-t10/9 {h11-u11/3}-w11/3+t11/9 h11-u11/3 ]
    [   h10            h10+w10/3               h11-w11/3          h11    ] 

Exploiting the common subexpressions in braces, conversion from Hermite to Bezier takes 3x32=96 flops.

Constructor & Destructor Documentation

template<class P>
SimTK::Geo::BicubicBezierPatch_< P >::BicubicBezierPatch_ ( )
inline

Construct an uninitialized patch; control points will be garbage.

template<class P>
SimTK::Geo::BicubicBezierPatch_< P >::BicubicBezierPatch_ ( const Mat< 4, 4, Vec3P > &  controlPoints)
inlineexplicit

Construct a bicubic Bezier patch using the given control points B.

See the class documentation for how this matrix is defined. If instead you have algebraic or Hermite coefficients, you can first convert them to Bezier control points with the calcBFromA() or calcHFromA() provided here.

Member Function Documentation

template<class P>
Vec3P SimTK::Geo::BicubicBezierPatch_< P >::evalP ( RealP  u,
RealP  w 
) const
inline

Evaluate a point P(u,w) on this patch given values for the parameters u and w in [0,1].

Values outside this range are permitted but do not lie on the patch. Cost is 123 flops.

template<class P>
void SimTK::Geo::BicubicBezierPatch_< P >::evalP1 ( RealP  u,
RealP  w,
Vec3P Pu,
Vec3P Pw 
) const
inline

Evaluate the tangents Pu=dP/du, Pw=dP/dw on this patch given values for the parameters u and w in [0,1].

Values outside this range are permitted but do not lie on the curve segment. Cost is 248 flops.

template<class P>
void SimTK::Geo::BicubicBezierPatch_< P >::evalP2 ( RealP  u,
RealP  w,
Vec3P Puu,
Vec3P Puw,
Vec3P Pww 
) const
inline

Evaluate the second derivatives Puu=d2P/du2, Pww=d2P/dw2, and cross derivative Puw=Pwu=d2P/dudw on this patch given values for the parameters u and w in [0,1].

Values outside this range are permitted but do not lie on the curve segment. Cost is 363 flops.

template<class P>
void SimTK::Geo::BicubicBezierPatch_< P >::evalP3 ( RealP  u,
RealP  w,
Vec3P Puuu,
Vec3P Puuw,
Vec3P Puww,
Vec3P Pwww 
) const
inline

Evaluate the third derivatives Puuu=d3P/du3, Pwww=d3P/dw3, and cross derivatives Puuw=Pwuu=Puwu=d3P/du2dw and Puww=Pwwu=Pwuw=d3P/dudw2 on this patch given values for the parameters u and w in [0,1].

Cost is 468 flops. All higher derivatives of a cubic patch are zero.

template<class P>
const Mat<4,4,Vec3P>& SimTK::Geo::BicubicBezierPatch_< P >::getControlPoints ( ) const
inline

Return a reference to the Bezier control points B that are stored in this object.

See the documentation for this class to see how the returned matrix of control points is defined.

template<class P>
Mat<4,4,Vec3P>& SimTK::Geo::BicubicBezierPatch_< P >::updControlPoints ( )
inline

Return a writable reference to the Bezier control points B that are stored in this object.

See the documentation for this class to see how the returned matrix of control points is defined.

template<class P>
Mat<4,4,Vec3P> SimTK::Geo::BicubicBezierPatch_< P >::calcAlgebraicCoefficients ( ) const
inline

Calculate the algebraic coefficients A from the stored Bezier control points.

See the documentation for BicubicHermitePatch_ to see how the returned matrix of coefficients is defined. Cost is 240 flops.

template<class P>
Mat<4,4,Vec3P> SimTK::Geo::BicubicBezierPatch_< P >::calcHermiteCoefficients ( ) const
inline

Calculate the Hermite coefficients H from the stored Bezier control points.

See the documentation for this class to see how the returned matrix of coefficients is defined. Cost is 84 flops.

template<class P>
CubicBezierCurve_<P> SimTK::Geo::BicubicBezierPatch_< P >::getBoundaryCurveU0 ( ) const
inline

Return the u=0 boundary curve as a Bezier curve segment.

The control points are just the first row of the patch control points B so no computation is required.

template<class P>
CubicBezierCurve_<P> SimTK::Geo::BicubicBezierPatch_< P >::getBoundaryCurveU1 ( ) const
inline

Return the u=1 boundary curve as a Bezier curve segment.

The control points are just the last row of the patch control points B so no computation is required.

template<class P>
CubicBezierCurve_<P> SimTK::Geo::BicubicBezierPatch_< P >::getBoundaryCurveW0 ( ) const
inline

Return the w=0 boundary curve as a Bezier curve segment.

The control points are just the first column of the patch control points B so no computation is required.

template<class P>
CubicBezierCurve_<P> SimTK::Geo::BicubicBezierPatch_< P >::getBoundaryCurveW1 ( ) const
inline

Return the w=1 boundary curve as a Bezier curve segment.

The control points are just the last column of the patch control points B so no computation is required.

template<class P>
CubicBezierCurve_<P> SimTK::Geo::BicubicBezierPatch_< P >::calcIsoCurveU ( RealP  u0) const
inline

Given a particular value u0 for patch coordinate u, create a cubic Bezier curve segment P(w)=P(u0,w) for the isoparametric curve along the patch at fixed u=u0.

Cost is 93 flops.

template<class P>
CubicBezierCurve_<P> SimTK::Geo::BicubicBezierPatch_< P >::calcIsoCurveW ( RealP  w0) const
inline

Given a particular value w0 for patch coordinate w, create a cubic Bezier curve segment P(u)=P(u,w0) for the isoparametric curve along the patch at fixed w=w0.

Cost is 93 flops.

template<class P>
void SimTK::Geo::BicubicBezierPatch_< P >::splitU ( RealP  u,
BicubicBezierPatch_< P > &  patch0,
BicubicBezierPatch_< P > &  patch1 
) const
inline

Split this patch into two along the u direction, along an isoparametric curve of constant u=t such that 0 < t < 1.

On return, patch0 coincides with the u=0..t subpatch, and patch1 coincides with the u=t..1 subpatch. Each of the new patches is reparameterized so that its u parameter goes from 0 to 1, and the w direction remains parameterized as before. This method is only allowed for tol <= t <= 1-tol where tol is the default tolerance for this precision.

Parameters
[in]uThe u parameter of splitting isoparametric curve (tol <= u <= 1-tol).
[out]patch0Subpatch covering domain [0..u,0..1] (contains 0,0 corner).
[out]patch1Subpatch covering domain [u..1,0..1] (contains 1,1 corner).

Cost is 180 flops, or 120 flops if u=1/2.

template<class P>
void SimTK::Geo::BicubicBezierPatch_< P >::splitW ( RealP  w,
BicubicBezierPatch_< P > &  patch0,
BicubicBezierPatch_< P > &  patch1 
) const
inline

Split this patch into two along the w direction, along an isoparametric curve of constant w=t such that 0 < t < 1.

On return, patch0 coincides with the w=0..t subpatch, and patch1 coincides with the w=t..1 subpatch. Each of the new patches is reparameterized so that its w parameter goes from 0 to 1, and the u direction remains parameterized as before. This method is only allowed for tol <= t <= 1-tol where tol is the default tolerance for this precision.

Parameters
[in]wThe w parameter of splitting isoparametric curve (tol <= w <= 1-tol).
[out]patch0Subpatch covering domain [0..1,0..w] (contains 0,0 corner).
[out]patch1Subpatch covering domain [0..1,w..1] (contains 1,1 corner).

Cost is 180 flops, or 120 flops if w=1/2.

template<class P>
void SimTK::Geo::BicubicBezierPatch_< P >::split ( RealP  u,
RealP  w,
BicubicBezierPatch_< P > &  patch00,
BicubicBezierPatch_< P > &  patch01,
BicubicBezierPatch_< P > &  patch10,
BicubicBezierPatch_< P > &  patch11 
) const
inline

Split this patch into four subpatches at a particular parametric point (u,w) such that 0 < u,w < 1, with each resulting subpatch covering part of the original parametric domain in each direction.

The subpatches are reparametrized to have [0..1,0..1] domains. This method is only allowed for tol <= u,w <= 1-tol where tol is the default tolerance for this precision.

Parameters
[in]uThe u parameter of the splitting point (tol <= u <= 1-tol).
[in]wThe w parameter of the splitting point (tol <= w <= 1-tol).
[out]patch00Subpatch covering domain [0..u,0..w] (contains 0,0 corner).
[out]patch01Subpatch covering domain [0..u,w..1] (contains 0,1 corner).
[out]patch10Subpatch covering domain [u..1,0..w] (contains 1,0 corner).
[out]patch11Subpatch covering domain [u..1,w..1] (contains 1,1 corner).

Cost is 360, 420, or 540 flops depending on whether both, one, or neither parameter is 1/2.

template<class P>
Geo::Sphere_<P> SimTK::Geo::BicubicBezierPatch_< P >::calcBoundingSphere ( ) const
inline

Return a sphere that surrounds the entire patch in the 0<= u,w <=1 range.

template<class P>
Geo::AlignedBox_<P> SimTK::Geo::BicubicBezierPatch_< P >::calcAxisAlignedBoundingBox ( ) const
inline

Return an axis-aligned bounding box (AABB) that surrounds the entire patch segment in the 0<= u,w <=1 range.

template<class P>
Geo::OrientedBox_<P> SimTK::Geo::BicubicBezierPatch_< P >::calcOrientedBoundingBox ( ) const
inline

Return an oriented bounding box (OBB) that surrounds the entire curve segment in the 0<= u,w <=1 range.

template<class P>
static Vec3P SimTK::Geo::BicubicBezierPatch_< P >::evalPUsingB ( const Mat< 4, 4, Vec3P > &  B,
RealP  u,
RealP  w 
)
inlinestatic

Given Bezier control points B and values for the curve parameters u and w in [0..1], return the point P(u,w)=Fb(u)*B*~Fb(w) at that location, where Fb is a vector of Bezier basis functions.

Cost is 3x35+18=123 flops.

template<class P>
static void SimTK::Geo::BicubicBezierPatch_< P >::evalP1UsingB ( const Mat< 4, 4, Vec3P > &  B,
RealP  u,
RealP  w,
Vec3P Pu,
Vec3P Pw 
)
inlinestatic

Given Bezier control points B and values for the curve parameters u and w in [0..1], return the tangents Pu(u,w)=dFb(u)*B*~Fb(w) and Pw(u,w)=Fb(u)*B*~dFb(w) at that location.

Cost is 3x70+38=248 flops.

template<class P>
static void SimTK::Geo::BicubicBezierPatch_< P >::evalP2UsingB ( const Mat< 4, 4, Vec3P > &  B,
RealP  u,
RealP  w,
Vec3P Puu,
Vec3P Puw,
Vec3P Pww 
)
inlinestatic

Given Bezier control points B and values for the curve parameters u and w in [0..1], return the second derivatives Puu(u,w)=d2Fb(u)*B*~Fb(w), Puw(u,w)=dFb(u)*B*~dFb(w) and Pww(u,w)=Fb(u)*B*~d2Fb(w) at that location.

Cost is 3x105+48=363 flops.

template<class P>
static void SimTK::Geo::BicubicBezierPatch_< P >::evalP3UsingB ( const Mat< 4, 4, Vec3P > &  B,
RealP  u,
RealP  w,
Vec3P Puuu,
Vec3P Puuw,
Vec3P Puww,
Vec3P Pwww 
)
inlinestatic

Given Bezier control points B and values for the curve parameters u and w in [0..1], return the third derivatives Puuu(u,w)=d3Fb(u)*B*~Fb(w), Puuw(u,w)=d2Fb(u)*B*~dFb(w), Puww(u,w)=dFb(u)*B*~d2Fb(w) and Pwww(u,w)=Fb(u)*B*~d3Fb(w) at that location.

Cost is 3x140+48=468 flops.

template<class P>
static CubicBezierCurve_<P> SimTK::Geo::BicubicBezierPatch_< P >::calcIsoCurveU ( const Mat< 4, 4, Vec3P > &  B,
RealP  u0 
)
inlinestatic

Given a particular value u0 for patch coordinate u, create a cubic Bezier curve segment P(w)=P(u0,w) for the isoparametric curve along the patch at fixed u=u0.

Cost is 3x28+9=93 flops.

template<class P>
static CubicBezierCurve_<P> SimTK::Geo::BicubicBezierPatch_< P >::calcIsoCurveW ( const Mat< 4, 4, Vec3P > &  B,
RealP  w0 
)
inlinestatic

Given a particular value w0 for patch coordinate w, create a cubic Bezier curve segment P(u)=P(u,w0) for the isoparametric curve along the patch at fixed w=w0.

Cost is 3x28+9=93 flops.

template<class P>
static Mat<4,4,Vec3P> SimTK::Geo::BicubicBezierPatch_< P >::calcAFromB ( const Mat< 4, 4, Vec3P > &  B)
inlinestatic

Given the Bezier control points B, return the equivalent vector algebraic coefficients A.

All coefficients are 3-vectors. Cost is 3x80=240 flops.

template<class P>
static Mat<4,4,Vec3P> SimTK::Geo::BicubicBezierPatch_< P >::calcBFromA ( const Mat< 4, 4, Vec3P > &  A)
inlinestatic

Given the vector algebraic coefficients A, return the equivalent Bezier control points B.

All coefficients are 3-vectors. Cost is 3x72=216 flops.

template<class P>
static Mat<4,4,Vec3P> SimTK::Geo::BicubicBezierPatch_< P >::calcHFromB ( const Mat< 4, 4, Vec3P > &  B)
inlinestatic

Given the Bezier control points B, return the equivalent vector Hermite coefficients H.

All coefficients are 3-vectors. Cost is 3x28=84 flops.

template<class P>
static Mat<4,4,Vec3P> SimTK::Geo::BicubicBezierPatch_< P >::calcBFromH ( const Mat< 4, 4, Vec3P > &  H)
inlinestatic

Given the vector Hermite coefficients H, return the equivalent Bezier control points B.

All coefficients are 3-vectors. Cost is 3x32=96 flops.


The documentation for this class was generated from the following files: