我尝试使用 atan2f 更改对象朝向中心的方向,但它给了我错误的值。我在某个地方错了吗?
glm::vec3 center = glm::vec3(0.4f, 0.4f, 0.0f);
for(int i = 0; i < num; i++){
float rel = i / (float) num;
float angle = rel * M_PI * 2;
glm::vec3 position = glm::vec3(cos(angle), glm::sin(angle), position.z);
position.x *= radius; position.y *= radius;
position.x += center; position.y += center;
glm::mat4 trans = glm::translate(glm::mat4(1.0f), position);
float newAngle = atan2f(position.y - center.y, position.x - center.x);
glm::mat4 rotation = glm::rotation(glm::mat4(1.0f), newAngle, glm::vec3(0, 0, 1));
numModel.at(i) = trans * rotation;
}