How to Get Vertical Line from Point and Line
2017-12-03 09:44
555 查看
Description
How to get vertical line cross one point which out of line in line.QPoint Line::VerticalPoint(QPoint pt) { QPointF ptCross = pt; double dtY = static_cast<double>(y1() - y2()); double dtX = static_cast<double>(x1() - x2()); double k,b,m; /** 0 = kx +b -y; 对应垂线方程为 -x -ky + m = 0;(mm为系数) */ if(abs(dtX - 0) < 1e-10){ ptCross = QPointF(x1(),pt.y()); goto _END; } if(abs(dtY - 0) < 1e-10){ ptCross = QPointF(pt.x(),y1()); goto _END; } k = dtY/dtX; b = (y1()-k*x1()); m = pt.x() + k*pt.y(); ptCross.setX((m-k*b)/(k*k + 1)); ptCross.setY(k*ptCross.x()+b); _END: return ptCross.toPoint(); }
相关文章推荐
- How to Display a SharePoint Dialog from Ribbon Button and Get Selected Item Context
- [Android] how to get pem format public key from modulus and exponent
- How to open Firefox and chrome from command line
- I'm on Facebook--Now What???: How to Get Personal, Business, and Professional Value from Facebook
- JSP URI/URL - How to get the request URI, URL, and Context from a JSP
- I'm on Facebook--Now What???: How to Get Personal, Business, and Professional Value from Facebook
- How to easily open files and URLs from the command line
- trim content between begin and end lines or get from keyword line to file end
- [转]How to get return values and output values from a stored procedure with EF Core?
- how to get preloader and dsp_bl from mtk phone?
- C++ How to avoid the enter key when using cin and getline
- how to get charset from string and file
- How to use GET and POST methods in HTTP from a MIDlet
- How to run FTE and FTE from command line
- How to change service accounts and service account passwords in SharePoint Server 2007 and in Windows SharePoint Services 3.0
- How to get the "connection string" from web.config file
- How To Use Function 'F4_FILENAME' and 'KD_GET_FILENAME_ON_F4'
- How to start a Windows CE emulator from the command line
- How to get browser name, version and operating system detail in selenium 2(Web driver)
- Understanding the SharePoint calendar and how to export it to iCal format