/usr/share/psychtoolbox-3/PsychOpenGL/PsychGetPositionYawMatrix.m is in psychtoolbox-3-common 3.0.14.20170103+git6-g605ff5c.dfsg1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | function M = PsychGetPositionYawMatrix(translation, yawRotation)
% M = PsychGetPositionYawMatrix(translation, yawRotation);
%
% Builds a 4x4 OpenGL compatible (right hand side post-multiply)
% matrix for a 3D translation followed by a rotation around the
% y-axis. Useful for positioning an observer in 3D space, then
% giving the observer a specific "looking direction" or heading.
%
% You can also use this function for incremental position and
% orientation updates by simply post-multiplying the result of
% this function to the result of a previous call to this function,
% e.g.:
%
% 1. Select start position and orientation:
%
% M = PsychGetPositionYawMatrix(startPosition, startHeading);
%
% 2. Update location relative to current heading direction, then
% change new heading by deltaHeading degrees for initiating a
% turn:
%
% M = M * PsychGetPositionYawMatrix(PositionIncrement, deltaHeading);
%
% Initializing an observer position with step 1, then updating it
% by repeating step 2, e.g., driven by keyboard input, mouse or
% gamepad input, or some other input device or "game logic" allows
% to move the observers body through the scene in a "natural" way.
%
%
% Parameters:
%
% 'translation' a 3 component translation vector [tx, ty, tz].
%
% 'yawRotation' a rotation angle in degrees along the y-axis, also
% known as heading direction or upright direction.
%
% History:
% 28-Sep-2015 mk Written.
% Translation matrix:
T = diag([1 1 1 1]);
T(1:3, 4) = translation;
% Rotation matrix around y axis:
alpha = yawRotation / 180 * pi;
R = [cos(alpha) 0 sin(alpha) 0 ; ...
0 1 0 0 ; ...
-sin(alpha) 0 cos(alpha) 0 ; ...
0 0 0 1];
% First translate, then rotate:
M = T * R;
end
|