MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / calc_transform_inverse

Function calc_transform_inverse

src/backend/cpu/kernel/transform.hpp:22–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20
21template<typename T>
22void calc_transform_inverse(T *txo, const T *txi, const bool perspective) {
23 if (perspective) {
24 txo[0] = txi[4] * txi[8] - txi[5] * txi[7];
25 txo[1] = -(txi[1] * txi[8] - txi[2] * txi[7]);
26 txo[2] = txi[1] * txi[5] - txi[2] * txi[4];
27
28 txo[3] = -(txi[3] * txi[8] - txi[5] * txi[6]);
29 txo[4] = txi[0] * txi[8] - txi[2] * txi[6];
30 txo[5] = -(txi[0] * txi[5] - txi[2] * txi[3]);
31
32 txo[6] = txi[3] * txi[7] - txi[4] * txi[6];
33 txo[7] = -(txi[0] * txi[7] - txi[1] * txi[6]);
34 txo[8] = txi[0] * txi[4] - txi[1] * txi[3];
35
36 T det = txi[0] * txo[0] + txi[1] * txo[3] + txi[2] * txo[6];
37
38 txo[0] /= det;
39 txo[1] /= det;
40 txo[2] /= det;
41 txo[3] /= det;
42 txo[4] /= det;
43 txo[5] /= det;
44 txo[6] /= det;
45 txo[7] /= det;
46 txo[8] /= det;
47 } else {
48 T det = txi[0] * txi[4] - txi[1] * txi[3];
49
50 txo[0] = txi[4] / det;
51 txo[1] = txi[3] / det;
52 txo[3] = txi[1] / det;
53 txo[4] = txi[0] / det;
54
55 txo[2] = txi[2] * -txo[0] + txi[5] * -txo[1];
56 txo[5] = txi[2] * -txo[3] + txi[5] * -txo[4];
57 }
58}
59
60template<typename T>
61void calc_transform_inverse(T *tmat, const T *tmat_ptr, const bool inverse,

Callers 1

transformFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected