[vlc-devel] [PATCH 2/4] viewpoint: add euler to 4x4 matrix conversion
Rémi Denis-Courmont
remi at remlab.net
Thu Feb 7 12:59:34 CET 2019
Are you sure that you should do intermediate computations in double precision? That does not seem useful here.
Le 7 février 2019 13:12:16 GMT+02:00, Alexandre Janniaux <ajanni at videolabs.io> a écrit :
>Refactor code from opengl/vout_helper and d3d11, by merging the
>creation of
>three 4x4 rotation matrices for the shaders into only one created from
>the
>viewpoint.
>---
> include/vlc_viewpoint.h | 48 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 48 insertions(+)
>
>diff --git a/include/vlc_viewpoint.h b/include/vlc_viewpoint.h
>index df930b3900..0b8404513c 100644
>--- a/include/vlc_viewpoint.h
>+++ b/include/vlc_viewpoint.h
>@@ -66,4 +66,52 @@ static inline void vlc_viewpoint_reverse(
>vlc_viewpoint_t *p_vp )
> p_vp->roll *= -1;
> }
>
>+static inline void vlc_viewpoint_to_4x4( const vlc_viewpoint_t *p_vp,
>+ float *m )
>+{
>+ float s, c;
>+
>+ vlc_viewpoint_t vp = *p_vp;
>+ vp.yaw *= M_PI; vp.pitch *= M_PI; vp.roll *= M_PI;
>+ vp.yaw /= 180.f; vp.pitch /= 180.f; vp.roll /= 180.f;
>+ vp.yaw += M_PI_2;
>+
>+ s = sinf(vp.pitch);
>+ c = cosf(vp.pitch);
>+ float x_rot[4][4] = {
>+ { 1.f, 0.f, 0.f, 0.f },
>+ { 0.f, c, -s, 0.f },
>+ { 0.f, s, c, 0.f },
>+ { 0.f, 0.f, 0.f, 1.f } };
>+
>+ s = sinf(vp.yaw);
>+ c = cosf(vp.yaw);
>+ float y_rot[4][4] = {
>+ { c, 0.f, s, 0.f },
>+ { 0.f, 1.f, 0.f, 0.f },
>+ { -s, 0.f, c, 0.f },
>+ { 0.f, 0.f, 0.f, 1.f } };
>+
>+ s = sinf(vp.roll);
>+ c = cosf(vp.roll);
>+ float z_rot[4][4] = {
>+ { c, s, 0.f, 0.f },
>+ { -s, c, 0.f, 0.f },
>+ { 0.f, 0.f, 1.f, 0.f },
>+ { 0.f, 0.f, 0.f, 1.f } };
>+
>+ /**
>+ * Column-major matrix multiplication mathematically equal to
>+ * z_rot * x_rot * y_rot
>+ */
>+ memset(m, 0, 16 * sizeof(float));
>+ for (int i=0; i<4; ++i)
>+ for (int j=0; j<4; ++j)
>+ for (int k=0; k<4; ++k)
>+ for (int l=0; l<4; ++l)
>+ {
>+ m[4*i+l] += y_rot[i][j] * x_rot[j][k] * z_rot[k][l];
>+ }
>+}
>+
> #endif /* VLC_VIEWPOINT_H_ */
>--
>2.20.1
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel
--
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20190207/c903fb07/attachment.html>
More information about the vlc-devel
mailing list