line-segment

Using PathIterator to return all line segments that constrain an Area?

谁说胖子不能爱 提交于 2019-11-29 08:32:56
In Java, how would one employ PathIterator to iterate through the line segments that constrain an Area ? The Area is bound only by lines (but curve support wouldn't hurt). The method should return a collection of all the line segments. Peter This works (in all situations, I believe), but it might require more thorough testing: Area area; // The value is set elsewhere in the code ArrayList<double[]> areaPoints = new ArrayList<double[]>(); ArrayList<Line2D.Double> areaSegments = new ArrayList<Line2D.Double>(); double[] coords = new double[6]; for (PathIterator pi = area.getPathIterator(null);

Find cells in array that are crossed by a given line segment

醉酒当歌 提交于 2019-11-28 12:41:14
问题 I have got a 2D array of cells with size 10x10, and many points that are pairs of floating point values, like: (1.6, 1.54), (4.53, 3.23). The pairs (x,y) are such that x<10 and y<10 Each cell takes points whose coordinates have the same integer part as the cell coordinates. So arr[3][7] will take points with x={3...3.99(9)} and y={7... 7.99(9)}, for example (3.5, 7.1) or (3.2, 7.6). Similarly (1.6, 1.54) is in arr[1][1] , (4.53, 3.23) is in arr[4][3], etc. Each point has got a designated

Using PathIterator to return all line segments that constrain an Area?

喜夏-厌秋 提交于 2019-11-28 02:03:51
问题 In Java, how would one employ PathIterator to iterate through the line segments that constrain an Area? The Area is bound only by lines (but curve support wouldn't hurt). The method should return a collection of all the line segments. 回答1: This works (in all situations, I believe), but it might require more thorough testing: Area area; // The value is set elsewhere in the code ArrayList<double[]> areaPoints = new ArrayList<double[]>(); ArrayList<Line2D.Double> areaSegments = new ArrayList

Shortest distance between a point and a line segment

末鹿安然 提交于 2019-11-25 21:49:08
问题 I need a basic function to find the shortest distance between a point and a line segment. Feel free to write the solution in any language you want; I can translate it into what I\'m using (Javascript). EDIT: My line segment is defined by two endpoints. So my line segment AB is defined by the two points A (x1,y1) and B (x2,y2) . I\'m trying to find the distance between this line segment and a point C (x3,y3) . My geometry skills are rusty, so the examples I\'ve seen are confusing, I\'m sorry