Skip to content

Commit cce3d48

Browse files
author
Teseo Schneider
committed
unproject_on_line
1 parent a546322 commit cce3d48

File tree

2 files changed

+75
-109
lines changed

2 files changed

+75
-109
lines changed

src/unproject_on_line.cpp

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#include <common.h>
2+
#include <npe.h>
3+
#include <typedefs.h>
4+
5+
6+
#include <igl/unproject_on_line.h>
7+
8+
const char *ds_unproject_on_line = R"igl_Qu8mg5v7(
9+
10+
11+
Given a screen space point (u,v) and the current projection matrix (e.g.
12+
gl_proj * gl_modelview) and viewport, _unproject_ the point into the scene
13+
so that it lies on given line (origin and dir) and projects as closely as
14+
possible to the given screen space point.
15+
16+
Parameters
17+
----------
18+
UV 2-long uv-coordinates of screen space point
19+
M 4 by 4 projection matrix
20+
VP 4-long viewport: (corner_u, corner_v, width, height)
21+
origin point on line
22+
dir vector parallel to line
23+
24+
Returns
25+
-------
26+
t line parameter so that closest poin on line to viewer ray through UV
27+
lies at origin+t*dir
28+
Z 3d position of closest point on line to viewing ray through UV
29+
30+
See also
31+
--------
32+
33+
34+
Notes
35+
-----
36+
None
37+
38+
Examples
39+
--------
40+
41+
)igl_Qu8mg5v7";
42+
43+
npe_function(unproject_on_line)
44+
npe_doc(ds_unproject_on_line)
45+
46+
npe_arg(uv, dense_float, dense_double)
47+
npe_arg(m, npe_matches(uv))
48+
npe_arg(vp, npe_matches(uv))
49+
npe_arg(origin, npe_matches(uv))
50+
npe_arg(dir, npe_matches(uv))
51+
52+
53+
npe_begin_code()
54+
assert_size_equals(uv, 2, "uv");
55+
assert_rows_equals(m, 4, "m");
56+
assert_cols_equals(m, 4, "m");
57+
assert_size_equals(vp, 4, "uv");
58+
59+
assert_size_equals(origin, 3, "origin");
60+
assert_size_equals(dir, 3, "dir");
61+
62+
EigenDense<npe_Scalar_uv> uv_copy = uv;
63+
EigenDense<npe_Scalar_uv> m_copy = m;
64+
EigenDense<npe_Scalar_uv> vp_copy = vp;
65+
EigenDense<npe_Scalar_uv> origin_copy = origin;
66+
EigenDense<npe_Scalar_uv> dir_copy = dir;
67+
68+
npe_Scalar_uv t;
69+
igl::unproject_on_line(uv_copy, m_copy, vp_copy, origin_copy, dir_copy, t);
70+
npe_Matrix_uv Z = origin + dir * t;
71+
72+
return std::make_tuple(double(t), npe::move(Z));
73+
74+
npe_end_code()
75+

todo/unproject_on_line.cpp

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

0 commit comments

Comments
 (0)