File: PolarToSensor.m

package info (click to toggle)
psychtoolbox-3 3.0.18.12.dfsg1-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 83,576 kB
  • sloc: ansic: 173,181; cpp: 20,885; objc: 5,148; sh: 2,752; python: 1,366; php: 384; makefile: 193; java: 113
file content (27 lines) | stat: -rwxr-xr-x 824 bytes parent folder | download | duplicates (7)
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
function [sensor] = PolarToSensor(pol)
% [sensor] = PolarToSensor(pol)
%
% Converts from polar sensor coordinates to
% rectangular sensor coordinates.
%
% Polar coordinates are defined as radius, azimuth, and elevation.
%
% Inverts SensorToPolar.
%
% See also SensorToPolar, SensorToCyl, CylToSensor.
%
% 9/26/93    dhb   Added calData argument.
% 2/6/94     jms   Changed 'polar' to 'pol'
% 2/20/94    jms   Added single argument case to avoid cData.
% 4/5/02     dhb, ly  New calling interface.
% 11/6/06    dhb   Only allow one input arguemnt.

[n,m] = size(pol);
if (n ~= 3)
  error('Cannot handle polar coordinates with dimension other than 3');
end

sensor = zeros(n,m);
sensor(1,:) = pol(1,:).*cos(pol(3,:)).*cos(pol(2,:));
sensor(2,:) = pol(1,:).*cos(pol(3,:)).*sin(pol(2,:));
sensor(3,:) = pol(1,:).*sin(pol(3,:));