Vector2 LandscapeEditorDrawSystem::TranslatePoint(const Vector2& point, const Rect& fromRect, const Rect& toRect)
{
	DVASSERT(fromRect.dx != 0.f && fromRect.dy != 0.f);

	Vector2 origRectSize = fromRect.GetSize();
	Vector2 destRectSize = toRect.GetSize();

	Vector2 scale(destRectSize.x / origRectSize.x,
				  destRectSize.y / origRectSize.y);

	Vector2 relPos = point - fromRect.GetPosition();
	Vector2 newRelPos(relPos.x * scale.x,
					  relPos.y * scale.y);

	Vector2 newPos = newRelPos + toRect.GetPosition();

	return newPos;
}
Vector2 LandscapeTestData::TranslatePoint(const Vector2& point, const DAVA::Rect& destPlane) const
{
	DVASSERT(landscapeRect.dx != 0 && landscapeRect.dy !=0);
	
	Vector2 origPlaneSize = landscapeRect.GetSize();
	Vector2 destPlaneSize = destPlane.GetSize();

	Vector2 scale(destPlaneSize.x / origPlaneSize.x,
				  destPlaneSize.y / origPlaneSize.y);
	
	Vector2 relPos = point - landscapeRect.GetPosition();

	Vector2 newRelPos(relPos.x * scale.x,
					  relPos.y * scale.y);

	Vector2 newPos = newRelPos + destPlane.GetPosition();

	return newPos;
}
Rect LandscapeTestData::TranslateRect(const Rect &rect, const Rect& destPlane) const
{
	DVASSERT(landscapeRect.dx != 0 && landscapeRect.dy !=0);
	
	Vector2 origPlaneSize = landscapeRect.GetSize();
	Vector2 destPlaneSize = destPlane.GetSize();

	Vector2 scale(destPlaneSize.x / origPlaneSize.x,
				   destPlaneSize.y / origPlaneSize.y);

	Vector2 relPos = rect.GetPosition() - landscapeRect.GetPosition();

	Vector2 newRelPos(relPos.x * scale.x,
					  relPos.y * scale.y);

	Vector2 newPos = newRelPos + destPlane.GetPosition();

	Vector2 newSize(rect.GetSize().x * scale.x,
					rect.GetSize().y * scale.y);

	return Rect(newPos, newSize);
}