Rank: 228483 based on 0 downloads (last 30 days) and 0 file submitted
photo

John Mahoney

E-mail
Company/University
UC Merced

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Comments and Ratings by John View all
Updated File Comments Rating
28 Apr 2014 Perceptually improved colormaps 5 perceptual colormaps with rainbow-like colors and 1 with heat colors Author: Matteo Niccoli

Hi Matteo,
It looks like pmkmp fails if the number of colors requested is 1.
cmap = pmkmp(1);
Otherwise looks nice!
John

22 Jan 2013 Polygon_Intersection This function computes n-times intersection region of shapes collection Author: Guillaume JACQUENOT

Hi all,

I am interested in coloring the regions formed by a single self-intersecting polygon.

I was hoping that this would do it
%%
clear S
S(1).P.x = [0,5,5,2,2,4,4,1,1,3,3,0];
S(1).P.y = [0,0,5,5,2,2,1,1,3,3,4,4];
S(1).P.hole = 0;
Display_result = 1;
Accuracy = 1e-6;
Polygons_intersection(S,Display_result,Accuracy);
%%

However, using this function the region that is double-covered is not colored. Can the author (or anyone else) recommend an algorithm to accomplish a single coloring of all regions of N-covering?

Cheers, John

17 Jan 2013 Fast and Robust Curve Intersections Computes intersection points of two curves. Author: Douglas Schwarz

Douglas,

Thanks for the nice function.
Could you please clarify the behavior depending on the ROBUST flag?

From the function doc:

% ROBUST (optional) set to 1 or true means to use a slight variation of the
% algorithm that might return duplicates of some intersection points, and
% then remove those duplicates. The default is true, but since the
% algorithm is slightly slower you can set it to false if you know that
% your curves don't intersect at any segment boundaries. Also, the robust
% version properly handles parallel and overlapping segments.

First, based on the first sentence, it would seem that the removal of duplicates is handled by intersections.m. This is not the case.

Second, it would seem that something should fail if the curves *do* intersect at segment boundaries (points specifying the line) and the ROBUST = 0/false is used.
At least for the example below, this is not the case.

Thanks for your help!

% Test intersections function
% Depending on whether ROBUST is true or false, and depending on how points
% defining each line do or don't lay (exactly = machine prec?) on the other
% line, the algorithm returns a different number of intersections.

clear all

% % two lines where no point is exactly on other line
% x1 = [0.1, 0.4, 0.5, 0.8];
% y1 = [0.2, 0.5, 0.7, 0.9];
% x2 = [0.1, 0.4, 0.8];
% y2 = [0.9, 0.3, 0.1];

% % first line has point on the other, but not vice versa
% x1 = [0.1, 0.25, 0.5, 0.8];
% y1 = [0.2, 0.6, 0.7, 0.9];
% x2 = [0.1, 0.4, 0.8];
% y2 = [0.9, 0.3, 0.1];

% % two lines that share a common point
% x1 = [0.1, 0.4, 0.5, 0.8];
% y1 = [0.2, 0.3, 0.7, 0.9];
% x2 = [0.1, 0.4, 0.8];
% y2 = [0.9, 0.3, 0.1];

robust = 0;
[xinter, yinter, iinter, jinter] = intersections(x1, y1, x2, y2, robust);

figure
hold on
scatter(xinter, yinter, 200, 'r','filled')
plot(x1, y1, '.b-','markersize',30)
plot(x2, y2, '.g-','markersize',20)
text(0.5, 0.5, ['found ', num2str(numel(xinter)), ' intersection/s'], 'fontsize',14)

28 Dec 2012 polyfitn Polynomial modeling in 1 or n dimensions Author: John D'Errico

John,

Great code as usual!

It seems to fail when given only one data point.

n = 1;
x = rand(n,2);
y = exp(sum(x,2)) + randn(n,1)/100;
p = polyfitn(x,y,3);

While failing might be desirable in some cases, it should really throw an error instead. And your code does supply an n-param output for n-1 inputs, so it would not be inconsistent to handle this case.

I think it is in the logic after line 120 - checking the size of the inputs and transposing accordingly.

Thanks!

Contact us