//============================================================================== bool cMyCustomDevice::getRotation(cMatrix3d& a_rotation) { //////////////////////////////////////////////////////////////////////////// /* STEP 8: Here you shall implement code which reads the orientation frame from your haptic device. The orientation frame is expressed by a 3x3 rotation matrix. The 1st column of this matrix corresponds to the x-axis, the 2nd column to the y-axis and the 3rd column to the z-axis. The length of each column vector should be of length 1 and vectors need to be orthogonal to each other. Note: If your device is located in front of you, the x-axis is pointing towards you (the operator). The y-axis points towards your right hand side and the z-axis points up towards the sky. If your device has a stylus, make sure that you set the reference frame so that the x-axis corresponds to the axis of the stylus. */ //////////////////////////////////////////////////////////////////////////// bool result = C_SUCCESS; // variables that describe the rotation matrix double r00, r01, r02, r10, r11, r12, r20, r21, r22; cMatrix3d frame; frame.identity(); // *** INSERT YOUR CODE HERE, MODIFY CODE BELLOW ACCORDINGLY *** // if the device does not provide any rotation capabilities // set the rotation matrix equal to the identity matrix. r00 = 1.0; r01 = 0.0; r02 = 0.0; r10 = 0.0; r11 = 1.0; r12 = 0.0; r20 = 0.0; r21 = 0.0; r22 = 1.0; frame.set(r00, r01, r02, r10, r11, r12, r20, r21, r22); // store new rotation matrix a_rotation = frame; // estimate angular velocity estimateAngularVelocity(a_rotation); // exit return (result); }
//=========================================================================== int cMyCustomDevice::getRotation(cMatrix3d& a_rotation) { // temp variables int error = -1; double r00, r01, r02, r10, r11, r12, r20, r21, r22; cMatrix3d frame; frame.identity(); /************************************************************************ STEP 7: Here you may implement code which reads the orientation frame from your haptic device. The orientation frame is expressed by a 3x3 rotation matrix. The 1st column of this matrix corresponds to the x-axis, the 2nd column to the y-axis and the 3rd column to the z-axis. The length of each column vector should be of length 1 and vectors need to be perpendicular to each other. If the operation fails return an error code. Note: If your device is located in front of you, the x-axis is pointing towards you (the operator). The y-axis points towards your right hand side and the z-axis points up towards the sky. If your device has a stylus, make sure that you set the reference frame so that the x-axis corresponds to the axis of the stylus. *************************************************************************/ // *** INSERT YOUR CODE HERE, MODIFY CODE BELLOW ACCORDINGLY *** // by default we set the rotation matrix equal to the identiy matrix. r00 = 1.0; r01 = 0.0; r02 = 0.0; r10 = 0.0; r11 = 1.0; r12 = 0.0; r20 = 0.0; r21 = 0.0; r22 = 1.0; frame.set(r00, r01, r02, r10, r11, r12, r20, r21, r22); // store new rotation matrix a_rotation = frame; // estimate angular velocity estimateAngularVelocity(a_rotation); // exit return (error); }
//=========================================================================== int cPhantomDevice::getRotation(cMatrix3d& a_rotation) { // check if drivers are installed if (!m_driverInstalled) return (-1); double rot[3][3]; int error = hdPhantomGetRotation(m_deviceID, &rot[0][0], &rot[0][1], &rot[0][2], &rot[1][0], &rot[1][1], &rot[1][2], &rot[2][0], &rot[2][1], &rot[2][2]); a_rotation.set(rot[0][0], rot[0][1], rot[0][2], rot[1][0], rot[1][1], rot[1][2], rot[2][0], rot[2][1], rot[2][2]); estimateAngularVelocity(a_rotation); return (error); }
//=========================================================================== int cHydraDevice::getRotation(cMatrix3d& a_rotation) { /************************************************************************ STEP 7: Here you may implement code which reads the orientation frame from your haptic device. The orientation frame is expressed by a 3x3 rotation matrix. The 1st column of this matrix corresponds to the x-axis, the 2nd column to the y-axis and the 3rd column to the z-axis. The length of each column vector should be of length 1 and vectors need to be perpendicular to each other. If the operation fails return an error code such as -1 for instance. Note: If your device is located in front of you, the x-axis is pointing towards you (the operator). The y-axis points towards your right hand side and the z-axis points up towards the sky. If your device has a stylus, make sure that you set the reference frame so that the x-axis corresponds to the axis of the stylus. *************************************************************************/ int error = 0; double r00, r01, r02, r10, r11, r12, r20, r21, r22; cMatrix3d frame; frame.identity(); // *** INSERT YOUR CODE HERE, MODIFY CODE BELLOW ACCORDINGLY *** // if the device does not provide any rotation capabilities // we set the rotation matrix equal to the identiy matrix. sixenseAllControllerData acd; sixenseGetAllNewestData( &acd ); // sixense is COLUMN MAJOR! r00 = acd.controllers[a_deviceNumber].rot_mat[0][0]; r01 = acd.controllers[a_deviceNumber].rot_mat[1][0]; r02 = acd.controllers[a_deviceNumber].rot_mat[2][0]; r10 = acd.controllers[a_deviceNumber].rot_mat[0][1]; r11 = acd.controllers[a_deviceNumber].rot_mat[1][1]; r12 = acd.controllers[a_deviceNumber].rot_mat[2][1]; r20 = acd.controllers[a_deviceNumber].rot_mat[0][2]; r21 = acd.controllers[a_deviceNumber].rot_mat[1][2]; r22 = acd.controllers[a_deviceNumber].rot_mat[2][2]; frame.set(r00, r01, r02, r10, r11, r12, r20, r21, r22); cMatrix3d permute_rows(0, 0, 1, 1, 0, 0, 0, 1, 0); cMatrix3d permute_columns(0, 1, 0, 0, 0, 1, 1, 0, 0); a_rotation = permute_rows*frame*permute_columns; // estimate angular velocity estimateAngularVelocity(a_rotation); // exit return (error); }