【发布时间】:2013-04-12 14:33:11
【问题描述】:
我有一个箭头,表示为 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 指出的那样),纬度和经度之间的物理距离不相等吗?
【问题讨论】:
标签: math rotation coordinates trigonometry distortion