地物分类项目代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
861B

  1. import math
  2. # 顺时针旋转
  3. def Nrotation_angle_get_coor_coordinates(point, center, angle):
  4. src_x, src_y = point
  5. center_x, center_y = center
  6. radian = math.radians(angle)
  7. dest_x = (src_x - center_x) * math.cos(radian) + (src_y - center_y) * math.sin(radian) + center_x
  8. dest_y = (src_y - center_y) * math.cos(radian) - (src_x - center_x) * math.sin(radian) + center_y
  9. return (dest_x, dest_y)
  10. # 逆时针旋转
  11. def Srotation_angle_get_coor_coordinates(point, center, angle):
  12. src_x, src_y = point
  13. center_x, center_y = center
  14. radian = math.radians(angle) # 弧度
  15. dest_x = (src_x - center_x) * math.cos(radian) - (src_y - center_y) * math.sin(radian) + center_x
  16. dest_y = (src_x - center_x) * math.sin(radian) + (src_y - center_y) * math.cos(radian) + center_y
  17. return (dest_x, dest_y)