How to simplify a matrix operation

New Message Reply Date view Thread view Subject view Author view

From: William Sherman -Visualization (wsherman++at++ncsa.uiuc.edu)
Date: 01/10/2002 10:04:16


pfHello,

I'm curious as to why the following command can't be compiled:

        my_dcs->getMatPtr()->preMult(pfMatrix::makeRot(-90.0, 1.0, 0.0, 0.0));

I suppose it's a C++ thing, and I'm much better at C than C++, but it
seems to me that doing this in one-line should be possible. The reason
I want to do it in one line is twofold: it saves me from declaring two
temporary pfMatrices, and it's a single logical operation (pre-rotate the
dcs by 90 degrees about the -X axis).

Perhaps with a slight tweak of the syntax (more parentheses?) this can
be made to work -- I hope. Here are the two error messages generated
by this line:

    pfMatrix::makeRot(-90.0, 1.0, 0.0, 0.0)
    error(3326): a nonstatic member reference must be relative to a specific object

I guess that alone implies that I won't be able to get away without one
temporary matrix.

and:
    my_dcs->getMatPtr()
    error(3396): function may not be called for const- or volatile-qualified object

At first I hoped the following would work (with only one temp matrix):
{
        pfMatrix tmpmat;

        tmpmat.makeRot(-90.0, 1.0, 0.0, 0.0);
        my_dcs->getMatPtr()->preMult(tmpmat);
}

Here is what did work:
{
        pfMatrix tmpmat1, tmpmat2;

        tmpmat1.makeRot(-90.0, 1.0, 0.0, 0.0);
        my_dcs->getMat(tmpmat2); /* WARNING: unobvious call-by-ref */
        tmpmat2.preMult(tmpmat1);
        my_dcs->setMat(tmpmat2); /* WARNING: unobvious call-by-ref */
}

        Thanks,
        Bill

/*************************************************************************/
/* Bill Sherman (wsherman++at++ncsa.uiuc.edu) */
/* National Center for Supercomputing Applications */
/* University of Illinois at Urbana-Champaign */
/* Og - "You want to do mankind a real service? Tell funnier jokes" */
/* Spinner - "but facts don't always reveal the truth" */
/* Robin - "Yeah, but I always figure that's the writers' fault" */
/*************************************************************************/


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Thu Jan 10 2002 - 10:01:54 PST

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.