<< Click to Display Table of Contents >> Navigation: User DLLs > Writing DLLs > Samples > ex_move |
// dcs headers
#include "dcs_defn.h"
#include "dcs_ufnc.h"
#include "userfunc.h"
/****************************************************************************/
/* Implement your move routines here */
/****************************************************************************/
// This is a sample move .dll function that performs a three point move.
char dcsMoveName1[] = "Example Move";
char* dcsGetMoveFuncName1() { return dcsMoveName1;}
void userMoveFunc1(dcsDataPtr* pDataPtr)
{
wpMOVECAL_s* pMovePtr = (wpMOVECAL_s*)pDataPtr;
if (pMovePtr == wpNULL) return;
pMovePtr->m_IsMvInfoCal = wpTRUE;
int objNum = pMovePtr->m_NumObjVec; // number of object points
int tgtNum = pMovePtr->m_NumTgtVec; // number of target points
if (objNum != 3 || tgtNum != 3) return; // enforce move requirements
// get move data
int ii;
wpVEC3D_s objVec[3];
wpVEC3D_s tgtVec[3];
wpBOOL retv;
for (ii = 0; ii < 3; ii++)
{
objVec[ii] = mvGlbGetObjVec(pMovePtr, ii); // object vectors
tgtVec[ii] = mvGlbGetTgtVec(pMovePtr, ii); // target vectors
}
// get three point move parameters
wpVEC3D_s transVec; // translation vector
wpVEC3D_s axis1, axis2; // rotation axes
double angle1, angle2; // rotation angles
retv = mvGlbThreePt3Move(objVec[0], objVec[1], objVec[2], // three point move
tgtVec[0], tgtVec[1], tgtVec[2], &transVec, &axis1, &angle1, &axis2, &angle2);
if (retv == wpFALSE) pMovePtr->m_IsMvInfoCal = wpFALSE;
// pass move information back to 3-Dcs
if (pMovePtr->m_IsMvInfoCal != wpFALSE)
{
wpVEC3D_s rtVec = tgtVec[0]; // rotation point
int pairNum = 2;
mvGlbSetMovePairNum(pMovePtr, pairNum); // allocate memory
ii = 0;
mvGlbSetMoveTrInfo(pMovePtr, ii, transVec); // pass translation vector
mvGlbSetMoveRtInfo(pMovePtr, ii, rtVec, axis1, angle1); // pass rotation information
ii++;
mvGlbSetMoveRtInfo(pMovePtr, ii, rtVec, axis2, angle2); // pass rotation information
}
}