|
Hi Atomek, I have written a query that creates perpendicular lines from one or more selected points to one or more selected lines. It uses some algebra to calculate the line(s). SELECT NewLine( NewPoint(x3, y3), NewPoint(x3 - k * (y2-y1), y3 + k * (x2-x1)) ) perpendicular FROM ( SELECT ((y2-y1) * (x3-x1) - (x2-x1) * (y3-y1)) / ((y2-y1)^2 + (x2-x1)^2) k, x3, y3, y2, x2, y1, x1 FROM ( SELECT MinY(StartPoint(L.ID)) y1, MinY(EndPoint(L.ID)) y2, MinX(StartPoint(L.ID)) x1, MinX(EndPoint(L.ID)) x2, MinX((P.ID)) x3, MinY((P.ID)) y3 FROM [Line] L, [Point] P WHERE L.[Selection (I)] AND P.[Selection (I)] ) ) The points are in a drawing called Point and the lines in a drawing named Line. In the attached map file I've linked this query as a drawing. It works fine unless the line is exactly vertical or horizontal. (Edit) I expected it to fail in case of horizontal and vertical lines, but after trying it seems to work fine in these cases too! It only fails if the line is of length zero. But then it is a point, not a line. Cheers, Chris Attachments: perpendicular.map
http://www.mppng.nl/manifold/pointlabeler |