I am not sure if this a question for the mathematics stackoverflow or some other. If it is then please move it.
Basically, I have a programming challenge where given list of points (which form a line or a curve), I need to determine a point is on left or right of these list of points.
Does anyone knows a mathematical answer to this question or does this needs to be moved to another place?
P
Edit: The point that needs to be compare may not be on the line
I would have to think a little longer about how to determine which side of a general curve some point lies, but with the line it is very straightforward.
The following approach only holds if the given set of points is entirely co-linear. Pick any two distinct points $(x_1,y_1)$ and $(x_2,y_2)$ such that $x_1 \neq x_2$, then line $f(x)$ will have be $f(x) = \left( \dfrac{y_2- y_1}{x_2 - x_1}\right)(x-x_1) + y_1$ where the fraction is the slope. Once you have the line, consider the point $(x_3,y_3)$ which you are to determine if it is on the left or right of $f(x)$.
Find the value of $a = f(x_3)$. If $a > y_3$, your point is "below" $f(x)$ which I would interpret as to the right of $f(x)$ if you were riding the line $f(x)$ from the negative $x$-axis to the positive $x$-axis.
If $a = y_3$, your point is on the line.
If $a < y_3$, your point is "above" $f(x)$ and I would consider it to be to the left of $f(x)$ for the same reasons mentioned in the twice-previous paragraph.
The only exception, as hinted with finding distinct points $(x_1,y_1)$ and $(x_2,y_2)$, is when $x_1 = x_2$. If the points given to you are co-linear but they all posses the same $x$-value, this means you have a line of the form $x = c$ which has no defined slope (among other properties). But this would be the easiest case because then you just compare your $(x_3,y_3)$'s first coordinate with the value of $c$ and you can find which side of $x=c$ it lies on.
This reminds me of Project Euler's Problem 102. I would consider using an implementation of the notion of a cross product for a more general case involving some arbitrary curve. Just a guess at an approach: isolate the two nearest points to your mystery point. Take vector 1 to be the line segment connecting the 2 points, and take vector 2 to be the line connecting the first given point and your mystery point. Analyzing the sign of the cross(vector) product involving those points (assuming you adhere to some convention like the Right-Hand-Rule) will tell you which side of the curve your mystery lies on. [Disclaimer: I haven't tried this yet but it's an approach worth considering/revising/improving]