2D坐标旋转 - 图像失真

时间:2013-04-12 14:33:11

标签: math rotation coordinates trigonometry distortion

我有一个箭头,表示为X,Y点,我想旋转25度。我的箭头旋转,但看起来不再好看。它们的角度不再是90度。要点:

-85.0,0.0
-25.0,50.0
-25.0,15.0
85.0,15.0
85.0,-15.0
-25.0,-15.0
-25.0,-50.0
-85.0,0.0

这会生成图片that looks like this

这是我的(PHP)代码来旋转点:

$pts = array(
    array( -85, 0 ),
    array( -25, 50 ),
    array( -25, 15 ),
    array( 85, 15 ),
    array( 85, -15 ),
    array( -25, -15 ),
    array( -25, -50 ),
    array( -85, 0 ),
);

$rotate = deg2rad( 25 );
$sin = sin( $rotate );
$cos = cos( $rotate );

foreach( $pts as $xy ) {
    list( $x, $y ) = $xy;

    // Rotate
    $x2 = ( $x * $cos ) - ( $y * $sin );
    $y2 = ( $x * $sin ) + ( $y * $cos );

    printf( "%0.3f, %0.3f\n", $x2, $y2 );
}

输出:

-77.036, -35.923
-43.789, 34.750
-28.997, 3.029
70.697, 49.517
83.375, 22.328
-16.318, -24.160
-1.527, -55.881
-77.036, -35.923

生成的图片no longer looks good

我的数学错误是什么?我希望它仍然有90度角应该等等。

谢谢! 塞特

编辑:本练习的其余部分是我将这些点转换为在Google地球中显示的纬度/经度坐标。翻译代码:

$x2 = ( $x2 * $scale ) + $latref;
$y2 = ( $y2 * $scale ) + $lonref;

我的“真实”问题(正如@ joel-in-go指出的那样),纬度和经度之间的物理距离不相等?

1 个答案:

答案 0 :(得分:4)

数学没什么问题 - 图表中X和Y坐标轴上的刻度不一样:)