bool mitk::Geometry2D::Map( const mitk::Point3D &pt3d_mm, mitk::Point2D &pt2d_mm) const { assert(m_BoundingBox.IsNotNull()); Point3D pt3d_units; BackTransform(pt3d_mm, pt3d_units); pt2d_mm[0]=pt3d_units[0]*m_ScaleFactorMMPerUnitX; pt2d_mm[1]=pt3d_units[1]*m_ScaleFactorMMPerUnitY; pt3d_units[2]=0; return const_cast<BoundingBox*>(m_BoundingBox.GetPointer())->IsInside(pt3d_units); }
int CPCAGrid::Calc () { if (m_dwK > m_dwP) return 1 ; // k > p /* if ((m_nSplitCircle & 1) == 0) // //if (m_dwSplitCircle & 1) // only allow even values for splitcircle ++ m_nSplitCircle ;*/ if (m_dwkIni) sme_matmult_R (m_mX, m_mL.GetColRef (m_dwkIni, m_dwP), !TempY ()) ; else { TempY ().Copy (m_mX) ; SetDiag_sq (!m_mL) ; //m_mL.setdiag () ; // this MUST now happen in the calling R routine! // this has been changed when introducing the m_dwkIni argument // why not here? } for (m_dwCurK = m_dwkIni; m_dwCurK < m_dwK; m_dwCurK++) // for each PC which to be computed { m_dwPSub = m_dwP - m_dwCurK ; // dimensionality of the subspace OnCalcPC () ; if (m_dwPSub == 1) // only 1 dimension left -> return this direction { m_vSDev (m_dwCurK) = ApplyMethod (TempY ().GetColRef (0)) ; continue ; // break ; } m_vScl.Reshape (m_dwPSub) ; m_vOrd.Reshape (m_dwPSub) ; ApplyMethod (TempY (), m_vScl) ; // 2do: m_vScl can be a temporary vector meal_sort_order_rev (m_vScl, m_vOrd, m_vScl.size ()) ; // gets the order (m_vOrd) of the dimensions regarding to their variance (m_vScl) in decreasing order m_dwCurP = m_vOrd(0) ; // index of the coloumn of x with biggest scatter m_vAfinBest.Reshape (m_dwPSub) ; m_vAfin.Reshape (m_dwPSub) ; m_vAfin.Reset (0) ; m_vAfin (m_dwCurP) = 1 ; CopyCol (*m_vYOpt, TempY (), m_dwCurP) ; // loads the loading with max scatter as the initial solution t_size i, j ; double dCurSplit ; double dScatBest = 0 ; double dObjBest = 0 ; for (i = 0; i <= m_dwMaxIter; i++) // the outer iteration, which subsequently decreases the gridsize ( = dCurSplit) { //double dScat, dObj, dSumAbsDelta = 0 ; // 2do: check if it's better to use * 0.5 each time? dCurSplit = pow (0.5, (double) i) ; // the current gridSize for (j = 0; j < m_dwPSub; j++) // for each loading in the current solution { m_dwCurP = m_vOrd (j) ; // m_dwCurP = the j-th largest coponent // the m_dwCurP-st loading in tje current solution is now altered in order to increase the objective function m_vCurY = TempY ().GetColRef (m_dwCurP) ; // 2do: move this 2 rows down. m_pdCurY = m_vCurY ; const double dL = m_vAfin (m_dwCurP) ; // current loading if (fabs (dL) == 1) continue ; RemoveLoading (/*i*/) ; m_dNL = dL ; GridPlane (dCurSplit) ; // increasing the objective function by trying several directions on a grid AddLoading (m_dNL, m_dNCL) ; // add the found loading tho the current solution //double dNL = dL, dNCL ; //GridPlane (dNL, dNCL, dScat, dObj, dCurSplit) ; //AddLoading (dNL, dNCL) ; //dSumAbsDelta += fabs (dL - dNL) ; } EO<SOP::a_divide>::VSc (*m_vAfin, norm2 (m_vAfin)) ; // 2do: check norm of m_vAfin. should be 1 anyway!, if not it's sufficient to perform this normalization after this for loop, only with the m_vAfinBest - vector! if (!i || dObjBest <= m_dBestObj) // checking whether we've found a better solution -> if true store it. { dObjBest = m_dBestObj ; m_vAfinBest.Copy_NC (m_vAfin) ; dScatBest = m_dCurScat ; } //meal_printf ("delta: %.22f ->", dSumAbsDelta) ; /* if (dSumAbsDelta <= m_dZeroTol) // no changes of any loading -> quit // doesn't make sense as we're operating on a raster //if (dCurSplit<= m_dZeroTol) // no changes of any loading -> quit { //meal_printf ("stop iteration\n") ; if (m_dwTrace >= 3) meal_printf ("Calculation of PC %d stopped after %d loops\r\n", m_dwCurK + 1, i + 1) ; break ; } //meal_printf ("continue iteration\n") ; */ } m_vSDev (m_dwCurK) = dScatBest ; // 2do: use ptrs instead of vector access! m_vObj(m_dwCurK) = dObjBest ; BackTransform () ; } return 0 ; }
void mitk::BaseGeometry::WorldToIndex( const mitk::Vector3D &vec_mm, mitk::Vector3D &vec_units) const { BackTransform( vec_mm, vec_units); }
void mitk::BaseGeometry::WorldToIndex(const mitk::Point3D &pt_mm, mitk::Point3D &pt_units) const { BackTransform(pt_mm, pt_units); }