This is in reference to - Determine which side of a line a point lies
This an observation - I am trying to count points meeting my criteria using two of the above mentioned techniques i.e. the determinant using two reference points and third point to compare. Also alternatively I am using the slope method. Here, i already have a reference angle, one point fixed, and other varying points which need to be checked. so basically I am checking the angle which the lines are making with the horizontal.
I am getting different results, with the determinant, the result is approximately 3% more. Basically, more points are considered.
Any idea why this might be happening. Is this error in any way related to rounding off, in case of this being related to a rounding off error, which method is reliable? I am using tand() in matlab to compute the angles and then compare, and det() function to find the value of the determinant.
The code when comparing angles is as shown below
angle = E(l);
while i+1 < len_y % Y co-ordinates
while j+1 < len_x % X co-ordinates [The manner of saving the 2D matrix and the analysis are both in sync.]
if z_1(i,j) <= z_1(i,j+1) % check for the first peak
j = j + 1;
else z_1(i,j) > z_1(i,j+1); % this is the first peak, where we set up the line
while j+1 < len_x % set up a line using the angle
z0 = z_1(i,j); % this is the first point of the line
x0 = X(j);
x1 = x0 + 10; % problem solved.
z1 = z0 - (tand(E(l)) * (x1 - x0)); % this is to setup the line to compare is a point is below or above it
j = j + 1;
trial_angle = atand((z0 - z_1(j))/(X(j) - x0));
while trial_angle > E(l) & j < len_x; % check the first point of intersection of the line
j = j + 1;
trial_angle = atand((z0 - z_1(j))/(X(j) - x0));
end % end of points which are not in contact
I am using MATLAB 2012 and Win7 64 bit
Any help will be appreciated.
Thanks
thedorkknight