-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetEllipseVertices.m
More file actions
27 lines (23 loc) · 880 Bytes
/
Copy pathgetEllipseVertices.m
File metadata and controls
27 lines (23 loc) · 880 Bytes
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 to calculate vertices on an ellipse defined by its major & minor
% axes and rotation (CCW from +ve y direction in radians).
%
% Inputs:
% xa - ellipse size in x-direction.
% ya - ellipse size in y-direction
% r - rotation counter-clockwise from +ve y direction in radians
% angRes - angular resolution at which to calculate vertices.
%
% Outputs:
% xout,yout - vectors of points describing ellipse. Origin, centre of ellipse is at 0,0.
%
% Copyright 2016 Elliot Sefton-Nash
function [xout, yout] = getEllipseVertices(xa, ya, r, angRes)
% Vector of angles for which to calculate ellipse x,y vertices.
% Measured CCW from -ve y axis in radians.
angVec = -pi:angRes:pi;
x = xa * cos(angVec);
y = ya * sin(angVec);
% Rotate vertices by specified angle around origin.
[xout,yout] = rotPoint2D(x, y, 0, 0, r);
end