-
Notifications
You must be signed in to change notification settings - Fork 0
/
ellipsoid_segment.m
85 lines (68 loc) · 3.12 KB
/
ellipsoid_segment.m
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
% Segment of an ellipsoid in R^3 parametrised from [0,1] x [0,1]
%
% s = ellipsoid_segment(Itheta,Iphi,ax,ay,az) represents a segment of the
% ellipsoid centred at the origin parametrised in spherical polar
% coordinates
%
% x = ax * sin(theta) * cos(phi)
% y = ay * sin(theta) * sin(phi)
% z = az * cos(theta)
%
% The segment is that part of the ellipsoid with theta between Itheta(1) and
% Itheta(2), and phi between Iphi(1) and Iphi(2). If Itheta = [0,pi] and
% Iphi = [0,2*pi] then the segment is the whole ellipsoid.
%
% F = s.evaluate(u,v) computes the coordinates of points on the segment.
% If u and v are n x 1 matrix then F is a 3 x n matrix and F(:,k) holds
% the (x,y,z) coordinates of the point on the segment corresponding to the
% point (u(k),v(k)).
%
% This is a child class of sheet. See sheet for a full list of methods.
%
% See also: sheet, translated_sheet, spherical_segment, disk.
%
% Stuart C. Hawkins - 25 August 2021
% Copyright 2019-2022 Stuart C. Hawkins
%
% This file is part of TMATROM3
%
% TMATROM3 is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% TMATROM3 is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with TMATROM3. If not, see <http://www.gnu.org/licenses/>.
classdef ellipsoid_segment < sheet
properties
end
methods
%-----------------------------------------
% constructor
%-----------------------------------------
function self = ellipsoid_segment(thetalim,philim,ax,ay,az)
% map u in [0,1] to theta in thetalim
theta = @(u) thetalim(1) + (thetalim(2)-thetalim(1)) * u;
% map v in [0,1] to phi in philim
phi = @(v) philim(1) + (philim(2)-philim(1)) * v;
% ... and the derivatives of those mappings wrt u and v
thetad = (thetalim(2)-thetalim(1));
phid = (philim(2)-philim(1));
% specify spherical polar coordinates parametrisation of the ellipsoid
% for the surface mapping....
f = @(u,v) [ax*sin(theta(u)).*cos(phi(v));ay*sin(theta(u)).*sin(phi(v));az*cos(theta(u))];
% ....and its derivative with respect to u (theta)...
dtheta = @(u,v) [ax*thetad*cos(theta(u)).*cos(phi(v));ay*thetad*cos(theta(u)).*sin(phi(v));-az*thetad*sin(theta(u))];
% ....and its derivative with respect to v (phi)...
dphi = @(u,v) [-ax*phid*sin(theta(u)).*sin(phi(v));ay*phid*sin(theta(u)).*cos(phi(v));zeros(size(theta(u)))];
% pass the mapping and its partial derivatives to the parent
% constructor
self = self@sheet(f,dtheta,dphi);
end
end
end