经过摸索,现在已经大体写好了,好请朋友,看看,看有什么不妥之处。
#include <iostream>
#include <math.h>
using namespace std;
class Point
{
private:
double xval, yval;
public:
Point(double x=0.0, double y=0.0)
{
xval = x;
yval = y;
}
double x() { return xval; }
double y() { return yval; }
}
double dist(Point other)
//距离
{
double xd = xval - other.xval;
double yd = yval - other.yval;
return sqrt(xd*xd + yd*yd);
}
Point add(Point b)
//加
{
return Point(xval + b.xval, yval + b.yval);
}
Point sub(Point b)
//减
{
return Point(xval - b.xval, yval- b.yval);
}
Point mul(Point b)
//乘
{
return Point(xval * b.xva + yval * b.yval);
}
Point div(Point b)
//除
{
return Point(xval - b.xval, y - b.yval);
}
void move(double a, double y)
//移动
{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
xval += a;
yval += b;
}
void rotate(double x1, double y1)
//平面内旋转
{
double a;
//(x, yi)*(cosa, isina)=(x1,y1i)
//即:(x1,y1(xcosa-ysina,i(sina+ycosa))
x1 = xcosa - ysina;
y1 = xsina + ycosa;
return Point(x1, y1);
}
}