Skip to content

Commit 36d5555

Browse files
author
Teseo Schneider
committed
two_axis_valuator_fixed_up
1 parent 828db09 commit 36d5555

3 files changed

Lines changed: 98 additions & 71 deletions

File tree

src/two_axis_valuator_fixed_up.cpp

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#include <npe.h>
2+
#include <common.h>
3+
#include <typedefs.h>
4+
5+
6+
7+
8+
9+
10+
#include <igl/two_axis_valuator_fixed_up.h>
11+
12+
const char *ds_two_axis_valuator_fixed_up = R"igl_Qu8mg5v7(
13+
14+
Applies a two-axis valuator drag rotation (as seen in Maya/Studio max) to a given rotation.
15+
16+
Parameters
17+
----------
18+
w width of the trackball context
19+
h height of the trackball context
20+
speed controls how fast the trackball feels, 1 is normal
21+
down_quat rotation at mouse down, i.e. the rotation we're applying the
22+
trackball motion to (as quaternion). **Note:** Up-vector that is fixed
23+
is with respect to this rotation.
24+
down_x position of mouse down
25+
down_y position of mouse down
26+
mouse_x current x position of mouse
27+
mouse_y current y position of mouse
28+
29+
Returns
30+
-------
31+
quat the resulting rotation (as quaternion)
32+
33+
See also
34+
--------
35+
snap_to_fixed_up
36+
37+
Notes
38+
-----
39+
None
40+
41+
Examples
42+
--------
43+
44+
)igl_Qu8mg5v7";
45+
46+
npe_function(two_axis_valuator_fixed_up)
47+
npe_doc(ds_two_axis_valuator_fixed_up)
48+
49+
npe_arg(w, int)
50+
npe_arg(h, int)
51+
npe_arg(speed, double)
52+
npe_arg(down_quat, dense_float, dense_double)
53+
npe_arg(down_x, int)
54+
npe_arg(down_y, int)
55+
npe_arg(mouse_x, int)
56+
npe_arg(mouse_y, int)
57+
58+
59+
npe_begin_code()
60+
assert_size_equals(down_quat, 4, "down_quat");
61+
Eigen::Quaternion<double> down_quat_copy;
62+
if (down_quat.cols() == 1)
63+
{
64+
down_quat_copy.x() = down_quat(0, 0);
65+
down_quat_copy.y() = down_quat(1, 0);
66+
down_quat_copy.z() = down_quat(2, 0);
67+
down_quat_copy.w() = down_quat(3, 0);
68+
}
69+
else
70+
{
71+
down_quat_copy.x() = down_quat(0, 0);
72+
down_quat_copy.y() = down_quat(0, 1);
73+
down_quat_copy.z() = down_quat(0, 2);
74+
down_quat_copy.w() = down_quat(0, 3);
75+
}
76+
77+
Eigen::Quaternion<double> quat_copy;
78+
igl::two_axis_valuator_fixed_up(w, h, speed, down_quat_copy, down_x, down_y, mouse_x, mouse_y, quat_copy);
79+
EigenDenseLike<npe_Matrix_down_quat> quat(4, 1);
80+
quat(0) = quat_copy.x();
81+
quat(1) = quat_copy.y();
82+
quat(2) = quat_copy.z();
83+
quat(3) = quat_copy.w();
84+
85+
return npe::move(quat);
86+
87+
npe_end_code()
88+
89+

tests/test_basic.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,6 +1962,15 @@ def test_read_msh(self):
19621962
self.assertTrue(v.dtype == np.float64)
19631963
self.assertTrue(t.dtype == self.f1.dtype)
19641964

1965+
def test_two_axis_valuator_fixed_up(self):
1966+
down_quat = np.random.rand(4, 1)
1967+
1968+
quat = igl.two_axis_valuator_fixed_up(20, 20, 1, down_quat, 10, 10, 9, 9)
1969+
1970+
self.assertTrue(quat.flags.c_contiguous)
1971+
self.assertTrue(quat.dtype == down_quat.dtype)
1972+
self.assertTrue(quat.shape[0] == 4)
1973+
19651974

19661975
if __name__ == '__main__':
19671976
unittest.main()

todo/two_axis_valuator_fixed_up.cpp

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)