输出测试贴.

Ac posted @ Feb 08, 2010 04:05:54 AM in 游戏编程 , 2689 阅读

detM=\begin{vmatrix}a_{x} & a_{y}\\b_{x} & b_{y}\end{vmatrix} = a_{x} b_{y} -a_{y}b_{x}$$

$$dist=\sqrt{(a_{x}-b_{x})^2 + (a_{y}-b_{y})^2} $$

#include <iostream>
#include <math.h>
class Cvect{
	public:
		int x,y;
		Cvect(int tx,int ty):x(tx),y(ty){}
		int det(Cvect &b){return x*b.y-y*b.x;}
		int dist(Cvect &b){return sqrt((b.x-x)*(b.x-x)+(b.y-y)*(b.y-y));}
};

int main(int argc,char** argv)
{
	Cvect a(10,20),Cvect b(5,30);
	std::cout<<"a det b is "<<a.det(b)
			<<"\nb det a is "<<b.det(a)
			<<"\ndist of a to b "<<a.dist(b)<<std::endl;
	return 0;
}

Tex,syntax测试..

 

 

  • 无匹配
  • 无匹配

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter