1// Copyright 2009-2021 Intel Corporation
2// SPDX-License-Identifier: Apache-2.0
3
4#pragma once
5
6#include "rtcore_common.h"
7
8RTC_NAMESPACE_BEGIN
9
10/*
11 * Structure for transformation representation as a matrix decomposition using
12 * a quaternion
13 */
14struct RTC_ALIGN(16) RTCQuaternionDecomposition
15{
16 float scale_x;
17 float scale_y;
18 float scale_z;
19 float skew_xy;
20 float skew_xz;
21 float skew_yz;
22 float shift_x;
23 float shift_y;
24 float shift_z;
25 float quaternion_r;
26 float quaternion_i;
27 float quaternion_j;
28 float quaternion_k;
29 float translation_x;
30 float translation_y;
31 float translation_z;
32};
33
34RTC_FORCEINLINE void rtcInitQuaternionDecomposition(struct RTCQuaternionDecomposition* qdecomp)
35{
36 qdecomp->scale_x = 1.f;
37 qdecomp->scale_y = 1.f;
38 qdecomp->scale_z = 1.f;
39 qdecomp->skew_xy = 0.f;
40 qdecomp->skew_xz = 0.f;
41 qdecomp->skew_yz = 0.f;
42 qdecomp->shift_x = 0.f;
43 qdecomp->shift_y = 0.f;
44 qdecomp->shift_z = 0.f;
45 qdecomp->quaternion_r = 1.f;
46 qdecomp->quaternion_i = 0.f;
47 qdecomp->quaternion_j = 0.f;
48 qdecomp->quaternion_k = 0.f;
49 qdecomp->translation_x = 0.f;
50 qdecomp->translation_y = 0.f;
51 qdecomp->translation_z = 0.f;
52}
53
54RTC_FORCEINLINE void rtcQuaternionDecompositionSetQuaternion(
55 struct RTCQuaternionDecomposition* qdecomp,
56 float r, float i, float j, float k)
57{
58 qdecomp->quaternion_r = r;
59 qdecomp->quaternion_i = i;
60 qdecomp->quaternion_j = j;
61 qdecomp->quaternion_k = k;
62}
63
64RTC_FORCEINLINE void rtcQuaternionDecompositionSetScale(
65 struct RTCQuaternionDecomposition* qdecomp,
66 float scale_x, float scale_y, float scale_z)
67{
68 qdecomp->scale_x = scale_x;
69 qdecomp->scale_y = scale_y;
70 qdecomp->scale_z = scale_z;
71}
72
73RTC_FORCEINLINE void rtcQuaternionDecompositionSetSkew(
74 struct RTCQuaternionDecomposition* qdecomp,
75 float skew_xy, float skew_xz, float skew_yz)
76{
77 qdecomp->skew_xy = skew_xy;
78 qdecomp->skew_xz = skew_xz;
79 qdecomp->skew_yz = skew_yz;
80}
81
82RTC_FORCEINLINE void rtcQuaternionDecompositionSetShift(
83 struct RTCQuaternionDecomposition* qdecomp,
84 float shift_x, float shift_y, float shift_z)
85{
86 qdecomp->shift_x = shift_x;
87 qdecomp->shift_y = shift_y;
88 qdecomp->shift_z = shift_z;
89}
90
91RTC_FORCEINLINE void rtcQuaternionDecompositionSetTranslation(
92 struct RTCQuaternionDecomposition* qdecomp,
93 float translation_x, float translation_y, float translation_z)
94{
95 qdecomp->translation_x = translation_x;
96 qdecomp->translation_y = translation_y;
97 qdecomp->translation_z = translation_z;
98}
99
100RTC_NAMESPACE_END
101
102