points

Fastest way to find the closest point to a given point in 3D, in Python

痞子三分冷 提交于 2019-12-03 11:53:38
So lets say I have 10,000 points in A and 10,000 points in B and want to find out the closest point in A for every B point. Currently, I simply loop through every point in B and A to find which one is closest in distance. ie. B = [(.5, 1, 1), (1, .1, 1), (1, 1, .2)] A = [(1, 1, .3), (1, 0, 1), (.4, 1, 1)] C = {} for bp in B: closestDist = -1 for ap in A: dist = sum(((bp[0]-ap[0])**2, (bp[1]-ap[1])**2, (bp[2]-ap[2])**2)) if(closestDist > dist or closestDist == -1): C[bp] = ap closestDist = dist print C However, I am sure there is a faster way to do this... any ideas? I typically use a kd-tree

Find bezier control-points for curve passing through N points

前提是你 提交于 2019-12-03 11:45:02
问题 Considering the following nice solution for finding cubic Bézier control points for a curve passing through 4 points: How to find control points for a BezierSegment given Start, End, and 2 Intersection Pts in C# - AKA Cubic Bezier 4-point Interpolation I wonder, if there is a straightforward extension to this for making the Bézier curve pass through N points, for N > 2 and maybe N ≤ 20? 回答1: This is a really old question, but I'm leaving this here for people who have the same question in the

Re-distort points with camera intrinsics/extrinsics

≯℡__Kan透↙ 提交于 2019-12-03 09:30:23
问题 Given a set of 2D points, how can I apply the opposite of undistortPoints ? I have the camera intrinsics and distCoeffs and would like to (for example) create a square, and distort it as if the camera had viewed it through the lens. I have found a 'distort' patch here : http://code.opencv.org/issues/1387 but it would seem this is only good for images, I want to work on sparse points. 回答1: This question is rather old but since I ended up here from a google search without seeing a neat answer I

How to avoid overplotting (for points) using base-graph?

ぃ、小莉子 提交于 2019-12-03 06:51:13
问题 I am in my way of finishing the graphs for a paper and decided (after a discussion on stats.stackoverflow), in order to transmit as much information as possible, to create the following graph that present both in the foreground the means and in the background the raw data: However, one problem remains and that is overplotting. For example, the marked point looks like it reflects one data point, but in fact 5 data points exists with the same value at that place. Therefore, I would like to know

Find bezier control-points for curve passing through N points

一个人想着一个人 提交于 2019-12-03 02:09:29
Considering the following nice solution for finding cubic Bézier control points for a curve passing through 4 points: How to find control points for a BezierSegment given Start, End, and 2 Intersection Pts in C# - AKA Cubic Bezier 4-point Interpolation I wonder, if there is a straightforward extension to this for making the Bézier curve pass through N points, for N > 2 and maybe N ≤ 20? This is a really old question, but I'm leaving this here for people who have the same question in the future. @divanov has mentioned that there's no Bezier curve passing through N arbitrary points for N >4. I

Re-distort points with camera intrinsics/extrinsics

情到浓时终转凉″ 提交于 2019-12-02 23:53:16
Given a set of 2D points, how can I apply the opposite of undistortPoints ? I have the camera intrinsics and distCoeffs and would like to (for example) create a square, and distort it as if the camera had viewed it through the lens. I have found a 'distort' patch here : http://code.opencv.org/issues/1387 but it would seem this is only good for images, I want to work on sparse points. morotspaj This question is rather old but since I ended up here from a google search without seeing a neat answer I decided to answer it anyway. There is a function called projectPoints that does exactly this. The

How to avoid overplotting (for points) using base-graph?

谁说我不能喝 提交于 2019-12-02 19:27:44
I am in my way of finishing the graphs for a paper and decided ( after a discussion on stats.stackoverflow ), in order to transmit as much information as possible, to create the following graph that present both in the foreground the means and in the background the raw data: However, one problem remains and that is overplotting. For example, the marked point looks like it reflects one data point, but in fact 5 data points exists with the same value at that place. Therefore, I would like to know if there is a way to deal with overplotting in base graph using points as the function. It would be

How to remove points that are far from a segment?

耗尽温柔 提交于 2019-12-02 09:08:08
I read how to keep points that are between two points (ie. : that are part of a segment, with some imprecision) here : How can I tell if a point is nearby a certain line? Thus, I implemented this little algorithm in Java, and my code is (note that the variables' name should be clear for you ! :) ) : List<Cupple> returned = new ArrayList<>(points_to_test); for(Cupple c : points_to_test) { /*if(c == segment_first_point || c == segment_last_point) { continue; }*/ if(Math.abs(Math.abs( (segment_last_point.getNumber(0) - segment_first_point.getNumber(0)) * (segment_first_point.getNumber(1) - c

Matlab: Find area enclosed by points (x,y)

烈酒焚心 提交于 2019-12-02 01:29:01
I've got 8 points that create the outline of an eight-sided polygon in two-dimensional space. I need to find the area enclosed be these points, but how do I do that using matlab? The eight points (x,y) are contained in the 8x2 matrix B. B = [ 260 455; 1187 467; 1325 605; 1342 1533; 1207 1675 251 1690; 107 1547; 116 593]; The polygon is created by drawing straight lines from the point which is row 1 to row 2, then row 2 to row 3 and so on... You can use polyarea : ar = polyarea(B(:, 1), B(:, 2)); I would go with trapezoid : Area = trapz(B(:,1),B(:,2)); For calculating area and even volume you

How can I cluster points which are connected in MATLAB?

浪尽此生 提交于 2019-12-01 14:27:39
Imagine we have many points which some of them are connected together and we want to cluster them. Please take a look at the following figure. If we have the " connectivity matrix " of points, how we can cluster them in two group (groups of connected points)? ConnectivityMatrix= [1 2 1 3 2 4 2 3 2 1 3 1 3 2 3 4 4 3 4 2 5 8 5 7 5 6 6 5 6 7 7 6 7 5 7 8 8 7 8 5] The final result should be nodes of 1,2,3,4 in a first group(cluster) and nodes of 5,6,7,8 in a second group (cluster). Here is some code to get you started. I basically implemented Depth First Search... a very crude implementation of it