Как применить Affine3d для Vector3d - PullRequest
0 голосов
/ 31 января 2020

У меня есть Vector3d, содержащий список вершин, и я пытаюсь применить к нему вращение, но не могу найти способ сделать это:

rotationArbitraryAxis(const Vector3d axis, const double angle) {

    Vector3d normAxis = axis.normalized();
    double radians = angle * M_PI / 180.0f;
    AngleAxisd aa(radians, normAxis);
    Affine3d fTransform = Translation3d(normAxis) * aa * Translation3d(-normAxis);

    const double* data = reinterpret_cast<const double*>(m_mesh.points().data());
    Vector3d verts(m_mesh.number_of_vertices());

    std::copy(data, data + m_mesh.number_of_vertices() * 3, verts.data());

    verts *= ???
}

Есть идеи?

1 Ответ

0 голосов
/ 31 января 2020

Как я уже сказал в своем комментарии, преобразуйте Affine3d в матрицу и используйте ее для преобразования вершин.

    const double* data = reinterpret_cast<const double*>(m_mesh.points().data());

    // I'm assuming you want this as an array of vector3's ???
    std::vector<Vector3d> verts(m_mesh.number_of_vertices());
    std::copy(data, data + m_mesh.number_of_vertices() * 3, verts.data());

    // convert the transform to a matrix
    auto matrix = fTransform.matrix();
    for(auto& vert : verts)
    {
      // now multiply
      vert = matrix * vert;
    }
...