#include#include struct pt { float x,y; }; struct quat { pt points[4]; }; float crossmulti2d( float x1, float y1, float x2, float y2) { return x1 * y2 - x2 * y1; } bool inquat( quat _q, pt _pt) { pt vec1, vec2; vec1.x = _q.points[1].x - _q.points[0].x; vec1.y = _q.points[1].y - _q.points[0].y; vec2.x = _pt.x - _q.points[0].x; vec2.y = _pt.y - _q.points[0].y; if( crossmulti2d( vec2.x, vec2.y, vec1.x, vec1.y ) < 0 ) { return false; } vec1.x = _q.points[2].x - _q.points[1].x; vec1.y = _q.points[2].y - _q.points[1].y; vec2.x = _pt.x - _q.points[1].x; vec2.y = _pt.y - _q.points[1].y; if( crossmulti2d(vec2.x, vec2.y, vec1.x, vec1.y) < 0 ) { return false; } vec1.x = _q.points[3].x - _q.points[2].x; vec1.y = _q.points[3].y - _q.points[2].y; vec2.x = _pt.x - _q.points[2].x; vec2.y = _pt.y - _q.points[2].y; if( crossmulti2d(vec2.x, vec2.y, vec1.x, vec1.y) < 0 ) { return false; } vec1.x = _q.points[0].x - _q.points[3].x; vec1.y = _q.points[0].y - _q.points[3].y; vec2.x = _pt.x - _q.points[3].x; vec2.y = _pt.y - _q.points[3].y; if( crossmulti2d(vec2.x, vec2.y, vec1.x, vec1.y ) < 0 ) { return false; } return true; } int main() { quat shape = { { {1, 1},{2, 1}, {1, 0},{0, 0} } }; pt tests[] = { {0.0, 1.0}, {1.0, 0.5}, {1.5, 0}, {1.5, 0.5}, {1.5, 0.52}, {1.5, 0.49} }; for(int i =0; i 成都創(chuàng)新互聯(lián)專注于企業(yè)全網(wǎng)整合營(yíng)銷推廣、網(wǎng)站重做改版、興寧網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、HTML5、成都做商城網(wǎng)站、集團(tuán)公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁(yè)設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為興寧等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。 另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
文章名稱:判斷點(diǎn)在凸四邊形內(nèi)-創(chuàng)新互聯(lián)
當(dāng)前路徑:http://weahome.cn/article/ccdhgi.html