Main Page   Modules   Alphabetical List   Data Structures   Data Fields  

RtBezPat
[Math Tools]


Data Structures

struct   RtBezierV4d

Typedefs

typedef RtBezierV4d  RtBezierRow [4]
typedef RtBezierRow  RtBezierMatrix [4]

Functions

void  RtBezierQuadControlFit3d (RtBezierMatrix B, RtBezierMatrix P)
void  RtBezierQuadBernsteinWeight3d (RtBezierMatrix W, RtBezierMatrix B)
void  RtBezierQuadBernsteinWeight4d (RtBezierMatrix W, RtBezierMatrix B)
void  RtBezierQuadPointDifference3d (RtBezierMatrix D, RtBezierMatrix W, RwReal PointU, RwReal PointV, RwReal StepU, RwReal stepV)
void  RtBezierQuadPointDifference4d (RtBezierMatrix D, RtBezierMatrix W, RwReal PointU, RwReal PointV, RwReal StepU, RwReal stepV)
void  RtBezierQuadOriginDifference3d (RtBezierMatrix D, RtBezierMatrix W, RwReal stepU, RwReal setpV)
void  RtBezierQuadOriginDifference4d (RtBezierMatrix D, RtBezierMatrix W, RwReal stepU, RwReal setpV)
void  RtBezierQuadTangent (RtBezierMatrix D, RwReal theta, RtBezierMatrix P)
void  RtBezierQuadTangentPair (RtBezierMatrix Dt, RtBezierMatrix Dp, RwReal theta, RtBezierMatrix P)
void  RtBezierQuadGetNormals (RtBezierMatrix N, RtBezierMatrix B)
void  RtBezierQuadSample3d (RwV3d *out, RtBezierMatrix B, RwReal u, RwReal v)
void  RtBezierQuadDifferenceStepU3d (RtBezierRow row)
void  RtBezierQuadDifferenceStepU4d (RtBezierRow row)
void  RtBezierQuadDifferenceStepV3d (RtBezierMatrix mat)
void  RtBezierQuadDifferenceStepV4d (RtBezierMatrix mat)
void  RtBezierTriangleControlFit3d (RtBezierMatrix T, RtBezierMatrix P)
void  RtBezierQuadFromTriangle (RtBezierMatrix Q, RtBezierMatrix T)

Detailed Description

The Bezier Patch Toolkit is a group of functions that support the way RenderWare processes patches.

RtBezPat Toolkit Overview

Requirements

Overview

The toolkit is a group of void functions in RenderWare Graphics that support the Bezier patch code. The functions are useful beyond the facilities that RenderWare supports, so they are provided and documented in the Toolkit for the developer to use. They use three data types in addition to those documented in the Bezier Patch plugin, RpPatch
  1. RtBezierV4d is the RenderWare vector that holds four values. The first three would typically be positional x, y and z.
  2. RtBezierRow is an array of four RtBezierV4d's, one for each control point of a Bezier spline. Thus any row of control points across a patch can be stored in an RtBezierRow.
  3. RtBezierMatrix is an array of four RtBezierRow's. So the matrix holds all sixteen control points of a patch. It can hold the coordinates of quad patches or tri patches, and the vectors could represent surface points instead of control points. Alternatively it can represent normal vectors, tangents and "difference" values; all these are used in the Bezier Toolkit functions.

A Bezier curve can be measured in "u". At the first control point u=0. At the last, u=1 and at the other two control points, u=1/3 and u=2/3. This is applied to patches, so that one edge is measured in "u". The transverse edge is also a Bezier curved measured in "v", with control points at v=0, v=1/3, v=2/3 and v=1. This notation is used in some functions.

The Toolkit functions fall into four groups.

  1. RtBezierQuadFromTriangle is given the control points for a tri patch and returns an RtBezierMatrix containing the control points for an equivalent Bezier quad patch. This is a utility function to serve several other functions that take only quad patches as parameters.
  2. RtBezierQuadControlFit3d and RtBezierTriangleControlFit3d calculate the control points that generate surfaces passing through the supplied on-curve sample control points. RtBezierQuadSample3d converts from control points to surface points. This calculates any point on the patch's surface.
  3. RtBezierQuadBernsteinWeight3d and RtBezierQuadBernsteinWeight4d pre-calculate many of the Bernstein matrix-multiplications needed for patches. The former addresses x, y, and z whilst the latter addresses x, y, z and an extra parameter, w. RtBezierQuadPointDifference3d and RtBezierQuadPointDifference4d calculate "forward differences" starting at an arbitrary parameter point. The former addresses x, y, and z whilst the latter addresses x, y, z and w. RtBezierQuadOriginDifference3d and RtBezierQuadOriginDifference4d calculate forward differences starting at the parameter origin. The former addresses x, y, and z whilst the latter addresses x, y, z and w. These speed up the calculation of patch coordinates. They are used with RtBezierQuadDifferenceStepU3d RtBezierQuadDifferenceStepU4d and RtBezierQuadDifferenceStepV3d RtBezierQuadDifferenceStepV4d which update values when stepping across or down a patch.
  4. RtBezierQuadTangent, RtBezierQuadTangentPair and RtBezierQuadGetNormals calculate the directions of normal vectors and of tangents at each vertex of a patch.

Typedef Documentation

typedef RtBezierRow RtBezierMatrix[4]
 

RtBezierMatrix typedef for a matrix of 4*4 vectors. RtBezierMatrix is an array of 4 rows.

typedef RtBezierV4d RtBezierRow[4]
 

RtBezierRow typedef for a row of vectors. RtBezierRow is an array of 4 vectors


Function Documentation

void RtBezierQuadBernsteinWeight3d RtBezierMatrix    W,
RtBezierMatrix    B
 

RtBezierQuadBernsteinWeight3d returns a Bernstein weighted matrix for an input control point matrix, addressing x, y, and z coordinates.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

Parameters:
W  Output difference matrix
B  Input Bezier matrix
See also:
RtBezierQuadDifferenceStepU3d , RtBezierQuadDifferenceStepV3d , RtBezierQuadSample3d
void RtBezierQuadBernsteinWeight4d RtBezierMatrix    W,
RtBezierMatrix    B
 

RtBezierQuadBernsteinWeight4d returns a Bernstein weighted matrix for an input control point matrix, addressing x, y, z, and w coordinates.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

Parameters:
W  Output difference matrix
B  Input Bezier matrix
See also:
RtBezierQuadDifferenceStepU4d , RtBezierQuadDifferenceStepV4d , RtBezierQuadSample3d
void RtBezierQuadControlFit3d RtBezierMatrix    B,
RtBezierMatrix    P
 

RtBezierQuadControlFit3d returns the control points for a Bezier quadrilateral fitted to pass through the supplied sample points, addressing x, y, and z coordinates.

Parameters:
B  Output Bezier control point matrix
P  Input sample point matrix
void RtBezierQuadDifferenceStepU3d RtBezierRow    row
 

RtBezierQuadDifferenceStepU3d updates a difference row for a step in the u patch parameter addressing x, y, and z coordinates.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

Parameters:
row  Difference row to update for a step in the u patch coordinate
See also:
RtBezierQuadDifferenceStepV3d , RtBezierQuadBernsteinWeight3d , RtBezierQuadOriginDifference3d , RtBezierQuadSample3d
The following code illustrates the use of RtBezierQuadDifferenceStepU3d
    static RtBezierMatrix control =
    {
        {{00,00,00,-1}, {30,00,00,-1}, {60,00,00,-1}, {90,00,00,-1}},
        {{00,30,00,-1}, {30,30,30,-1}, {60,30,00,-1}, {90,30,00,-1}},
        {{00,60,00,-1}, {30,60,90,-1}, {60,60,60,-1}, {90,60,00,-1}},
        {{00,90,00,-1}, {30,90,00,-1}, {60,90,00,-1}, {90,90,90,-1}}
    };
    RwInt32             j;
    RtBezierMatrix      weight;
    RtBezierMatrix      difference;

    RtBezierQuadBernsteinWeight3d(weight, control);

    RtBezierQuadOriginDifference3d(difference, weight, 
                                  ((RwReal) 1) / ((RwReal) 8),
                                  ((RwReal) 1) / ((RwReal) 8));

    for (j = 0; j <= 8; j++)
    {
        const RwReal        v = ((RwReal) j) / ((RwReal) resV);
        RtBezierRow         row;
        RwInt32             i;

        row[0] = difference[0][0];
        row[1] = difference[0][1];
        row[2] = difference[0][2];
        row[3] = difference[0][3];
 
        for (i = 0; i <= 8; i++)
        {
            const RwReal    u = ((RwReal) i) / ((RwReal) 8);

            // row[0] now contains the point at (u,v) on the Bezier surface

            RtBezierQuadDifferenceStepU3d(row);
        }
        RtBezierQuadDifferenceStepV3d(difference);
    }
   
void RtBezierQuadDifferenceStepU4d RtBezierRow    row
 

RtBezierQuadDifferenceStepU4d updates a difference row for a step in the u patch parameter, addressing x, y, z, and w coordinates.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

Parameters:
row  Difference row to update for a step in the u patch coordinate
See also:
RtBezierQuadDifferenceStepV4d , RtBezierQuadBernsteinWeight4d , RtBezierQuadOriginDifference4d
The following code illustrates the use of RtBezierQuadDifferenceStepU4d
    static RtBezierMatrix control =
    {
        {{00,00,00,-1}, {30,00,00,-1}, {60,00,00,-1}, {90,00,00,-1}},
        {{00,30,00,-1}, {30,30,30,-1}, {60,30,00,-1}, {90,30,00,-1}},
        {{00,60,00,-1}, {30,60,90,-1}, {60,60,60,-1}, {90,60,00,-1}},
        {{00,90,00,-1}, {30,90,00,-1}, {60,90,00,-1}, {90,90,90,-1}}
    };
    RwInt32             j;
    RtBezierMatrix      weight;
    RtBezierMatrix      difference;

    RtBezierQuadBernsteinWeight4d(weight, control);

    RtBezierQuadOriginDifference4d(difference, weight, 
                                  ((RwReal) 1) / ((RwReal) 8),
                                  ((RwReal) 1) / ((RwReal) 8));

    for (j = 0; j <= 8; j++)
    {
        const RwReal        v = ((RwReal) j) / ((RwReal) resV);
        RtBezierRow         row;
        RwInt32             i;

        row[0] = difference[0][0];
        row[1] = difference[0][1];
        row[2] = difference[0][2];
        row[3] = difference[0][3];
 
        for (i = 0; i <= 8; i++)
        {
            const RwReal    u = ((RwReal) i) / ((RwReal) 8);

            // row[0] now contains the point at (u,v) on the Bezier surface

            RtBezierQuadDifferenceStepU4d(row);
        }
        RtBezierQuadDifferenceStepV4d(difference);
    }
   
void RtBezierQuadDifferenceStepV3d RtBezierMatrix    mat
 

RtBezierQuadDifferenceStepV3d updates a difference matrix for a step in the v patch parameter, addressing x, y, and z coordinates.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

Parameters:
mat  Difference matrix to update for a step in the v patch coordinate
See also:
RtBezierQuadDifferenceStepU3d , RtBezierQuadBernsteinWeight3d , RtBezierQuadOriginDifference3d , RtBezierQuadSample3d
The following code illustrates the use of RtBezierQuadDifferenceStepV3d
    static RtBezierMatrix control =
    {
        {{00,00,00,-1}, {30,00,00,-1}, {60,00,00,-1}, {90,00,00,-1}},
        {{00,30,00,-1}, {30,30,30,-1}, {60,30,00,-1}, {90,30,00,-1}},
        {{00,60,00,-1}, {30,60,90,-1}, {60,60,60,-1}, {90,60,00,-1}},
        {{00,90,00,-1}, {30,90,00,-1}, {60,90,00,-1}, {90,90,90,-1}}
    };
    RwInt32             j;
    RtBezierMatrix      weight;
    RtBezierMatrix      difference;

    RtBezierQuadBernsteinWeight3d(weight, control);

    RtBezierQuadOriginDifference3d(difference, weight, 
                                  ((RwReal) 1) / ((RwReal) 8),
                                  ((RwReal) 1) / ((RwReal) 8));

    for (j = 0; j <= 8; j++)
    {
        const RwReal        v = ((RwReal) j) / ((RwReal) resV);
        RtBezierRow         row;
        RwInt32             i;

        row[0] = difference[0][0];
        row[1] = difference[0][1];
        row[2] = difference[0][2];
        row[3] = difference[0][3];
 
        for (i = 0; i <= 8; i++)
        {
            const RwReal    u = ((RwReal) i) / ((RwReal) 8);

            // row[0] now contains the point at (u,v) on the Bezier surface

            RtBezierQuadDifferenceStepU3d(row);
        }
        RtBezierQuadDifferenceStepV3d(difference);
    }
   
void RtBezierQuadDifferenceStepV4d RtBezierMatrix    mat
 

RtBezierQuadDifferenceStepV4d updates a difference matrix for a step in the v patch parameter, addressing x, y, z, and w coordinates.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

Parameters:
mat  Difference matrix to update for a step in the v patch coordinate
See also:
RtBezierQuadDifferenceStepU4d , RtBezierQuadBernsteinWeight4d , RtBezierQuadOriginDifference4d
The following code illustrates the use of RtBezierQuadDifferenceStepV4d
    static RtBezierMatrix control =
    {
        {{00,00,00,-1}, {30,00,00,-1}, {60,00,00,-1}, {90,00,00,-1}},
        {{00,30,00,-1}, {30,30,30,-1}, {60,30,00,-1}, {90,30,00,-1}},
        {{00,60,00,-1}, {30,60,90,-1}, {60,60,60,-1}, {90,60,00,-1}},
        {{00,90,00,-1}, {30,90,00,-1}, {60,90,00,-1}, {90,90,90,-1}}
    };
    RwInt32             j;
    RtBezierMatrix      weight;
    RtBezierMatrix      difference;

    RtBezierQuadBernsteinWeight4d(weight, control);

    RtBezierQuadOriginDifference4d(difference, weight, 
                                  ((RwReal) 1) / ((RwReal) 8),
                                  ((RwReal) 1) / ((RwReal) 8));

    for (j = 0; j <= 8; j++)
    {
        const RwReal        v = ((RwReal) j) / ((RwReal) resV);
        RtBezierRow         row;
        RwInt32             i;

        row[0] = difference[0][0];
        row[1] = difference[0][1];
        row[2] = difference[0][2];
        row[3] = difference[0][3];
 
        for (i = 0; i <= 8; i++)
        {
            const RwReal    u = ((RwReal) i) / ((RwReal) 8);

            // row[0] now contains the point at (u,v) on the Bezier surface

            RtBezierQuadDifferenceStepU4d(row);
        }
        RtBezierQuadDifferenceStepV4d(difference);
    }
   
void RtBezierQuadFromTriangle RtBezierMatrix    Q,
RtBezierMatrix    T
 

RtBezierQuadFromTriangle takes a matrix of 10 control points for a tri patch, and returns a matrix of 16 control points for a quad patch. The side of the tri patch defined by control points 9-8-6-3 becomes quad patch's diagonal 12-9-6-3.

Parameters:
Q  Output control points of a Bezier quadrilateral patch
T  Input control points of a Bezier triangular patch
void RtBezierQuadGetNormals RtBezierMatrix    N,
RtBezierMatrix    B
 

RtBezierQuadGetNormals calculates the surface normals corresponding to the control points of a Bezier quadrilateral patch.

Parameters:
N  Output matrix of normals
B  Input matrix of 16 control points for a Bezier quadrilateral patch
void RtBezierQuadOriginDifference3d RtBezierMatrix    D,
RtBezierMatrix    W,
RwReal    StepU,
RwReal    StepV
 

RtBezierQuadOriginDifference3d returns a difference matrix for an input Bernstein weight matrix at the parameter origin, addressing x, y, and z coordinates.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

Parameters:
D  Output difference matrix
W  Input Bernstein weighted matrix
StepU  Patch u coordinate difference per step
StepV  Patch v coordinate difference per step
See also:
RtBezierQuadDifferenceStepU3d , RtBezierQuadDifferenceStepV3d , RtBezierQuadSample3d
void RtBezierQuadOriginDifference4d RtBezierMatrix    D,
RtBezierMatrix    W,
RwReal    StepU,
RwReal    StepV
 

RtBezierQuadOriginDifference4d returns a difference matrix for an input Bernstein weight matrix at the parameter origin, addressing x, y, z, and w coordinates.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

Parameters:
D  Output difference matrix
W  Input Bernstein weighted matrix
StepU  Patch u coordinate difference per step
StepV  Patch v coordinate difference per step
See also:
RtBezierQuadDifferenceStepU4d , RtBezierQuadDifferenceStepV4d
void RtBezierQuadPointDifference3d RtBezierMatrix    D,
RtBezierMatrix    W,
RwReal    PointU,
RwReal    PointV,
RwReal    StepU,
RwReal    StepV
 

RtBezierQuadPointDifference3d returns a difference matrix for an input Bernstein weight matrix at an arbitrary initial parameter point, addressing x, y, and z coordinates.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

Parameters:
D  Output difference matrix
W  Input Bernstein weighted matrix
PointU  Patch pointu coordinate
PointV  Patch point v coordinate
StepU  Patch u coordinate difference per step
StepV  Patch v coordinate difference per step
See also:
RtBezierQuadDifferenceStepU3d , RtBezierQuadDifferenceStepV3d , RtBezierQuadSample3d
void RtBezierQuadPointDifference4d RtBezierMatrix    D,
RtBezierMatrix    W,
RwReal    PointU,
RwReal    PointV,
RwReal    StepU,
RwReal    StepV
 

RtBezierQuadPointDifference4d returns a difference matrix for an input Bernstein weight matrix at an arbitrary initial parameter point, addressing x, y, z, and w coordinates.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

Parameters:
D  Output difference matrix
W  Input Bernstein weighted matrix
PointU  Patch point u coordinate
PointV  Patch point v coordinate
StepU  Patch u coordinate difference per step
StepV  Patch v coordinate difference per step
See also:
RtBezierQuadDifferenceStepU4d , RtBezierQuadDifferenceStepV4d
void RtBezierQuadSample3d RwV3d   out,
RtBezierMatrix    B,
RwReal    u,
RwReal    v
 

RtBezierQuadSample3d returns a point on a Bezier patch at the specified parameter point, addressing x, y, and z coordinates.

Parameters:
out  Output point on Bezier patch
B  Matrix of Bezier control points
u  patch coordinate in [0,1]
v  patch coordinate in [0,1]
See also:
RtBezierQuadDifferenceStepU3d , RtBezierQuadDifferenceStepV3d
The following code illustrates the use of RtBezierQuadSample3d
    static RtBezierMatrix control =
    {
        {{00,00,00,-1}, {30,00,00,-1}, {60,00,00,-1}, {90,00,00,-1}},
        {{00,30,00,-1}, {30,30,30,-1}, {60,30,00,-1}, {90,30,00,-1}},
        {{00,60,00,-1}, {30,60,90,-1}, {60,60,60,-1}, {90,60,00,-1}},
        {{00,90,00,-1}, {30,90,00,-1}, {60,90,00,-1}, {90,90,90,-1}}
    };
    RwInt32             i;
    RwInt32             j;
    RwReal              u;
    RwReal              v;
    RwV3d               p;

    for (j = 0; j <= 8; j++)
    {
        v = ((RwReal) j) / ((RwReal) 8);

        for (i = 0; i <= 8; i++)
        {
            u = ((RwReal) i) / ((RwReal) 8);

            RtBezierQuadSample3d(&p, control, u, v);

            // p now contains the point at (u,v) on the Bezier surface
        }
    }
   
void RtBezierQuadTangent RtBezierMatrix    D,
RwReal    theta,
RtBezierMatrix    P
 

RtBezierQuadTangent returns a 16 control point matrix for the tangents over a Bezier quadrilateral.

Parameters:
D  Matrix of 16 control points for tangents in the parameter direction theta
theta  Parameter direction theta
P  Matrix of 16 control points for a Bezier quadrilateral patch
void RtBezierQuadTangentPair RtBezierMatrix    Dt,
RtBezierMatrix    Dp,
RwReal    theta,
RtBezierMatrix    P
 

RtBezierQuadTangentPair returns 2 matrices, of 16 control points each, the tangents over a Bezier quadrilateral patch.

Parameters:
Dt  Matrix of 16 control points for tangents in the parameter direction theta
Dp  Matrices of 16 control points for tangents in the parameter direction at right angles to theta
theta  Parameter direction theta
P  Matrix of 16 control points for a Bezier quadrilateral patch
void RtBezierTriangleControlFit3d RtBezierMatrix    T,
RtBezierMatrix    P
 

RtBezierTriangleControlFit3d returns the control points for a Bezier triangle fitted to pass through the supplied sample points, addressing x, y, and z coordinates.

Parameters:
T  Output Bezier control point matrix
P  Input sample point matrix

Criterion Software © 1993-2003 Criterion Software Limited. All rights reserved. Built Tue Apr 22 12:46:53 2003. Send Feedback
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)