相关疑难解决方法(0)

用于旋转原点周围点的正确三角法

以下任何一种方法都使用正确的数学来旋转一个点吗?如果是这样,哪一个是正确的?

POINT rotate_point(float cx,float cy,float angle,POINT p)
{
  float s = sin(angle);
  float c = cos(angle);

  // translate point back to origin:
  p.x -= cx;
  p.y -= cy;

  // Which One Is Correct:
  // This?
  float xnew = p.x * c - p.y * s;
  float ynew = p.x * s + p.y * c;
  // Or This?
  float xnew = p.x * c + p.y * s;
  float ynew = -p.x * s + p.y * c;

  // translate …
Run Code Online (Sandbox Code Playgroud)

c# c++ geometry trigonometry

15
推荐指数
2
解决办法
2万
查看次数

标签 统计

c# ×1

c++ ×1

geometry ×1

trigonometry ×1