已知两点坐标和三边长度,求三角形第三点的坐标
生活随笔
收集整理的這篇文章主要介紹了
已知两点坐标和三边长度,求三角形第三点的坐标
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
已知兩點坐標和三邊長度,求三角形第三點的坐標
經驗證,該方法在平面中通用。
基本思路或步驟如下:
引用自https://wenku.baidu.com/view/46038b2342323968011ca300a6c30c225801f056.html
圖片: https://wenku.baidu.com/view/46038b2342323968011ca300a6c30c225801f056.html
以下為代碼
去博客設置頁面,選擇一款你喜歡的代碼片高亮樣式,下面展示同樣高亮的 代碼片.
//根據兩點坐標和邊長長度,計算第三點坐標,第三點有兩個 bool AutoExtraLine::Cal3rdPoint(vector<CCVector3d> vecSrcPoints, double ab, double bc, double ca, vector<CCVector3d>& vec3rdPoints) {if (vecSrcPoints.size()<2){return false;}CCVector3d pointA = vecSrcPoints[0];CCVector3d pointB = vecSrcPoints[1];CCVector3d pointC;double dy = pointB.y - pointA.y;double dx = pointB.x - pointA.x;double tmpValue = (ca*ca + ab * ab - bc * bc) / (2 * ca*ab);//AB的方位角double angAB = CalVectorAngleWithY(pointA, pointB);if (angAB>180){// angAB = angAB - 180;}angAB = angAB * (PI / 180);// angAB = atan(dy / dx);//A點對應BC邊的角度double angBC = acos(tmpValue);//AC的方位角double angAC = angAB-angBC;pointC.x = pointA.x + ca * sin(angAC);pointC.y = pointA.y + ca * cos(angAC);vec3rdPoints.push_back(pointC);angAC = angAB + angBC;pointC.x = pointA.x + ca * sin(angAC);pointC.y = pointA.y + ca * cos(angAC);vec3rdPoints.push_back(pointC);return true; } /計算向量AB與Y軸正方向夾角,角度范圍0~360 double AutoExtraLine::CalVectorAngleWithY(CCVector3d pointA, CCVector3d pointB) {//線段(startPt,firstPt)平行于y軸向上CCVector3d firstPt(pointA.x, pointA.y + 10, pointA.z);double angle = PointAlg::calcAngleByThreePoint(firstPt, pointA, pointB);angle = angle * 180 / PI;if (pointA.x > pointB.x){angle = 360 - angle;}return angle; }總結
以上是生活随笔為你收集整理的已知两点坐标和三边长度,求三角形第三点的坐标的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 中缀表达式转换为前缀及后缀表达式并求值【
- 下一篇: 主网络程序函数