Beispiel #1
0
double Vector_2::distance( Vector_2 v )
{
	double dx = x-v.getX();
	double dy = y-v.getY();

	return sqrt( dx*dx + dy*dy );
}	
Beispiel #2
0
Vector_2 Vector_2::rayCrossPoint( Vector_2 v1, double angle1, Vector_2 v2, double angle2 )
{
	double x1 = v1.getX();
	double y1 = v1.getY();
	double x2 = v2.getX();
	double y2 = v2.getY();
	double rx1 = cos(angle1);
	double ry1 = sin(angle1);
	double rx2 = cos(angle2);
	double ry2 = sin(angle2);
	double detA = ry1*rx2 - rx1*ry2;

	if ( detA == 0 ) return Vector_2(0,0,U);

	double dx = x2-x1;
	double dy = y2-y1;
	double lambda = ( dy*rx2 - dx*ry2 ) / detA;

	return Vector_2( x1 + lambda*rx1, y1 + lambda*ry1, K );
}