Объясни, что делает код: 
void CalculationNormal::Calculation(double x1, double x2, double y1, double y2, double &normal_x, double &normal_y)
{
	dx = x2 - x1;
	dy = y2 - y1;
	length = sqrt(dx * dx + dy * dy);
	normal_x = - dy / length;
	normal_y = dx / length;
	direction = (x1 + x2) / 2 * normal_x + (y1 + y2) / 2 * normal_y;
	if (direction < 0)
	{
		normal_x = -normal_x;
		normal_y = -normal_y;
	}
}

//---------------------------------------------------------------------------

bool intersect(const point& Point, const point& point1, const point& point2)
{
	if ((point1.y > Point.y && point2.y <= Point.y) || (point2.y > Point.y && point1.y <= Point.y))
    {
		double t = (Point.y - point1.y) / (point2.y - point1.y);
		if (t >= 0 && t <= 1)
		{
			double x_intersect = point1.x + t * (point2.x - point1.x);
			if (x_intersect >= Point.x)
			{
                return true;
            }
        }
    }
    return false;
}

//---------------------------------------------------------------------------

bool isInside(const point& Point, const std::vector<point>& polyline)
{
    int intersections = 0;
    for (int i = 0; i < polyline.size(); i++)
    {
        const point& point1 = polyline[i];
        const point& point2 = polyline[(i + 1) % polyline.size()];
		if (intersect(Point, point1, point2))
        {
            intersections++;
        }
    }
    return (intersections % 2) == 1;
}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    if (OpenDialog1->Execute())
    {
        AnsiString fileName = OpenDialog1->FileName;
        FILE *file = fopen(fileName.c_str(), "r");
        double x, y;
        int NumPolylines;
        fscanf(file, "[Polylines]\n");
        fscanf(file, "%d\n", &NumPolylines);
        polylines.clear();
        polylines.resize(NumPolylines);
        for (int Poly = 0; Poly < NumPolylines; Poly++)
        {
            fscanf(file, "[Polyline]\n");
            int PolyIndex = 0;
            fscanf(file, "%d\n", &PolyIndex);
            int PointsCount = 0;
            fscanf(file, "%d\n", &PointsCount);
            for (int i = 0; i < PointsCount; i++)
            {
                if (fscanf(file, "%lf %lf\n", &x, &y) == 2)
                {
                    polylines[Poly].push_back({x, y});
                }
			}

		}
        fclose(file);

        centerX = PaintBox1->Width / 2;
		centerY = PaintBox1->Height / 2;
        PaintBox1->Canvas->Pen->Color = clBlack;
		PaintBox1->Canvas->Pen->Width = 2;

        for (int Poly = 0; Poly < NumPolylines; Poly++)
        {
            if (!polylines[Poly].empty())
            {
                PaintBox1->Canvas->MoveTo(centerX + scale * polylines[Poly][0].x, centerY - scale * polylines[Poly][0].y);
                for (size_t i = 1; i < polylines[Poly].size(); i++)
                {
                    PaintBox1->Canvas->LineTo(centerX + scale * polylines[Poly][i].x, centerY - scale * polylines[Poly][i].y);
                }
            }
		}
    }
    else
	{
		ShowMessage("Выбор файла отменен");
    }
}

//---------------------------------------------------------------------------

void __fastcall TForm1::PaintBox1Click(TObject *Sender)
{
	TPoint mousePos = PaintBox1->ScreenToClient(Mouse->CursorPos);
	double x = (mousePos.x - centerX) / scale;
	double y = -(mousePos.y - centerY) / scale;
	point testPoint = {x, y};

	PaintBox1->Canvas->Pen->Color = clRed;
	PaintBox1->Canvas->Brush->Color = clRed;
	PaintBox1->Canvas->Ellipse(mousePos.x - 3, mousePos.y - 3, mousePos.x + 3, mousePos.y + 3);

	int totalIntersections = 0;
	for (int Poly = 0; Poly < polylines.size(); Poly++)
	{
		for (int i = 0; i < polylines[Poly].size(); i++)
		{
			const point& point1 = polylines[Poly][i];
			const point& point2 = polylines[Poly][(i + 1) % polylines[Poly].size()];
			if (intersect(testPoint, point1, point2))
			{
				totalIntersections++;
			}
		}
	}

	if (totalIntersections % 2 == 1)
		{
			ShowMessage("Точка внутри фигуры");
		}
	else
		{
			ShowMessage("Точка снаружи фигуры");
		}
}
//-------------------------