You say co-ordinates, but you only mention an X axis. Are you working in a 1 dimensional co-ordinate system, or is it a 2 or 3 (or more) dimensional system?
If you are working in more than one dimension, then you will find that an arbitrary point will rarely be exactly on an arbitrary line due to floating point precision issues. Instead you will need to test how close the point is to the line. There are a number of mathematical ways to do that. Off the top of my head an easy way would be to work out the area of the triangle composed of the point and lines's endpoints and then divide that by the line's length. That will give you half the distance of the point from the line.
If you are working in only one dimension then a simple numerical comparison should suffice:
say "point is on line" if( point_x >= line_start && point_x <= line_end )
In reply to Re: fast way of working with numerical positions
by chrestomanci
in thread fast way of working with numerical positions
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |