I have the coordinates of curves in 3D space (point curve). The pairs of these curves lie in each other or have pretty much the same coordinates for a while until they branch off. I want to find the point where the two curves branch off of each other or the best estimate of that point.
I tried to find the closest distance along the points of the two curves and then look when this distance is higher than a certain small threshold which I estimated experimentally. This works, however, only roughly to find the splitting point and differs from pair to pair of my curves.
I guess a good solution would be to interpolate both point curves with (cubic) splines with scipy or splipy and then calculate the (last) intersection point of these two curves. I don't know how to do that though.
Example picture of two point curves
Splitting Point I am searching for
Thanks for the help!
Related
I have a set of 3d points in a txt file in the form of (x,y,z) as shown in figure 1. I want to specify the boundaries of these points as in figure 2 such that if any new points were added outside the boundaries they are deleted as the blue points, and if they are inside the boundaries as the green ones they are kept. How can I achieve that in python? I tried convex hull but it only gets the boundary points !
The real data can be found here, I used figures for simplification. https://drive.google.com/file/d/1ei9NaJHN922pYItK2CRIXyLfwqm_xgrt/view?usp=sharing
Figure 1
Figure 2
For 2D points, you can apply the test as described in Wikipedia:
One simple way of finding whether the point is inside or outside a simple polygon is to test how many times a ray, starting from the point and going in any fixed direction, intersects the edges of the polygon. If the point is on the outside of the polygon the ray will intersect its edge an even number of times. If the point is on the inside of the polygon then it will intersect the edge an odd number of times. The status of a point on the edge of the polygon depends on the details of the ray intersection algorithm.
The n-dimensional case involves a convex hull test and requires linear programming techniques as described here.
In a nutshell:
I need an algorithm that can generate points on the surface of a sphere, and the euclidean distance between each point and its neighbors must be the same.
Here is a quick explanation about what I mean about that:
If the sphere was represented as a "geodesic polyhedron" ("geodesic sphere"), each side of all the triangles would have the same length. Note that it doesn't have to be a Geodesic grid or a geodesic polyhedron, it could be something else. I'm open to all suggestions.
The difficulty is that we must be able to specify the distance between the neighbouring points.
If it was a graph I would say that the edges should be the same length, and that the distance between the adjacent nodes / vertices should the same.
What I'm looking for:
an existing libray / function or algorithm that already solves this problem (but I doubt that it would be the case because I did a lot of research)
an implementation
Constraints of the algorithm:
Output:
an array of 3D (x,y,z) coordinates.
Input parameters:
3D (x,y,z) coordinates of the sphere center
radius of the sphere
distance between neighbouring points (adjacent nodes)
What I've done:
I did a lot of research about the subject
I've read a lot of papers an articles
I implemented some algorithms I found
I found a lot of good papers and resources about related problems, but nothing for this specific case. So after days of research, I ask people that have specialised knowledge of this area some help.
The closest solution I've found is the Deserno algorithm (see link below), but the problem is that its input parameters are the radius and a number of points to generate (we can't sepcify the coordinates of the sphere center an the distance between neighbouring points).
If it helps, here are some related questions and useful resources:
Evenly distributing n points on a sphere
Plotting points on the surface of a sphere in Python's matplotlib
https://en.wikipedia.org/wiki/Geodesic_grid
https://en.wikipedia.org/wiki/Geodesic_polyhedron
https://en.wikipedia.org/wiki/Spherical_polyhedron
Deserno algorithm: https://www.cmu.edu/biolphys/deserno/pdf/sphere_equi.pdf
Some representations to give an idea:
Evenly distributed points:
Geodesic grid / geodesic polyhedron:
Geodesic polyhedron zoom:
Here, each point is at 10 centimeters of distance from its neighbors.
I am working with Python for this problem.
Say I have some point p and a 1-dimensional arbitrary curve in an n-dimensional (compact) space. How can I find the closest point in the curve to my designated point p? I found an answer in Find minimum distance from point to complicated curve, but Shapely only works on planes and the expressions for the curves I am working with reside in spaces whose number of dimension ranges from 2 to 16 due to the number of parameters defining the curves.
The expressions of these curves are always known explicitly.
I also tried using scipy.optimize with SLSQP to minimize the distance function, but it is not always working. For example if the curve is np.sin(15*x), and the points are only in the unit square centered at (0.5, 0.5) there are parts of the curve that are inside the square in only one of the two dimensions and the minimization fails for some points.
If you know analytical form of curve, you always know the distance from point x(t), y(t) to your external point. And you can write distance in analytical form.
Thus, you need to find derivative from distance expression and find roots.
Suppose we have a joint distribution p(x_1,x_2), and we know x_1,x_2,p. Both are discrete, (x_1,x_2) is scatter, its contour could be drawn, marginal as well. I would like to show the area of 95% quantile (a scale of 95% data will be contained) of the joint distribution, how can I do that?
As the other points out, there are infinitely many solutions to this problem. A practical one is to find the approximate center of the point cloud and extend a circle from there until it contains approximately 95% of the data. Then, find the convex hull of the selected points and compute its area.
Of course, this will only work if the data is sort of concentrated in a single area. This won't work if there are several clusters.
If you are interested in finding a pair x_1, x_2 of real numbers such that
P(X_1<=x_1, X_2<=x_2) = 0.95 and your distribution is continuous then there will be infinitely many of these pairs. You might be better of just fixing one of them and then finding the other
Okay, so I've been pulling some hairs out over this for the last couple of days and haven't made much progress.
I want to generate a 2-D array (grid) of gaussian-like distribution on an elliptical domain. Why do I say gaussian-like?, well I want an asymmetric gaussian, aka skewed gaussian where the peak of the gaussian-like surface is at some point x0,y0 within the ellipse and the values on the perimeter of the ellipse are zero (or approaching zero...).
The attached picture might describe what I mean a little better.