arma 3 nearest terrain objects

#include <iostream>
#include <vector>

class Object {
public:
    float x, y, z;

    Object(float x, float y, float z) : x(x), y(y), z(z) {}
};

float distance(float x1, float y1, float z1, float x2, float y2, float z2) {
    return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2) + pow(z2 - z1, 2));
}

Object findNearestObject(float playerX, float playerY, float playerZ, const std::vector<Object>& objects) {
    Object nearestObject = objects[0];
    float nearestDistance = distance(playerX, playerY, playerZ, nearestObject.x, nearestObject.y, nearestObject.z);

    for (const auto& obj : objects) {
        float dist = distance(playerX, playerY, playerZ, obj.x, obj.y, obj.z);
        if (dist < nearestDistance) {
            nearestDistance = dist;
            nearestObject = obj;
        }
    }

    return nearestObject;
}

int main() {
    float playerX = 0.0f, playerY = 0.0f, playerZ = 0.0f; // Replace with actual player coordinates
    std::vector<Object> terrainObjects = {
        {1.0f, 2.0f, 3.0f}, // Replace with actual object coordinates
        {4.0f, 5.0f, 6.0f}, // Replace with actual object coordinates
        {7.0f, 8.0f, 9.0f}  // Replace with actual object coordinates
    };

    Object nearestObject = findNearestObject(playerX, playerY, playerZ, terrainObjects);

    // Access nearestObject for further use

    return 0;
}