Qt Quick3D:在两个点之间绘制一条3D线

Qt Quick3D:在两个点之间绘制一条3D线,qt,qt6,qtquick3d,Qt,Qt6,Qtquick3d,我正在使用Qt6中的新QtQuick3D。我需要在两点之间画一条线,但没有找到专门用于此的函数。因此,我决定使用一个基本的圆柱体,我可以缩放和旋转。缩放按预期工作,但旋转有一些问题 Node { property vector3d center property vector3d scaleCylinder property vector3d eulerAngles Model { id: line position: cente

我正在使用Qt6中的新QtQuick3D。我需要在两点之间画一条线,但没有找到专门用于此的函数。因此,我决定使用一个基本的圆柱体,我可以缩放和旋转。缩放按预期工作,但旋转有一些问题

Node {
    property vector3d center
    property vector3d scaleCylinder
    property vector3d eulerAngles

    Model {
        id: line
        position: center
        source: "#Cylinder"
        scale: scaleCylinder
        eulerRotation: eulerAngles

        materials:
            DefaultMaterial {
            diffuseColor: "blue"
        }
    }
}
我使用特征库计算旋转,通过角度轴检索Euler角度。显示时,圆柱体轴位于Y轴上

AngleAxis angleAxis(const PointType vec) {

    double angle;
    VectorType axis;

    PointType a = PointType({0, 1, 0});
    PointType v = normalize(vec);

    axis = point2vector(normalize(cross(a, v)));
    angle = acos(dot(a, v));

    return AngleAxis(angle, axis);
}

void setEulerAngles() {
    AngleAxis rotation = angleAxis(target - entry);
    VectorType angles= rotation.toRotationMatrix().eulerAngles(0, 1, 2);
    eulerAngles = QVector3D(float(angles[0] * 180.0 / M_PI), float(angles[1] * 180.0 / M_PI), float(angles[2] * 180.0 / M_PI));
}
我计算欧拉角时出错了吗?我应该使用另一种技术,比如四元数吗?也许有一个更简单的解决方案我不知道