如题所述
向量旋转问题。
设向量A(x,y)逆时针旋转theta度
那么有旋转后向量B(x*cos(theta)-y*sin(theta), x*sin(theta)+y*cos(theta))
座标系旋转等于点绕远点旋转等于向量旋转
代码:
struct Vector {double x, y;
Vector() {x = y = 0;}
Vector(double a, double b):x(a),y(b){}
const Vector rotateAC (double theta) ;
const Vector getRotatedAC (double theta) const ;
const Vector rotateC (double theta) ;
const Vector getRotatedC (double theta) const ;
const Vector operator += (Vector b);
const Vector operator -= (Vector b);
const Vector operator *= (double b);
const Vector operator /= (double b);
};
const Vector Vector :: rotateAC (double theta)
{return (*this) = getRotatedAC(theta);}
const Vector Vector :: getRotatedAC (double theta) const
{return Vector(x*cos(theta) - y*sin(theta), x*sin(theta) + y*cos(theta));}
const Vector Vector :: rotateC (double theta) {return rotateAC(-theta);}
const Vector Vector :: getRotatedC (double theta) const {return getRotatedAC(-theta);}
温馨提示:答案为网友推荐,仅供参考
第1个回答 2014-06-23
有一个旋转公式,你百度一下,吧旋转角度和原坐标带入公式就可以算出新坐标追问
我是要那个编程代码,不是怎么求
本回答被提问者采纳第2个回答 2017-05-12
什么语言的编程?