Vector3 RefractiveInterface::BRDF(const Vector3& in, const Vector3& ambiguousNormal, const Vector3& out, const bool& isFront) const { return Vector3(0, 0, 0); // First check to see that all three vectors are in the same plane if (!coplanar(in, ambiguousNormal, out)) return Vector3(0, 0, 0); Vector3 normal; if (isFront == false) normal = ambiguousNormal; else normal = -ambiguousNormal; /*float nIn = m_n0; float nOut = m_n1; float cosIn = dot(normal, in); float cosOut = dot(normal, out); float sinIn = sqrt(1.0f - cosIn*cosIn); // sin's are all positive by definition of sqrt(...) float sinOut = sqrt(1.0f - cosOut*cosOut); if (cosIn < 0) nIn = m_n1; if (cosOut > 0) nOut = m_n0; float sinCrit = fmin(m_n0, m_n1) / fmax(m_n0, m_n1); // critical sin(theta) for total internal reflection if (cosIn*cosOut < 0) { // rays are on opposite sides of interface (TRANSMITTED) float nSinIn = nIn*sinIn; float nSinOut = nOut*sinOut; if (fmin(nSinIn, nSinOut) / fmax(nSinIn, nSinOut) > 0.99999) return m_kt; else return Vector3(0,0,0); } else if (cosIn*cosOut > 0) { // rays are on the same side of interface (REFLECTED) if (fmin(sinIn, sinOut) / fmax(sinIn, sinOut) > 0.99999) return m_kr; else return Vector3(0,0,0); } else { // at least one of the rays is parallel to the interface if (cosIn == 0) { if (cosOut == 0) return 1; // special case of ray skimming the surface (no energy lost) if (nIn > nOut) return 0; if (fmin(sinCrit, sinOut) / fmax(sinCrit, sinOut) > 0.99999) return (m_kt[0] + m_kt[1] + m_kt[2]) / 3; return 0; } else if (cosOut == 0) { if (nIn < nOut) return 0; if (fmin(sinCrit, sinIn) / fmax(sinCrit, sinIn) > 0.99999) return (m_kt[0] + m_kt[1] + m_kt[2]) / 3; return 0; } } return 0;*/ }
/*! \brief Compute the pose according to the desired method the different method are LAGRANGE Lagrange approach (test is done to switch between planar and non planar algorithm) DEMENTHON Dementhon approach (test is done to switch between planar and non planar algorithm) VIRTUAL_VS Virtual visual servoing approach DEMENTHON_VIRTUAL_VS Virtual visual servoing approach initialized using Dementhon approach LAGRANGE_VIRTUAL_VS Virtual visual servoing initialized using Lagrange approach */ void vpPose::computePose(vpPoseMethodType methode, vpHomogeneousMatrix& cMo) { #if (DEBUG_LEVEL1) std::cout << "begin vpPose::ComputePose()" << std::endl ; #endif if (npt <4) { vpERROR_TRACE("Not enough point (%d) to compute the pose ",npt) ; throw(vpPoseException(vpPoseException::notEnoughPointError, "No enough point ")) ; } switch (methode) { case DEMENTHON : case DEMENTHON_VIRTUAL_VS : case DEMENTHON_LOWE : { if (npt <4) { vpERROR_TRACE("Dementhon method cannot be used in that case ") ; vpERROR_TRACE("(at least 4 points are required)") ; vpERROR_TRACE("Not enough point (%d) to compute the pose ",npt) ; throw(vpPoseException(vpPoseException::notEnoughPointError, "Not enough points ")) ; } // test si les point 3D sont coplanaires int plan = coplanar() ; if (plan == 1) { //std::cout << "Plan" << std::endl; try{ poseDementhonPlan(cMo); } catch(...) { vpERROR_TRACE(" ") ; throw ; } //std::cout << "Fin Plan" << std::endl; } else { //std::cout << "No Plan" << std::endl; try{ poseDementhonNonPlan(cMo) ; } catch(...) { vpERROR_TRACE(" ") ; throw ; } //std::cout << "Fin No Plan" << std::endl; } } break ; case LAGRANGE : case LAGRANGE_VIRTUAL_VS : case LAGRANGE_LOWE : { // test si les point 3D sont coplanaires int plan = coplanar() ; if (plan == 1) { if (npt <4) { vpERROR_TRACE("Lagrange method cannot be used in that case ") ; vpERROR_TRACE("(at least 4 points are required)") ; vpERROR_TRACE("Not enough point (%d) to compute the pose ",npt) ; throw(vpPoseException(vpPoseException::notEnoughPointError, "Not enough points ")) ; } try { poseLagrangePlan(cMo); } catch(...) { vpERROR_TRACE(" ") ; throw ; } } else { if (npt <4) { vpERROR_TRACE("Lagrange method cannot be used in that case ") ; vpERROR_TRACE("(at least 4 points are required)") ; vpERROR_TRACE("Not enough point (%d) to compute the pose ",npt) ; throw(vpPoseException(vpPoseException::notEnoughPointError, "Not enough points ")) ; } try { poseLagrangeNonPlan(cMo); } catch(...) { vpERROR_TRACE(" ") ; throw ; } } } break; case RANSAC: if (npt <4) { vpERROR_TRACE("Ransac method cannot be used in that case ") ; vpERROR_TRACE("(at least 4 points are required)") ; vpERROR_TRACE("Not enough point (%d) to compute the pose ",npt) ; throw(vpPoseException(vpPoseException::notEnoughPointError, "Not enough points ")) ; } try { poseRansac(cMo); } catch(...) { vpERROR_TRACE(" ") ; throw ; } break; case LOWE : case VIRTUAL_VS: break ; } switch (methode) { case LAGRANGE : case DEMENTHON : case RANSAC : break ; case VIRTUAL_VS: case LAGRANGE_VIRTUAL_VS: case DEMENTHON_VIRTUAL_VS: { try { poseVirtualVS(cMo); } catch(...) { vpERROR_TRACE(" ") ; throw ; } } break ; case LOWE: case LAGRANGE_LOWE: case DEMENTHON_LOWE: { try { poseLowe(cMo); } catch(...) { vpERROR_TRACE(" ") ; throw ; } } break ; } #if (DEBUG_LEVEL1) std::cout << "end vpPose::ComputePose()" << std::endl ; #endif }