我正在尝试将以下 JavaScript 代码移植到 C++:
var vector = new array();
for (var i = 0; i < points.length; i++)
{
var newX = points[i].X * cos - points[i].Y * sin;
var newY = points[i].Y * cos + points[i].X * sin;
vector[vector.length] = newX;
vector[vector.length] = newY;
sum += newX * newX + newY * newY;
}
我似乎无法理解这些行中发生了什么:
vector[vector.length] = newX;
vector[vector.length] = newY;
覆盖数组中相同位置的值的目的是什么?