Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds a warning to chunkerfunc when the curve is not closed but ifclos… #92

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion chunkie/chunkerfunc.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@

% discover number of outputs
try
[r,d,d2] = fcurve(t);
[r,d,d2] = fcurve(ta);
nout = 3;
catch
try
Expand Down Expand Up @@ -314,6 +314,9 @@
rad_curr = max(xmax-xmin,ymax-ymin);
end

%



% the curve should be resolved to precision eps now on
% each interval ab(,i)
Expand Down Expand Up @@ -551,6 +554,32 @@
chnkr.d2stor(:,:,i) = reshape(out{3},dim,k)*h*h;
end

% check ends
lrinterpmat = lege.matrin(k,[-1;1],us);
left1 = lrinterpmat(1,:)*(chnkr.rstor(:,:,1).');
rightnch = lrinterpmat(2,:)*(chnkr.rstor(:,:,nch).');
dleft1 = lrinterpmat(1,:)*(chnkr.dstor(:,:,1).');
dleft1 = dleft1(:)/norm(dleft1(:));
drightnch = lrinterpmat(2,:)*(chnkr.dstor(:,:,nch).');
drightnch = drightnch(:)/norm(drightnch(:));

msgbase = "CHUNKERFUNC: ";
if norm(left1(:)-rightnch(:))/rad_curr > eps && ifclosed
msg = msgbase + ...
"start and end points of curve parameterization are not the same" + ...
" to target precision but ifclosed flag is true." + ...
" Check curve parameterization or if not a closed curve" + ...
" set flag appropriately and consider creating a chunkgraph object";
warning(msg);
elseif norm(dleft1(:)-drightnch(:)) > eps*k && ifclosed
msg = msgbase + ...
"unit tangent vectors at start and end points of curve are not the same" + ...
" to target precision but ifclosed flag is true." + ...
" Check curve parameterization or if not a closed curve" + ...
" set flag appropriately and consider creating a chunkgraph object";
warning(msg);
end

chnkr.adjstor(:,1:nch) = adjs(:,1:nch);

% update normals
Expand Down
19 changes: 19 additions & 0 deletions devtools/test/chunkerfuncTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,25 @@
a = area(chnkr);
assert(abs(a - pi*r^2) < 1e-12,'area wrong for circle domain')

% iflcosed flag testing

lastwarn(''); %clears warning state
cparams = [];
chnkr = chunkerfunc(@(t) [cos(t(:).'); sin(t(:).'/2)],cparams);
[warnmsg,warnID] = lastwarn;
assert(~isempty(warnmsg));

lastwarn(''); %clears warning state
cparams = []; cparams.ta=0; cparams.tb=2*pi-1e-3;
chnkr = chunkerfunc(@(t) [cos(t(:).'); sin(t(:).')],cparams);
[warnmsg,warnID] = lastwarn;
assert(~isempty(warnmsg));

lastwarn(''); %clears warning state
cparams = []; cparams.ta=0; cparams.tb=2*pi-1e-3; cparams.ifclosed = false;
chnkr = chunkerfunc(@(t) [cos(t(:).'); sin(t(:).')],cparams);
[warnmsg,warnID] = lastwarn;
assert(isempty(warnmsg));

% subplot(1,3,3)
% plot(chnkr)
Expand Down
Loading