旋转已转换为像素的经纬度坐标

Rotating lat,long coordinates that have been converted to pixels

我正在尝试使用 .csv 文件中的 lat/long 坐标显示城市地图。这些值必须转换为 xy 值才能使用 Processing 显示在屏幕上。我的老师给了我这个代码,但是对于我的坐标,输出的地图旋转了 90 度。

// 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);

有谁知道如何将 xy 位置旋转 90 度,进而从坐标输出地图?

编辑:翻译的问题是,如果我有鼠标点击功能,请查看鼠标悬停的形状,点击和鼠标悬停的形状不对齐。

您可以直接调用 rotate() 函数。来自 the reference:

translate(width/2, height/2);
rotate(PI/3.0);
rect(-26, -26, 52, 52);

请注意,您还必须调用translate()函数来设置要旋转的点,然后相对于该点进行绘制。

如果你不想使用rotate()功能,那么你首先必须弄清楚要围绕哪个点旋转,然后围绕那个点旋转。谷歌搜索“围绕另一个点旋转一个点”returns 一堆结果,包括这个 Stack Overflow post:Rotating a point about another point (2D)