line.cpp

来自「本程序是2005年参加中国机器人大赛的比赛程序」· C++ 代码 · 共 47 行

CPP
47
字号
// Line.cpp: implementation of the Line class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Robocup.h"
#include "Line.h"



#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Line::Line()
{
	k = 0;
	b = 0;
}

Line::~Line()
{

}

void Line::makeLine( const Vector &v, const double ang, BOOL rad )
{
	if( !rad )
		k = tan(ang*3.14159265/180.0);//角度
	else
		k = ang;//斜率
	b = v.y - k * v.x;
}

void Line::makeLine( const Vector& v1, const Vector& v2 )
{
	k = (v2.y-v1.y)/(v2.x-v1.x);
	b = v1.y - k * v1.x;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?