[問題] 多點到直線的距離
看板Prob_Solve (計算數學 Problem Solving)作者firingmoon (小天)時間9年前 (2015/05/16 22:46)推噓9(9推 0噓 43→)留言52則, 9人參與討論串1/2 (看更多)
各位版友好
今天我有n個點,求每一個點到直線L的距離,最終找出其中一點
且此點到直線L的距離最長
直觀的來講我只需要做n次並用max函數即可
但我希望速度能夠更快
所以想請教各位是否有演算法可以加速計算此部分 謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 113.61.182.113
※ 文章網址: https://www.ptt.cc/bbs/Prob_Solve/M.1431787607.A.711.html
→
05/17 00:16, , 1F
05/17 00:16, 1F
→
05/17 00:19, , 2F
05/17 00:19, 2F
推
05/17 00:25, , 3F
05/17 00:25, 3F
→
05/17 00:26, , 4F
05/17 00:26, 4F
→
05/17 00:27, , 5F
05/17 00:27, 5F
→
05/17 00:27, , 6F
05/17 00:27, 6F
推
05/17 00:35, , 7F
05/17 00:35, 7F
對 值不care 所以我沒有計算分母
let ax+b-y = 0
for (i=1,i<10000,i++)
{
dis = abs(a*xpoint[i]+b-ypoint[i])
if (dis>dismax)
{
dismax = dis
point = i <-------這是我的目的 想要找哪一個點
}
}
這是我的程式碼
不知道是否有任何地方可以讓他計算速度變更快
→
05/17 00:36, , 8F
05/17 00:36, 8F
→
05/17 00:37, , 9F
05/17 00:37, 9F
※ 編輯: firingmoon (113.61.182.113), 05/17/2015 01:07:32
推
05/17 01:09, , 10F
05/17 01:09, 10F
→
05/17 01:09, , 11F
05/17 01:09, 11F
推
05/17 01:11, , 12F
05/17 01:11, 12F
→
05/17 01:12, , 13F
05/17 01:12, 13F
→
05/17 01:14, , 14F
05/17 01:14, 14F
→
05/17 01:14, , 15F
05/17 01:14, 15F
→
05/17 01:14, , 16F
05/17 01:14, 16F
→
05/17 01:14, , 17F
05/17 01:14, 17F
→
05/17 01:14, , 18F
05/17 01:14, 18F
→
05/17 01:14, , 19F
05/17 01:14, 19F
→
05/17 01:15, , 20F
05/17 01:15, 20F
→
05/17 01:15, , 21F
05/17 01:15, 21F
→
05/17 01:16, , 22F
05/17 01:16, 22F
→
05/17 01:17, , 23F
05/17 01:17, 23F
→
05/17 01:18, , 24F
05/17 01:18, 24F
→
05/17 01:19, , 25F
05/17 01:19, 25F
→
05/17 01:19, , 26F
05/17 01:19, 26F
→
05/17 01:20, , 27F
05/17 01:20, 27F
→
05/17 01:20, , 28F
05/17 01:20, 28F
推
05/17 01:20, , 29F
05/17 01:20, 29F
推
05/17 01:25, , 30F
05/17 01:25, 30F
→
05/17 01:26, , 31F
05/17 01:26, 31F
→
05/17 01:31, , 32F
05/17 01:31, 32F
推
05/17 01:31, , 33F
05/17 01:31, 33F
→
05/17 01:32, , 34F
05/17 01:32, 34F
→
05/17 01:49, , 35F
05/17 01:49, 35F
→
05/17 01:51, , 36F
05/17 01:51, 36F
→
05/17 01:54, , 37F
05/17 01:54, 37F
→
05/17 01:54, , 38F
05/17 01:54, 38F
→
05/17 01:55, , 39F
05/17 01:55, 39F
→
05/17 01:55, , 40F
05/17 01:55, 40F
→
05/17 01:56, , 41F
05/17 01:56, 41F
(1)只做一次
(2)讀得懂 基本上這部分不用太在意
(3)沒有特殊,單純就a[1],a[2],a[3].........
※ 編輯: firingmoon (113.61.182.113), 05/17/2015 02:01:33
→
05/17 02:04, , 42F
05/17 02:04, 42F
推
05/17 15:10, , 43F
05/17 15:10, 43F
→
05/17 15:21, , 44F
05/17 15:21, 44F
推
05/17 21:45, , 45F
05/17 21:45, 45F
→
05/17 21:46, , 46F
05/17 21:46, 46F
→
05/17 21:47, , 47F
05/17 21:47, 47F
→
05/17 21:47, , 48F
05/17 21:47, 48F
→
05/17 21:48, , 49F
05/17 21:48, 49F
→
05/17 21:48, , 50F
05/17 21:48, 50F
→
05/18 10:39, , 51F
05/18 10:39, 51F
→
11/13 12:01, , 52F
11/13 12:01, 52F
討論串 (同標題文章)
Prob_Solve 近期熱門文章
PTT數位生活區 即時熱門文章