Re: general transformation

New Message Reply Date view Thread view Subject view Author view

From: Simon C Mills (simon++at++wgs.estec.esa.nl)
Date: 01/08/2001 00:47:45


Mark Evans wrote:
>
> I would like to know if there is a way to find the
> general transformation of a node in the Performer
> hierarchy, if I know the node and his parent, the
> parent of his parent, etc - i.e., I know the exact
> location of the node in the hierarchy.
> The cmplicated way is to get the transform of the
> parent, and parent of the parent, etc, till we get to
> the highest node in the hierarchy, and multiply the
> matrices. Is there a simpler way?

It's no big deal to make a recursive function that, given a node,
multiplies all transform matrices up the tree to the root. For example:

void
ComputeAbsPos(pfNode *root, pfNode *node, pfMatrix &m)
{
    /* If node is null, return identity */
    if (node == NULL) {
        PFMAKE_IDENT_MAT(m);
        pfNotify(PFNFY_DEBUG, PFNFY_PRINT, "ComputeAbsPos: NULL node");
        return;
    }
    
    /* If node is SCS/DCS set matrix to node's matrix, otherwise
identity */
    if (node->isOfType(pfSCS::getClassType()))
        ((pfSCS *) node)->getMat(m);
    else
        PFMAKE_IDENT_MAT(m);
        
    /* If node is a child express in parent's coordinate system */
    if (node->getNumParents() > 0) {
        pfMatrix mparent;
        pfNode *parent;
        
        /* use the first parent */
        parent = (pfNode *) node->getParent(0);
        if (parent == root)
            return;
        ComputeAbsPos(root, parent, mparent);
        m.postMult(mparent);
    }
}

This makes the assumption that the nodes in question are not instanced
in more than one place in which case there will be more than one parent
to the node. One way around that is to take a look at the pfTraverser
functionality which I've also used for the same purpose. During a
traverse the current transformation matrix, which is what you want, can
be obtained.

Regards, Simon
_______________________________________________________________________

Simon Mills
Modelling & Simulation Section (TOS-EMM) Tel: +31 (0)71 565 3725
European Space Agency (ESA/ESTEC) Fax: +31 (0)71 565 5419
Postbus 299, 2200AG Noordwijk e-mail: simon++at++wgs.estec.esa.nl
The Netherlands http://www.estec.esa.nl/wmwww/EMM
_______________________________________________________________________


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Mon Jan 08 2001 - 00:47:30 PST

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