SuperDex Physics C++ API
Loading...
Searching...
No Matches
transform_rt_utils.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
20
21namespace superdex {
22
23// Get/set rotation in converted formats
25 return ToMatrix3x3(transform.GetRotation());
26}
27
29 return ToVMatrix3x3(transform.GetRotation());
30}
31
32[[nodiscard]] MOCHI_FORCE_INLINE Vec4r GetRotationVector(TransformRT const& transform) {
33 return transform.GetRotation().VToRotationVector();
34}
35
36MOCHI_FORCE_INLINE void SetRotationVector(Vec4r const& rotVec, TransformRT& outTransform) {
37 outTransform.SetRotation(Quaternion::FromRotationVector(rotVec));
38}
39
40MOCHI_FORCE_INLINE void SetRotationVector(Real3 const& rotVec, TransformRT& outTransform) {
41 SetRotationVector(ToSimd(rotVec), outTransform);
42}
43
44} // namespace superdex
Vec4r VToRotationVector() const
static Quaternion FromRotationVector(Vec4r rotVector)
Quaternion const & GetRotation() const
void SetRotation(Quaternion const &rotation)
#define MOCHI_FORCE_INLINE
Simd< T, 4 > ToSimd(NdArray< T, 2 > const &v, T z=T(0), T w=T(0))
Definition vmatrix.h:413
Matrix3x3r GetRotationMatrix(TransformRT const &transform)
Matrix3x3r ToMatrix3x3(Quaternion const &q)
NdArray< Simd< real, 4 >, 3 > VMatrix3x3r
Definition vmatrix.h:52
Simd< real, 4 > Vec4r
Definition simd.h:206
void SetRotationVector(Vec4r const &rotVec, TransformRT &outTransform)
VMatrix3x3r VGetRotationMatrix(TransformRT const &transform)
NdArray< real, 3 > Real3
Definition nd_array.h:106
Vec4r GetRotationVector(TransformRT const &transform)
VMatrix3x3r ToVMatrix3x3(Quaternion const &q)
NdArray< real, 3, 3 > Matrix3x3r
Definition nd_array.h:125