From: Paul C. <pa...@us...> - 2005-03-23 00:24:05
|
Update of /cvsroot/emc/emc2/src/emc/nml_intf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24667 Added Files: Tag: bdi-4 emcpos.cc Log Message: Take advantage of the overloaded operators in emcpos.cc - Helps to commit the file in question... --- NEW FILE: emcpos.cc --- /******************************************************************** * * Description: emcpos.cc * An attempt to add some mathematical operators to the EmcPose * struct to simplify operations elsewhere. * * Author: Paul Corner * License: GPL Version 2 * System: Linux * * Copyright (c) 2005 All rights reserved. * * Last change: * $Revision: 1.1.2.1 $ * $Author: paul_c $ * $Date: 2005/03/23 00:23:38 $ ********************************************************************/ #include "rcs.hh" #include "posemath.h" /* PmCartesian */ #include "emcpos.h" /* Declare this here rather than in the struct. To do so in EmcPose kinda makes a mess of the shm model unless it is in both the C++ & C versions... But then it causes probs when trying to maintain compatability with older builds.. */ double dummy; double & EmcPose::operator[](int i) { switch (i) { case 0: return tran.x; break; case 1: return tran.y; break; case 2: return tran.z; break; case 3: return a; break; case 4: return b; break; case 5: return c; break; } // Out of range - Return a dummy value. return dummy; } EmcPose EmcPose::operator - (EmcPose v1) { EmcPose r1; r1.tran.x = tran.x - v1.tran.x; r1.tran.y = tran.y - v1.tran.y; r1.tran.z = tran.z - v1.tran.z; r1.a = a - v1.a; r1.b = b - v1.b; r1.c = c - v1.c; return r1; } EmcPose EmcPose::operator + (EmcPose v1) { EmcPose r1; r1.tran.x = tran.x + v1.tran.x; r1.tran.y = tran.y + v1.tran.y; r1.tran.z = tran.z + v1.tran.z; r1.a = a + v1.a; r1.b = b + v1.b; r1.c = c + v1.c; return r1; } bool EmcPose::operator == (EmcPose v1) { if ((tran.x == v1.tran.x) && (tran.y == v1.tran.y) && (tran.z == v1.tran.z) && (a == v1.a) && (b == v1.b) && (c == v1.c)) { return 1; } return 0; } bool EmcPose::operator != (EmcPose v1) { /* Almost the same as ==, except the return value is inverted. */ if ((tran.x == v1.tran.x) && (tran.y == v1.tran.y) && (tran.z == v1.tran.z) && (a == v1.a) && (b == v1.b) && (c == v1.c)) { return 0; } return 1; } |