c++ - 将 2 个数组值添加到一个向量中 c++
问题描述
我有 2 个名为 movePositionsX 和 movePositionY 的数组,就像这样
int movePositionsX[5] = { 1080 , 720 , 160 , 240 , 640};
int movePositionsY[5] = { 720 , 360 , 520, 860 , 164};
我有一个随机获取两个数组上的随机位置之一,我想将它们都放入 1 vector2 我该怎么做?
这是向量2
vector<int> combine;
到目前为止我有这段代码,但它给出了一个错误'没有匹配的函数调用 std::vector::insert(, int&, int&, float&)'
circleObjectArray[i].setPosition(Interpolate(circleObjectArray[i].getPosition(),combine.insert(combine.end,movePositionsX[rand() % 5], movePositionsY[rand() % 5], factor));
这是我的插值函数
Vector2f Interpolate(
const Vector2f pointA,
const Vector2f pointB,
float factor
) {
if( factor > 1.f )
factor = 1.f;
else if( factor < 0.f )
factor = 0.f;
return pointA + (pointB - pointA) * factor;
}
如何将数组的两个值组合成 1 个 vector2 以在此函数中使用它?
谢谢你的时间:D
解决方案
推荐阅读
- java - Spring Boot Security 禁用特定 URL 的 Web 安全性
- azure - 基于 REST 的服务在 Azure 中的 Kubernetes 上作为 pod 运行,并出现间歇性超时
- ruby - 如何以编程方式关闭 Sinatra Web 应用程序?
- jenkins - 如何在 Jenkins 共享库中导入外部类
- javascript - 输入的值即使不满足要求也会发送
- php - 单击提交按钮时,成功提交按摩显示,但某些字段为空。还显示未定义索引和未定义变量错误
- hadoop - 我们如何知道HDFS的阈值,如果使用cloudera我们每次都必须手动检查吗?
- javascript - 在地图功能中定位点击的卡片索引
- keras - TypeError:('关键字参数不理解:','data_format')
- java - Rabbitmq 只允许一个并发消费者