void findLongestDiameter(const MarkerPoint* nPoints, int nNumPoints, int &nIdx0, int &nIdx1) { int half = (nNumPoints + 1) / 2; int maxDist = -1; if (nNumPoints > 5) { for (int i = 0; i < half; i++) { for (int j = -1; j <= 1; j++) { int idx1 = i + half + j; if (idx1 >= nNumPoints) idx1 -= nNumPoints; int dist = distanceSquare(nPoints[i], nPoints[idx1]); if (dist > maxDist) { maxDist = dist; nIdx0 = i; nIdx1 = idx1; } } } } else { for (int i = 0; i < half; i++) { int idx1 = i + half; if (idx1 >= nNumPoints) idx1 -= nNumPoints; int dist = distanceSquare(nPoints[i], nPoints[idx1]); if (dist > maxDist) { maxDist = dist; nIdx0 = i; nIdx1 = idx1; } } } }
void VectorTestCase::testOtherTemplateFunctions(){ //test dot CPPUNIT_ASSERT_DOUBLES_EQUAL(dot(one, two), 8.0, OpenMD::NumericConstant::epsilon); CPPUNIT_ASSERT_DOUBLES_EQUAL(dot(v1, v3), 20.0, OpenMD::NumericConstant::epsilon); //test distance CPPUNIT_ASSERT_DOUBLES_EQUAL(distance(one, two), 2.0, OpenMD::NumericConstant::epsilon); CPPUNIT_ASSERT_DOUBLES_EQUAL(distance(v1, v2), sqrt(56.0), OpenMD::NumericConstant::epsilon); //test distanceSquare CPPUNIT_ASSERT_DOUBLES_EQUAL(distanceSquare(one, two), 4.0, OpenMD::NumericConstant::epsilon); CPPUNIT_ASSERT_DOUBLES_EQUAL(distanceSquare(v1, v2), 56, OpenMD::NumericConstant::epsilon); }
inline static float distanceSquareRT(float x1, float y1, float z1, float x2, float y2, float z2, float* h_R, float* h_t){ return distanceSquare(x1, y1, z1, (h_R[0]*x2 + h_R[1]*y2 + h_R[2]*z2) + h_t[0], (h_R[3]*x2 + h_R[4]*y2 + h_R[5]*z2) + h_t[1], (h_R[6]*x2 + h_R[7]*y2 + h_R[8]*z2) + h_t[2]); }
/// /// 距離の算出 static element_t distance( const Vec3& v1, const Vec3& v2 ){ return sqrtf(distanceSquare(v1, v2)); }
/// /// 距離の二乗を取得 element_t distanceSquare( const Vec3& target ) const { return distanceSquare( *this, target ); }