亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? geometry.cpp

?? 一個(gè)C編寫的足球機(jī)器人比賽程序
?? CPP
?? 第 1 頁 / 共 4 頁
字號(hào):
    // and finally the two intersection points
    x =  p2_x - h * dy;
    y =  p2_y + h * dx;
    p1->setVecPosition( x, y );
    x =  p2_x + h * dy;
    y =  p2_y - h * dx;
    p2->setVecPosition( x, y );
	
    return (arg < 0.0) ? 0 : ((arg == 0.0 ) ? 1 :  2);
}

/*! This method returns the size of the intersection area of two circles.
\param c circle with which intersection should be determined
\return size of the intersection area. */
double Circle::getIntersectionArea( Circle c )
{
	VecPosition pos1, pos2, pos3;
	double d, h, dArea;
	AngDeg ang;
	
	d = getCenter().getDistanceTo( c.getCenter() ); // dist between two centers
	if( d > c.getRadius() + getRadius() )           // larger than sum radii
		return 0.0;                                   // circles do not intersect
	if( d <= fabs(c.getRadius() - getRadius() ) )   // one totally in the other
	{
		double dR = min( c.getRadius(), getRadius() );// return area smallest circ
		return M_PI*dR*dR;
	}
	
	int iNrSol = getIntersectionPoints( c, &pos1, &pos2 );
	if( iNrSol != 2 )
		return 0.0;
	
	// the intersection area of two circles can be divided into two segments:
	// left and right of the line between the two intersection points p1 and p2.
	// The outside area of each segment can be calculated by taking the part
	// of the circle pie excluding the triangle from the center to the
	// two intersection points.
	// The pie equals pi*r^2 * rad(2*ang) / 2*pi = 0.5*rad(2*ang)*r^2 with ang
	// the angle between the center c of the circle and one of the two
	// intersection points. Thus the angle between c and p1 and c and p3 where
	// p3 is the point that lies halfway between p1 and p2.
	// This can be calculated using ang = asin( d / r ) with d the distance
	// between p1 and p3 and r the radius of the circle.
	// The area of the triangle is 2*0.5*h*d.
	
	pos3 = pos1.getVecPositionOnLineFraction( pos2, 0.5 );
	d = pos1.getDistanceTo( pos3 );
	h = pos3.getDistanceTo( getCenter() );
	ang = asin( d / getRadius() );
	
	dArea = ang*getRadius()*getRadius();
	dArea = dArea - d*h;
	
	// and now for the other segment the same story
	h = pos3.getDistanceTo( c.getCenter() );
	ang = asin( d / c.getRadius() );
	dArea = dArea + ang*c.getRadius()*c.getRadius();
	dArea = dArea - d*h;
	
	return dArea;
}


/*****************************************************************************/
/***********************  CLASS LINE *****************************************/
/*****************************************************************************/

/*! This constructor creates a line by given the three coefficents of the line.
A line is specified by the formula ay + bx + c = 0.
\param dA a coefficients of the line
\param dB b coefficients of the line
\param dC c coefficients of the line */
Line::Line( double dA, double dB, double dC )
{
	m_a = dA;
	m_b = dB;
	m_c = dC;
}


/*! This method returns the intersection point between the current Line and
the specified line.
\param line line with which the intersection should be calculated.
\return VecPosition position that is the intersection point. */
VecPosition Line::getIntersection( Line line )
{
	VecPosition pos;
	double x, y;
	if(m_b == 0 || line.getBCoefficient() == 0)
	{
		if(m_b == line.getBCoefficient())
		{
			return pos;  // lines are parallel, no intersection
		}
		else if(m_b == 0)
		{
			y = - m_c / m_a;
			x = line.getXGivenY(y);
		}
		else
		{
			y = - line.getCCoefficient() / line.getACoefficient();
			x = getXGivenY(y);
		}
		return VecPosition( x, y );
	}
	if( ( m_a / m_b ) ==  (line.getACoefficient() / line.getBCoefficient() ))
		return pos; // lines are parallel, no intersection
	if( m_a == 0 )            // bx + c = 0 and a2*y + b2*x + c2 = 0 ==> x = -c/b
	{                          // calculate x using the current line
		x = -m_c/m_b;                // and calculate the y using the second line
		y = line.getYGivenX(x);
	}
	else if( line.getACoefficient() == 0 )
	{                         // ay + bx + c = 0 and b2*x + c2 = 0 ==> x = -c2/b2
		x = -line.getCCoefficient()/line.getBCoefficient(); // calculate x using
		y = getYGivenX(x);       // 2nd line and calculate y using current line
	}
	// ay + bx + c = 0 and a2y + b2*x + c2 = 0
	// y = (-b2/a2)x - c2/a2
	// bx = -a*y - c =>  bx = -a*(-b2/a2)x -a*(-c2/a2) - c ==>
	// ==> a2*bx = a*b2*x + a*c2 - a2*c ==> x = (a*c2 - a2*c)/(a2*b - a*b2)
	// calculate x using the above formula and the y using the current line
	else
	{
		x = (m_a*line.getCCoefficient() - line.getACoefficient()*m_c)/
			(line.getACoefficient()*m_b - m_a*line.getBCoefficient());
		y = getYGivenX(x);
	}
	
	return VecPosition( x, y );
}


/*! This method calculates the intersection points between the current line
and the circle specified with as center 'posCenter' and radius 'dRadius'.
The number of solutions are returned and the corresponding points are put
in the third and fourth argument of the method
\param c circle with which intersection points should be found
\param posSolution1 first intersection (if any)
\param posSolution2 second intersection (if any) */
int Line::getCircleIntersectionPoints( Circle circle,
									  VecPosition *posSolution1, VecPosition *posSolution2 )
{
	int    iSol;
	double dSol1=0, dSol2=0;
	double h = circle.getCenter().getX();
	double k = circle.getCenter().getY();
	
	// line:   x = -c/b (if a = 0)
	// circle: (x-h)^2 + (y-k)^2 = r^2, with h = center.x and k = center.y
	// fill in:(-c/b-h)^2 + y^2 -2ky + k^2 - r^2 = 0
	//         y^2 -2ky + (-c/b-h)^2 + k^2 - r^2 = 0
	// and determine solutions for y using abc-formula
	if( fabs(m_a) < EPSILON )
	{
		iSol = Geometry::abcFormula( 1, -2*k, ((-m_c/m_b) - h)*((-m_c/m_b) - h)
			+ k*k - circle.getRadius()*circle.getRadius(), &dSol1, &dSol2);
		posSolution1->setVecPosition( (-m_c/m_b), dSol1 );
		posSolution2->setVecPosition( (-m_c/m_b), dSol2 );
		return iSol;
	}
	
	// ay + bx + c = 0 => y = -b/a x - c/a, with da = -b/a and db = -c/a
	// circle: (x-h)^2 + (y-k)^2 = r^2, with h = center.x and k = center.y
	// fill in:x^2 -2hx + h^2 + (da*x-db)^2 -2k(da*x-db) + k^2 - r^2 = 0
	//         x^2 -2hx + h^2 + da^2*x^2 + 2da*db*x + db^2 -2k*da*x -2k*db
	//                                                         + k^2 - r^2 = 0
	//       (1+da^2)*x^2 + 2(da*db-h-k*da)*x + h2 + db^2  -2k*db + k^2 - r^2 = 0
	// and determine solutions for x using abc-formula
	// fill in x in original line equation to get y coordinate
	double da = -m_b/m_a;
	double db = -m_c/m_a;
	
	double dA = 1 + da*da;
	double dB = 2*( da*db - h - k*da );
	double dC = h*h + db*db-2*k*db + k*k - circle.getRadius()*circle.getRadius();
	
	iSol = Geometry::abcFormula( dA, dB, dC, &dSol1, &dSol2 );
	
	posSolution1->setVecPosition( dSol1, da*dSol1 + db );
	posSolution2->setVecPosition( dSol2, da*dSol2 + db );
	return iSol;
	
}

/*! This method returns the tangent line to a VecPosition. This is the line
between the specified position and the closest point on the line to this
position.
\param pos VecPosition point with which tangent line is calculated.
\return Line line tangent to this position */
Line Line::getTangentLine( VecPosition pos )
{
	// ay + bx + c = 0 -> y = (-b/a)x + (-c/a)
	// tangent: y = (a/b)*x + C1 -> by - ax + C2 = 0 => C2 = ax - by
	// with pos.y = y, pos.x = x
	return Line( m_b, -m_a, m_a*pos.getX() - m_b*pos.getY() );
}

/*! This method returns the closest point on a line to a given position.
\param pos point to which closest point should be determined
\return VecPosition closest point on line to 'pos'. */
VecPosition Line::getPointOnLineClosestTo( VecPosition pos )
{
	Line l2 = getTangentLine( pos );  // get tangent line
	return getIntersection( l2 );     // and intersection between the two lines
}

/*! This method returns the distance between a specified position and the
closest point on the given line.
\param pos position to which distance should be calculated
\return double indicating the distance to the line. */
double Line::getDistanceWithPoint( VecPosition pos )
{
	return pos.getDistanceTo( getPointOnLineClosestTo( pos ) );
}

/*! This method determines whether the projection of a point on the
current line lies between two other points ('point1' and 'point2')
that lie on the same line.

  \param pos point of which projection is checked.
  \param point1 first point on line
  \param point2 second point on line
\return true when projection of 'pos' lies between 'point1' and 'point2'.*/
bool Line::isInBetween( VecPosition pos, VecPosition point1,VecPosition point2)
{
	pos          = getPointOnLineClosestTo( pos ); // get closest point
	double dDist = point1.getDistanceTo( point2 ); // get distance between 2 pos
	
	// if the distance from both points to the projection is smaller than this
	// dist, the pos lies in between.
	return pos.getDistanceTo( point1 ) <= dDist &&
		pos.getDistanceTo( point2 ) <= dDist;
}

/*! This method calculates the y coordinate given the x coordinate
\param x coordinate
\return y coordinate on this line */
double Line::getYGivenX( double x )
{
	if( m_a == 0 )
	{
		return 0;
	}
	// ay + bx + c = 0 ==> ay = -(b*x + c)/a
	return -(m_b*x+m_c)/m_a;
}

/*! This method calculates the x coordinate given the x coordinate
\param y coordinate
\return x coordinate on this line */
double Line::getXGivenY( double y )
{
	if( m_b == 0 )
	{
		cerr << "(Line::getXGivenY) Cannot calculate X coordinate\n" ;
		return 0;
	}
	// ay + bx + c = 0 ==> bx = -(a*y + c)/a
	return -(m_a*y+m_c)/m_b;
}

/*! This method creates a line given two points.
\param pos1 first point
\param pos2 second point
\return line that passes through the two specified points. */
Line Line::makeLineFromTwoPoints( VecPosition pos1, VecPosition pos2 )
{
	// 1*y + bx + c = 0 => y = -bx - c
	// with -b the direction coefficient (or slope)
	// and c = - y - bx
	double dA, dB, dC;
	double dTemp = pos2.getX() - pos1.getX(); // determine the slope
	if( fabs(dTemp) < EPSILON )
	{
		// ay + bx + c = 0 with vertical slope=> a = 0, b = 1
		dA = 0.0;
		dB = 1.0;
	}
	else
	{
		// y = (-b)x -c with -b the slope of the line
		dA = 1.0;
		dB = -(pos2.getY() - pos1.getY())/dTemp;
	}
	// ay + bx + c = 0 ==> c = -a*y - b*x
	dC =  - dA*pos2.getY()  - dB * pos2.getX();
	return Line( dA, dB, dC );
}

/*! This method creates a line given a position and an angle.
\param vec position through which the line passes
\param angle direction of the line.
\return line that goes through position 'vec' with angle 'angle'. */
Line Line::makeLineFromPositionAndAngle( VecPosition vec, AngDeg angle )
{
	// calculate point somewhat further in direction 'angle' and make
	// line from these two points.
	return makeLineFromTwoPoints( vec, vec+VecPosition(1,angle,POLAR));
}

/*! This method returns the a coefficient from the line ay + bx + c = 0.
\return a coefficient of the line. */
double Line::getACoefficient() const
{
	return m_a;
}

/*! This method returns the b coefficient from the line ay + bx + c = 0.
\return b coefficient of the line. */
double Line::getBCoefficient() const
{
	return m_b;
}

/*! This method returns the c coefficient from the line ay + bx + c = 0.
\return c coefficient of the line. */
double Line::getCCoefficient() const
{
	return m_c;
}

/*****************************************************************************/
/********************* CLASS RECTANGLE ***************************************/
/*****************************************************************************/

/*! This is the constructor of a Rectangle. Two points will be given. The
order does not matter as long as two opposite points are given (left
top and right bottom or right top and left bottom).
\param pos first point that defines corner of rectangle
\param pos2 second point that defines other corner of rectangle
\return rectangle with 'pos' and 'pos2' as opposite corners. */
Rect::Rect( VecPosition pos, VecPosition pos2 )
{
	setRectanglePoints( pos, pos2 );
}

/*! This method sets the upper left and right bottom point of the current
rectangle.
\param pos first point that defines corner of rectangle
\param pos2 second point that defines other corner of rectangle */
void Rect::setRectanglePoints( VecPosition pos1, VecPosition pos2 )
{
	m_posLeftTop.setX    ( max( pos1.getX(), pos2.getX() ) );
	m_posLeftTop.setY    ( min( pos1.getY(), pos2.getY() ) );
	m_posRightBottom.setX( min( pos1.getX(), pos2.getX() ) );
	m_posRightBottom.setY( max( pos1.getY(), pos2.getY() ) );
}

/*! This method determines whether the given position lies inside the current
rectangle.
\param pos position which is checked whether it lies in rectangle
\return true when 'pos' lies in the rectangle, false otherwise */
bool Rect::isInside( VecPosition pos )
{
	return pos.isBetweenX( m_posRightBottom.getX(), m_posLeftTop.getX() ) &&
		pos.isBetweenY( m_posLeftTop.getY(),     m_posRightBottom.getY() );
	
}

/*! This method sets the top left position of the rectangle
\param pos new top left position of the rectangle
\return true when update was successful */
bool Rect::setPosLeftTop( VecPosition pos )
{
	m_posLeftTop = pos;
	return true;
}

/*! This method returns the top left position of the rectangle
\return top left position of the rectangle */
VecPosition Rect::getPosLeftTop(  )
{
	return m_posLeftTop;
}

/*! This method sets the right bottom position of the rectangle
\param pos new right bottom position of the rectangle
\return true when update was successful */
bool Rect::setPosRightBottom( VecPosition pos )
{
	m_posRightBottom = pos;
	return true;
}

/*! This method returns the right bottom position of the rectangle
\return top right bottom of the rectangle */
VecPosition Rect::getPosRightBottom(  )
{
	return m_posRightBottom;
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久国产欧美日韩精品| 96av麻豆蜜桃一区二区| 日韩激情中文字幕| 亚洲国产毛片aaaaa无费看 | 中文字幕日韩精品一区| 国产日韩影视精品| 国产女主播视频一区二区| 日本一区二区视频在线| 欧美高清一级片在线观看| 国产日韩av一区| 国产精品乱码人人做人人爱 | 日韩黄色片在线观看| 午夜视频一区二区三区| 日韩电影免费在线| 久草精品在线观看| 国产精品一二三四区| 国产成人免费视频精品含羞草妖精 | 午夜亚洲国产au精品一区二区| 亚洲在线视频网站| 婷婷中文字幕综合| 久久av资源站| 国产成人a级片| 97se亚洲国产综合自在线不卡| 日本精品免费观看高清观看| 欧美日韩午夜精品| 日韩精品一区二区三区在线观看| 2020国产精品自拍| 亚洲欧美在线另类| 亚洲国产成人av| 久久精品国产一区二区三区免费看| 国产九色sp调教91| 99视频精品全部免费在线| 欧美羞羞免费网站| 精品国精品国产尤物美女| 欧美国产欧美综合| 亚洲国产精品影院| 久久成人av少妇免费| 菠萝蜜视频在线观看一区| 欧美天天综合网| 精品国精品国产| 亚洲欧美欧美一区二区三区| 天堂va蜜桃一区二区三区| 久久99热这里只有精品| 99re热这里只有精品视频| 欧美日韩亚洲国产综合| 国产亚洲精品久| 午夜免费久久看| 国产iv一区二区三区| 欧美影院午夜播放| 久久精品在这里| 一级精品视频在线观看宜春院| 美女免费视频一区二区| av高清久久久| 精品国产乱码久久久久久夜甘婷婷 | 欧美tickling挠脚心丨vk| 中文字幕一区二区三区在线不卡| 日日欢夜夜爽一区| 成人黄色小视频| 日韩一级成人av| 亚洲乱码日产精品bd| 久久99精品国产91久久来源| 在线观看亚洲成人| 国产精品丝袜黑色高跟| 热久久国产精品| 欧美最新大片在线看| 欧美国产视频在线| 久久se这里有精品| 在线成人小视频| 中文字幕一区视频| 国产精品一区二区视频| 欧美日韩国产大片| 亚洲日穴在线视频| 国产成人av电影在线播放| 日韩一区二区中文字幕| 亚洲综合视频在线观看| 成人app下载| 久久精品水蜜桃av综合天堂| 蜜桃视频在线观看一区| 欧美久久高跟鞋激| 一区二区三区自拍| 99精品热视频| 中文字幕欧美区| 国产美女精品在线| 欧美成人国产一区二区| 天天av天天翘天天综合网色鬼国产| 99九九99九九九视频精品| 中文字幕精品一区二区三区精品| 麻豆成人av在线| 欧美一区二区三区四区久久 | 国产99久久久国产精品免费看| 91精品国产综合久久福利| 亚洲成人中文在线| 色欧美片视频在线观看在线视频| 欧美韩日一区二区三区| 国产成人在线视频网站| 久久久一区二区三区捆绑**| 国产一区二区三区综合| 欧美电影精品一区二区| 美美哒免费高清在线观看视频一区二区 | 亚洲人成在线播放网站岛国| www.成人网.com| 国产精品久久久久影视| 成人av在线电影| 国产精品成人在线观看| 99视频国产精品| 亚洲伦理在线精品| 欧美午夜视频网站| 日韩精品每日更新| 欧美一区二区三区免费观看视频| 日韩av高清在线观看| 日韩免费性生活视频播放| 精彩视频一区二区| 久久午夜羞羞影院免费观看| 国产成人综合在线观看| 国产精品每日更新在线播放网址| eeuss影院一区二区三区| 亚洲男同1069视频| 欧美日韩一二三区| 美国一区二区三区在线播放| 久久精品在线观看| 99在线精品视频| 亚洲第一成人在线| 精品久久久久久久久久久久久久久 | 日韩电影免费在线| 日韩久久精品一区| 国产成人av福利| 亚洲日本欧美天堂| 在线电影一区二区三区| 极品销魂美女一区二区三区| 国产欧美一区二区三区在线老狼| 91美女在线看| 日韩一区精品字幕| 欧美一区二区三区啪啪| 福利一区福利二区| 亚洲综合成人网| 欧美成人三级在线| av电影在线观看一区| 午夜欧美电影在线观看| 久久中文字幕电影| 色婷婷av一区二区三区软件 | 成人网在线免费视频| 亚洲精品视频免费观看| 日韩一区二区在线免费观看| 国产成a人亚洲精品| 亚洲成人第一页| 国产色91在线| 欧美片网站yy| 成人激情小说乱人伦| 亚洲国产精品久久久男人的天堂| 欧美mv和日韩mv国产网站| 91污在线观看| 老色鬼精品视频在线观看播放| 国产精品丝袜91| 日韩一级视频免费观看在线| av不卡一区二区三区| 麻豆91免费看| 亚洲欧洲中文日韩久久av乱码| 欧美一级国产精品| 91蜜桃在线免费视频| 韩国成人福利片在线播放| 一区二区免费在线播放| 国产日韩欧美不卡在线| 4438x成人网最大色成网站| 99精品视频一区| 国模娜娜一区二区三区| 亚洲第一福利视频在线| 国产精品三级av| 精品少妇一区二区三区在线视频| 在线观看日韩高清av| 成人高清免费观看| 久久精品久久精品| 午夜精品久久久久久久99樱桃| 亚洲欧洲日产国产综合网| 精品剧情在线观看| 欧美日韩免费视频| 99国产精品视频免费观看| 韩国v欧美v日本v亚洲v| 轻轻草成人在线| 亚洲午夜精品在线| 中文字幕综合网| 中文字幕av一区二区三区高| 亚洲精品一线二线三线无人区| 欧美亚一区二区| 99国产一区二区三精品乱码| 国产盗摄一区二区三区| 久久99国产乱子伦精品免费| 日韩一区精品字幕| 亚洲成a人片在线不卡一二三区| 亚洲免费视频中文字幕| 国产精品国产自产拍在线| 精品日产卡一卡二卡麻豆| 欧美一区二区三区视频免费| 欧美日韩高清影院| 欧美日韩免费观看一区二区三区| 91女神在线视频| 91一区二区三区在线观看| 成人网在线免费视频| 国产不卡一区视频| 大尺度一区二区| 成人精品一区二区三区中文字幕|