求助,如何把火山的数组传进这个嵌入函数??
#include <vector>
#include <cmath>
float calculateMostFrequentYawAngle(float Rx, float Ry, const std::vector<std::pair<float, float>>& monsterPositions, float angleRange = 25.0f)
{
std::map<float, int> yawCounts;
for (const auto& pos : monsterPositions)
{
float dx = pos.first - Rx;
float dy = pos.second - Ry;
float yaw = std::atan2(dy, dx) * 180.0f / M_PI;
while (yaw < 0.0f)
yaw += 360.0f;
while (yaw >= 360.0f)
yaw -= 360.0f;
for (float yawInRange = yaw - angleRange; yawInRange <= yaw + angleRange; yawInRange++)
{
if (yawInRange < 0.0f)
yawInRange += 360.0f;
else if (yawInRange >= 360.0f)
yawInRange -= 360.0f;
yawCounts++;
}
}
float mostFrequentYaw = 0.0f;
int maxCount = 0;
for (const auto& entry : yawCounts)
{
if (entry.second > maxCount)
{
mostFrequentYaw = entry.first;
maxCount = entry.second;
}
}
return mostFrequentYaw;
}
用别名就行,以下代码基于PIV模块
<火山程序 类型 = "通常" 版本 = 1 />
类 monsterPosition <公开 基础类 = 标准键值对模板 @模板实现类 = "单精度小数, 单精度小数">
类 monsterPositions <公开 基础类 = PIV数值模板 @模板实现类 = "monsterPosition">
{
#
}
页:
[1]