Wikipedia:Reference desk/Archives/Mathematics/2016 April 19

Mathematics desk
< April 18 << Mar | April | May >> April 20 >
Welcome to the Wikipedia Mathematics Reference Desk Archives
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


April 19

edit

geometry

edit

geometry question Given the grid coordinates of 2 line segments, how do I calculate the grid coordinates of the point where these segments would intersect if they were longer? Thank you.71.174.55.9 (talk) 15:57, 19 April 2016 (UTC)[reply]

Hi, see Line–line intersection#Intersection of two lines, subsection Given two points on each line. The point (Px,Py) is what you are looking for, and it is expressed in the coordinates (x1,y1), (x2,y2) that define one segment, and (x3,y3), (x4,y4) that define the other segment. Make sure the segments are not parallel if you want exactly one intersection point. Gap9551 (talk) 16:16, 19 April 2016 (UTC)[reply]
  • This is good advice, assuming the line segments are each in the same 2D plane. For 3D or higher dimensions, the lines can also be skew, meaning they are neither parallel nor intersecting.
  • If the lines are in a 2D plane, you can calculate the slope of each, and if the slopes are not the same, the lines should intersect. The formulas for the slopes, using the above coords, are: m12 = (y1-y2)/(x1-x2) and m34 = (y3-y4)/(x3-x4). One issue that will come up if comparing the two slopes on computer is that the calcs get ugly with vertical lines, which have an infinite slope. You'd need to catch a division by zero error (or circumvent it, when the change in x coords is zero), and assign a logical variable to mean that an infinite slope exists for that line, and then determine that the two lines are parallel if both lines have that variable set to true. If neither slope is infinite, then you'd compare if they were within some percentage tolerance of each other (like a millionth of a percent, good for almost vertical lines) or a fixed tolerance (good for almost horizontal lines). (Determining the orientation of each line as an angle rather than slope gets past some of these problems, but creates others.) StuRat (talk) 16:54, 19 April 2016 (UTC)[reply]
And the formula to check if two lines, each defined by two points with three-dimensional coordinates, are in the same plane (not skew) is given in Skew lines#Testing for skewness. Loraof (talk) 17:56, 19 April 2016 (UTC)[reply]