|
|
@ -19,20 +19,11 @@ Eigen::Matrix3d subface::trans_world_to_local_linear() const { return model_matr |
|
|
|
|
|
|
|
std::pair<internal::paired_model_matrix *, bool> subface::apply_transform(internal::transform_type type, Eigen::Vector4d param) |
|
|
|
{ |
|
|
|
std::cout << "Applying transform: " << param.head<3>() << std::endl; |
|
|
|
auto temp = *model_matrices; |
|
|
|
switch (type) { |
|
|
|
case internal::transform_type::scale: { |
|
|
|
std::cout << "Before scale:" << std::endl; |
|
|
|
std::cout << "local_to_world.linear():\n" << temp.local_to_world.linear() << std::endl; |
|
|
|
std::cout << "world_to_local.linear():\n" << temp.world_to_local.linear() << std::endl; |
|
|
|
|
|
|
|
temp.local_to_world.linear() = param.head<3>().asDiagonal() * temp.local_to_world.linear(); |
|
|
|
temp.world_to_local.linear() = temp.world_to_local.linear() * param.head<3>().cwiseInverse().asDiagonal(); |
|
|
|
|
|
|
|
std::cout << "After scale:" << std::endl; |
|
|
|
std::cout << "local_to_world.linear():\n" << temp.local_to_world.linear() << std::endl; |
|
|
|
std::cout << "world_to_local.linear():\n" << temp.world_to_local.linear() << std::endl; |
|
|
|
} break; |
|
|
|
case internal::transform_type::rotation: { |
|
|
|
auto rotation_matrix = Eigen::Quaterniond(param).toRotationMatrix(); |
|
|
@ -40,14 +31,8 @@ std::pair<internal::paired_model_matrix *, bool> subface::apply_transform(intern |
|
|
|
temp.world_to_local.linear() = temp.world_to_local.linear() * rotation_matrix.transpose(); |
|
|
|
} break; |
|
|
|
case internal::transform_type::translation: { |
|
|
|
std::cout << "Before translation: " << std::endl; |
|
|
|
std::cout << "Local to world: " << temp.local_to_world.translation() << std::endl; |
|
|
|
std::cout << "World to local: " << temp.world_to_local.translation() << std::endl; |
|
|
|
temp.local_to_world.translation() += param.head<3>(); |
|
|
|
temp.world_to_local.translation() -= param.head<3>(); |
|
|
|
std::cout << "After translation: " << std::endl; |
|
|
|
std::cout << "Local to world: " << temp.local_to_world.translation() << std::endl; |
|
|
|
std::cout << "World to local: " << temp.world_to_local.translation() << std::endl; |
|
|
|
} break; |
|
|
|
default: throw std::invalid_argument("Invalid transform type"); |
|
|
|
} |
|
|
|