Skip to content

Commit ee71818

Browse files
cdtwiggfacebook-github-bot
authored andcommitted
Simpler implementation of quaternion conjugate.
Summary: The existing code is failing because the Vec4f isn't on the GPU, but this is a better implementation anyways. Reviewed By: jeongseok-meta Differential Revision: D65245708 fbshipit-source-id: c353c8b84503f49404ac10eb638287e4d3256c2c
1 parent 824175d commit ee71818

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

pymomentum/tensor_momentum/tensor_quaternion.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,9 @@ at::Tensor quaternionNormalize(at::Tensor q) {
217217

218218
at::Tensor quaternionConjugate(at::Tensor q) {
219219
checkQuaternion(q);
220-
const auto scalar_type =
221-
at::promote_types(q.scalar_type(), toScalarType<float>());
222-
const Eigen::Vector4f tmp(-1, -1, -1, 1);
223-
at::Tensor prodMatrix = to1DTensor(tmp).to(scalar_type);
224-
return q.to(scalar_type) * prodMatrix;
220+
auto [scalar, vec] = splitQuaternion(q);
221+
222+
return at::concat({-vec, scalar}, -1);
225223
}
226224

227225
at::Tensor quaternionInverse(at::Tensor q) {

0 commit comments

Comments
 (0)