line-segment

Distance from a point to a line segment in 3d (Python)

拈花ヽ惹草 提交于 2021-02-08 03:31:31
问题 I am looking for Python function that would compute distance from a point in 3D (x_0,y_0,z_0) to a line segment defined by its endpoints (x_1,y_1,z_1) and (x_2,y_2,z_2). I have only found solution for 2D for this problem. There are solutions to finding a distance from a point to a line in 3d, but not to a line segment, like here: (picture taken from Calculate distance point to line segment with special cases) 回答1: This answer is adapted from here: Calculate the euclidian distance between an

Paraview create line segments from CSV with “width” data

假如想象 提交于 2021-01-07 03:55:46
问题 I want to create line segments in Paraview. The format of my input data for each line segment is as: x0,y0,z0,x1,y1,z1,width I have tried using "Line" command like: for i in range(600): l = Line(Point1=(uniform(0,100),uniform(0,100),0),Point2=(uniform(0,100),uniform(0,100),0)) But, I can't find a way to specify the width to each line segment. Your help will be much appreciated. Best Regards, Hamid Rajabi. 回答1: The Line object does not know about the width . It is only a list of connected

Paraview create line segments from CSV with “width” data

感情迁移 提交于 2021-01-07 03:54:34
问题 I want to create line segments in Paraview. The format of my input data for each line segment is as: x0,y0,z0,x1,y1,z1,width I have tried using "Line" command like: for i in range(600): l = Line(Point1=(uniform(0,100),uniform(0,100),0),Point2=(uniform(0,100),uniform(0,100),0)) But, I can't find a way to specify the width to each line segment. Your help will be much appreciated. Best Regards, Hamid Rajabi. 回答1: The Line object does not know about the width . It is only a list of connected

intersection between a line and square

让人想犯罪 __ 提交于 2020-01-16 14:52:42
问题 I have a square in 2d space (width = height). The square is currently defined by two points: BottomLeft(X1,Y1) and TopRight(X2,Y2). The square is axis-aligned, so finding the other two corners is as easy as (X1, Y2) and (X2, Y1). I also have two points - one is always inside the square, and the other is definitely outside. They aren't necessarily at the centre of the square - they can be wherever. I know their coordinates too. What I need is to find the intersection point between the line

intersection between a line and square

走远了吗. 提交于 2020-01-16 14:52:41
问题 I have a square in 2d space (width = height). The square is currently defined by two points: BottomLeft(X1,Y1) and TopRight(X2,Y2). The square is axis-aligned, so finding the other two corners is as easy as (X1, Y2) and (X2, Y1). I also have two points - one is always inside the square, and the other is definitely outside. They aren't necessarily at the centre of the square - they can be wherever. I know their coordinates too. What I need is to find the intersection point between the line

Bentley-Ottmann Algorithm Implementation

旧街凉风 提交于 2020-01-13 09:45:09
问题 Is there any existing Bentley-Ottmann Algorithm Implementation/library in C# or Java? 回答1: Here is a Java implementation of the Bentley-Ottman algorithm 回答2: Here is at least a C++ implementation (including description): http://softsurfer.com/Archive/algorithm_0108/algorithm_0108.htm 来源: https://stackoverflow.com/questions/8113263/bentley-ottmann-algorithm-implementation

Detect if two line segments intersect using Cramer

牧云@^-^@ 提交于 2019-12-13 15:41:21
问题 I have used the code that has been posted here. Here is the code again: from __future__ import division def line(p1, p2): A = (p1[1] - p2[1]) B = (p2[0] - p1[0]) C = (p1[0]*p2[1] - p2[0]*p1[1]) return A, B, -C def intersection(L1, L2): D = L1[0] * L2[1] - L1[1] * L2[0] Dx = L1[2] * L2[1] - L1[1] * L2[2] Dy = L1[0] * L2[2] - L1[2] * L2[0] if D != 0: x = Dx / D y = Dy / D return x,y else: return False # Usage L1 = line([0,1], [2,3]) L2 = line([2,3], [0,4]) R = intersection(L1, L2) if R: print

Connect an even number of nodes without intersection

梦想与她 提交于 2019-12-07 03:46:18
问题 I have two sets of n nodes. Now I want to connect each node from one set with another node from the other set. The resulting graph should have no intersections. I know of several sweep line algorithms (Bentley-Ottmann-Algorithm to check where intersections occur, but I couldn't find an algorithm to solve those intersections, except for a brute-force approach. Each node from one set can be connected to any other node within the other set. Any pointers to (an efficient) algorithm that solves

Connect an even number of nodes without intersection

与世无争的帅哥 提交于 2019-12-05 08:04:45
I have two sets of n nodes. Now I want to connect each node from one set with another node from the other set. The resulting graph should have no intersections. I know of several sweep line algorithms ( Bentley-Ottmann-Algorithm to check where intersections occur, but I couldn't find an algorithm to solve those intersections, except for a brute-force approach. Each node from one set can be connected to any other node within the other set. Any pointers to (an efficient) algorithm that solves this problem? No implementation needed. EDIT1 : Here is one solution to the problem for n=7 : The black

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

别说谁变了你拦得住时间么 提交于 2019-11-29 18:02:19
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 place in the array that is easy to find, because I just have to cast x and y to int to get rid of the