//******************************************************************* // Public Method: //******************************************************************* bool rspfDrect::intersects(const rspfDrect& rect) const { if(rect.hasNans() || hasNans()) { return false; } if (theOrientMode != rect.theOrientMode) return false; rspf_float64 ulx = rspf::max(rect.ul().x,ul().x); rspf_float64 lrx = rspf::min(rect.lr().x,lr().x); rspf_float64 uly, lry; bool rtn=false; if (theOrientMode == RSPF_LEFT_HANDED) { uly = rspf::max(rect.ul().y,ul().y); lry = rspf::min(rect.lr().y,lr().y); rtn = ((ulx <= lrx) && (uly <= lry)); } else { uly = rspf::max(rect.ll().y,ll().y); lry = rspf::min(rect.ur().y,ur().y); rtn = ((ulx <= lrx) && (uly <= lry)); } return (rtn); }
//***************************************************************************** // METHOD: pqe::LsrVector::dot(pqe::LsrVector) // // Computes the scalar product. // //***************************************************************************** double pqe::LsrVector::dot(const pqe::LsrVector& v) const { if(hasNans()||v.hasNans()||(theLsrSpace != v.theLsrSpace)) { pqe::LsrSpace::lsrSpaceErrorMessage(std::cout); return pqe::nan(); } return theData.dot(v.data()); }
//***************************************************************************** // METHOD: pqe::LsrVector::cross(pqe::LsrVector) // // Computes the cross product. // //***************************************************************************** pqe::LsrVector pqe::LsrVector::cross(const pqe::LsrVector& v) const { if(hasNans()||v.hasNans()||(theLsrSpace != v.theLsrSpace)) { pqe::LsrSpace::lsrSpaceErrorMessage(std::cout); return pqe::LsrVector(pqe::nan(), pqe::nan(), pqe::nan(), theLsrSpace); } return pqe::LsrVector(theData.cross(v.data()), theLsrSpace); }
//***************************************************************************** // METHOD: pqe::LsrVector::angleTo(pqe::LsrVector) // // Returns the angle subtended (in DEGREES) between this and arg vector // //***************************************************************************** double pqe::LsrVector::angleTo(const pqe::LsrVector& v) const { if(hasNans()||v.hasNans()||(theLsrSpace != v.theLsrSpace)) { pqe::LsrSpace::lsrSpaceErrorMessage(std::cout); return pqe::nan(); } double mag_product = theData.magnitude() * v.theData.magnitude(); return pqe::acosd(theData.dot(v.theData)/mag_product); }
//******************************************************************* // Public Method: rspfDrect::completely_within //******************************************************************* bool rspfDrect::completely_within(const rspfDrect& rect) const { if(hasNans() || rect.hasNans()) { return false; } if (theOrientMode != rect.theOrientMode) return false; /* -------------- | 1 | | ---------- | | | | | | | | | | | 2 | | | | | | | | | | | ---------- | | | -------------- */ bool rtn = true; if (theUlCorner.x < rect.ul().x) rtn = false; else if (theLrCorner.x > rect.lr().x) rtn = false; else if (theOrientMode == RSPF_LEFT_HANDED) { if (theUlCorner.y < rect.ul().y) rtn = false; else if (theLrCorner.y > rect.lr().y) rtn = false; } else { if (theUlCorner.y > rect.ul().y) rtn = false; else if (theLrCorner.y < rect.lr().y) rtn = false; } return rtn; }
//***************************************************************************** // CONSTRUCTOR: ossimLsrRay(ossimLsrPoint, ossimLsrVector) // // Constructs by transforming the given ray into the new space. // //***************************************************************************** ossimLsrRay::ossimLsrRay(const ossimLsrPoint& origin, const ossimLsrVector& direction) : theOrigin(origin), theDirection(direction.unitVector()) { if (origin.lsrSpace() != direction.lsrSpace() || hasNans()) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL -- ossimLsrRay(ossimLsrPoint,ossimLsrVector) Constructor:" << "\n The origin and direction LSR quantities do not share the" << "\n same LSR space. Setting to NAN. Check the data for errors." << std::endl; theOrigin = ossimLsrPoint (ossim::nan(), ossim::nan(), ossim::nan(), origin.lsrSpace()); theDirection = ossimLsrVector(ossim::nan(), ossim::nan(), ossim::nan(), direction.lsrSpace()); } }
//******************************************************************* // Public Method: rspfDrect::clipToRect //******************************************************************* rspfDrect rspfDrect::clipToRect(const rspfDrect& rect)const { rspfDrect result; result.makeNan(); if(rect.hasNans() || hasNans()) { return result; } if (theOrientMode != rect.theOrientMode) return (*this); double x0 = rspf::max(rect.ul().x, ul().x); double x1 = rspf::min(rect.lr().x, lr().x); double y0, y1; if (theOrientMode == RSPF_LEFT_HANDED) { y0 = rspf::max(rect.ll().y, ll().y); y1 = rspf::min(rect.ur().y, ur().y); if( (x1 < x0) || (y1 < y0) ) return result; else result = rspfDrect(x0, y0, x1, y1, theOrientMode); } else { y0 = rspf::max(rect.ll().y,ll().y); y1 = rspf::min(rect.ur().y,ur().y); if((x0 <= x1) && (y0 <= y1)) { result = rspfDrect(x0, y1, x1, y0, theOrientMode); } } return result; }