Fw: [討論] 求三角形面積

看板Math作者 (Engineer)時間12年前 (2013/03/07 16:27), 編輯推噓2(204)
留言6則, 2人參與, 最新討論串1/2 (看更多)
※ [本文轉錄自 MATLAB 看板 #1HE4qka_ ] 作者: royt (Engineer) 看板: MATLAB 標題: [討論] 求三角形面積 時間: Thu Mar 7 16:17:47 2013 問題是輸入三個座標點 算出三點所圍成的三角形面積 我先用把兩點的距離分別算出來 再帶入海龍公式 % MS2013 HW#1: To caculate the area of the triangular function area = func_hw1(x1,y1,x2,y2,x3,y3) % print the position fprintf('The first point of the triangle is (%5.2f, %5.2f)\n', x1, y1) fprintf('The second point of the triangle is (%5.2f, %5.2f)\n', x2, y2) fprintf('The third point of the triangle is (%5.2f, %5.2f)\n\n', x3, y3) % calculate the distance between points distance_12 = sqrt( (x1 - x2)^2 + (y1 - y2)^2 ); distance_13 = sqrt( (x1 - x3)^2 + (y1 - y3)^2 ); distance_23 = sqrt( (x2 - x3)^2 + (y2 - y3)^2 ); % put the distance into Helen formula temp = (distance_12 + distance_13 + distance_23)/2; area = sqrt( temp * (temp - distance_12) * (temp - distance_13) * (temp - distance_23) ); fprintf('The area of the triangle is %7.2', area) % end 可是測出來誤差過大 http://ppt.cc/d4sK 請問是哪個地方出問題嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.7.214 ※ 發信站: 批踢踢實業坊(ptt.cc) ※ 轉錄者: royt (140.112.7.214), 時間: 03/07/2013 16:27:39

03/07 17:06, , 1F
已知三點坐標求三角形面積有簡單的公式,
03/07 17:06, 1F

03/07 17:06, , 2F
用海龍公式是跟自己過不去。
03/07 17:06, 2F

03/07 17:09, , 3F
03/07 17:09, 3F

03/07 20:05, , 4F
如果是已知三維空間三點座標呢?
03/07 20:05, 4F

03/07 20:15, , 5F
用外積去推導。
03/07 20:15, 5F

03/07 22:00, , 6F
我知道只是順便問問,不知有沒有現成公式。
03/07 22:00, 6F
文章代碼(AID): #1HE4zysw (Math)
文章代碼(AID): #1HE4zysw (Math)