1
長座標我想顯示地圖使用經度/緯度座標從.csv
文件中的城市。這些值必須被轉換成x
和y
值,以便使用處理在屏幕上顯示。我的老師給了我這個代碼,但是對於我的座標,輸出的地圖旋轉了90度。旋轉LAT,已轉換爲像素
// 1. normalize the value between the minimum and maximum latitude or longitude values (new value between 0 and 1)
// 2. blow up the value between 0 and 1 by muliplying by the width or height of the screen (reduced by the margin 2 * 20 pixel)
// 3. shift the position by 20 pixel for the margin
float xPosition = 20 + (width-40) * norm(l.longitude, minLongCoord, maxLongCoord);
float yPosition = 20 + (height-40) * norm(l.latitude, minLatCoord, maxLatCoord);
有誰知道如何旋轉x
和y
位置90度,並依次從座標輸出的地圖嗎?
編輯:隨着翻譯的問題是,如果我有一個鼠標點擊功能看到鼠標是什麼形狀了,點擊什麼形狀的鼠標在不對齊。
我試過,但問題是,地圖包含一堆較小的形狀。我正在使用beginShape()。這意味着每個單獨的形狀都會旋轉,而不是整個地圖。 – OptOut
@OptOut您可以圍繞其中心旋轉每個形狀。或者你可以使用我提到的第二種方法。你也可以調用['PShape#rotate()'](https://processing.org/reference/PShape_rotate_.html)函數。 –
@OptOut beginShape()只是意味着該指令畢竟改造將在endShape()被重置,所以你可以把之前的旋轉。 – Alex