Commit aa1d1c72 authored by Alexey Hohlov's avatar Alexey Hohlov
Browse files

Корректное обращение с точками в полигоне

parent dd8e3851
......@@ -300,23 +300,35 @@ CPoly::CPoly(CPoint pos)
radius = 0;
_pos.x = pos.x;
_pos.y = pos.y;
_pos.z = pos.z;
}
void CPoly::AddVertex(float x, float y)
{
CPoint* tmp_arr = new CPoint[vertex_count+1];
for (uint8_t i = 0; i < vertex_count; i++) {
float _x, _y;
uint8_t i;
CPoint* tmp_arr;
vertex_count++;
tmp_arr = new CPoint[vertex_count];
for (i = 0; i < vertex_count - 1; i++) {
tmp_arr[i] = vertex_arr[i];
}
delete vertex_arr;
delete vertex_arr_t;
vertex_arr[vertex_count] = point(x, y);
delete [] vertex_arr;
delete [] vertex_arr_t;
vertex_arr = tmp_arr;
vertex_count++;
vertex_arr[vertex_count] = point(x,y);
vertex_arr_t = new CPoint[vertex_count];
for (i = 0; i < vertex_count; i++) {
_x = vertex_arr[i].x;
_y = vertex_arr[i].y;
vertex_arr_t[i].x = _x * Cos(_angle) + _y * Sin(_angle) + _pos.x;
vertex_arr_t[i].y = _x * Sin(_angle) - _y * Cos(_angle) + _pos.y;
}
if (sqrt(x*x + y*y) > radius)
radius = sqrt(x*x + y*y);
......@@ -363,6 +375,6 @@ float CPoly::angle()
CPoly::~CPoly()
{
delete vertex_arr;
delete vertex_arr_t;
delete [] vertex_arr;
delete [] vertex_arr_t;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment