Computing location based on a list of approximate distances [closed] - algorithm

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have N points in at 3D space (I think I can grasp myself general N-dimensional case) and approximate distances to these points, how can I compute my position relative to these N points?
EDIT
Please note that the distances are approximate, so the more approximate distances I have the more convenient result I should get
Thank you!

I would write down an equation that gives you some measure of the errors associated with a possible location, and then find the location that minimizes this measure. My first attempt would be to minimize the sum of the squares of the difference between the distance measured and the distance worked out from the possible location, for each of your approximate distance, so you are minimizing something like SUM_i((sqrt((X-Ai)^2 + (Y-Bi)^2 + (Z-Ci)^2) - Di)^2) where X,Y,Z is the location co-ordinates you are trying to find, (Ai,Bi,Ci) is the co-ordinates of one of the objects from which you are measuring distances, and Di is the distance measured. It doesn't look very pretty, but you should at least be able to compute derivatives and then find some sort of minimization routine in a math library.

You have distances from given N points in a 3D space and their approximate error values. So, you have a thick sphere for each of the points that you are in. You get all of them, calculate their intersection area, and take that area's center point as your approximate location.

Related

how to fit polygon inside another polygon [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have two polygons as shown in the image below.
The left one is "rough polygon" and the right one is "final polygon"
Now, I'm looking for algorithm to fit "final polygon" inside "rough polygon" with best maximum scale.
you can rotate as well as translate "final polygon" as much as you want.
you can't perform individual x dimension or y dimension scaling.
you can only perform uniform scaling (where value of Sx and Sy are same).
Here is a possible line of attack for an exact solution by exhaustive trials; just ideas.
My guess is that a solution is achieved when there are three contacts. I mean three vertexes of either polygon touching an edge of the other or conversely. (If there are less than three contacts, you can inflate the internal polygon so that it comes into a third contact.)
Given two arbitrary triangles, it shouldn't be so difficult to find all possible three-contact positions.
So the global scheme is to take all triples of vertexes/sides from one polygon, and take all complementary triples of sides/vertexes of the other. For every combination, momentarily consider that you have triangles and find the possible three-contact positions. For for every candidate position check if the inner polygon stays confined in the outer one. In the end, keep the admissible solution with the largest scale factor.
For polygons with N and M sides, there will be O(N³M³) configurations to try, and the containment test can be as costly as O(NM). So this approach is only viable for very small polygons.
Scale the rightside polygon by 0.01. (geometrical)
Start spinnning it so fast that it draws circle. (geometrical)
Start incrementing the scale 0.01 by 0.01. (geometrical)
Stop when it touches the outer polygon. (geometrical)
Then bounce it to opposite direction until it bounces again. (physical)
Again and again.(iterations)
Until it cannot move/bounce again.(stuck optimally) (physical)
Use simulated annealing in case of false local solutions.(you need global solution)

When to avoid surface reconstruction [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
Suppose that you have a number of large point clouds and you want to observe whether they contain any valuable information or meaningful surfaces. To decrease the cost of surface reconstruction, you may ignore some point clouds with specific distribution, for instance, random distribution. How do you pick the point clouds with meaningful point orders and which ones do you avoid to reconstruct?
Two ideas:
Pick several locations and explore covariance matrix there. If the surface is well approximated by a plane in the neighbourhood, one of eigen values of the matrix will very small. The size of the neighbourhood used for analysis depends on smoothness of the surface.
Split the space into voxel grid. Count voxels containing at least one point. Then half size of voxels and count again. After several such measurements you will be able to approximate dependency of voxel number on voxel size. For surface-like distribution it should be number~(1/size)^2, for uniform distribution around volume it will be closer to (1/size)^3.

Randomly generating coordinates inside a bounded region [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a list of longitudes and latitudes which forms boundary for a geographical area. I would like to generate some random co-ordinates inside this geographical area . Could you suggest some approaches I can take in any language?
Like any problem, there are many ways to solve it, the first thing came into my mind is
Let's call this "geographic area" a polygon.
Find the bounding box of the polygon (easy, just find maxX maxY minX minY).
Generate random coordinate inside the bounding box x=rand()%(maxX-minX)+minX (and same for Y)
Test that the coordinate is inside the polygon, there are many solutions to this problem and they are implemented in any given language so you don't have to implement it by yourself.
Here is an implementation in C/C++ (it is easy to change it to any other language) : Point in Polygon Algorithm
http://en.wikipedia.org/wiki/Point_in_polygon
Edit :
As Jan Dvorak suggested, it might be problematic to use it technique on huge areas, i believe that if your polygon is close to the equator and his size is less the 100km, it will work just fine.
Also you will run into problems if you are near the 180° line because right next to it is the -180°.
First, We'll model the earth's shape as a sphere. Solving the problem for oblate spheroid is much harder.
Generating a random point on a sphere is relatively easy.
Generating a random point on a spherical triangle is harder, but explained in this linked article.
You'll need to divide your polygon into spherical triangles and weight them according to their area. Then randomly select a spherical triangle based on the weights.
For the general case, triangulating a spherical polygon is not possible, however, for most practical cases triangulation is a simple task. One such algorithm is described here (algorithm 1, page 901) with C++ source code available here (search for "Computational methods for calculating geometric parameters of tectonic plates").
You can try this:
Compute all co-ordinates within this geographical area, see save in vector<Point> points.
Generate a random int number within [0, points.size()), see k.
points[k] is what you want.

the centroid of the intersection of n disks/circles [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Given that n disks/circles share a common area, meaning that every two of them intersect one another, and we know their coordinates (x1,y1,r1), (x2,y2,r2), ..., (xn,yn,rn), where xi,yi,rn represent the x axis coordinate, the y axis coordinate, and the radius of the ith disks/circle, respectively, can you provide a method to calculate the coordinate of the centroid of the intersection of these disks/circles?!
Let's assume that all the circles overlap such that one can trace a path from any point in one of the circles to an arbitrary point in any other circle while traversing only points contained by circles. And, for generality, that the circles may be of different radii.
Per the wiki page you can decompose this shape into separate geometric regions. That is, you can find an intermediate value for the centroid by considering each circle separately (i.e. pretending they do not overlap).
Unfortunately some of the circles overlap, so you will be counting regions of the figure twice. The figure below, taken from this page, shows these regions of overlap. You therefore must find the centroid of the circle-circle intersection and subtract this from your intermediate centroid (see the wiki page's description of geometric decomposition for further details).
Since you can determine which circles overlap just do these for each overlapping pair and then each region of space will be counted only once. Your problem then reduces to finding the centroid of a circle-circle intersection.
You can find this by using geometric decomposition to break each lens of intersection into circular segments with the height of the segment given via a method here and coupling the result with appropriate coordinate transformations to rotate and translate the centroid to a location relative the center of one of the circles.

Given a point inside a rectangle, determine the side that's closest to the point [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I was curious if there was an elegant way to do this, aside from just calculating the distance from the point to each side and finding the minimum.
Some things I've thought about:
If it's a square, we can just draw the diagonals and figure out which of the 4 regions the point falls on. Each of these region corresponds to a closest side.
Perhaps we can divide up the rectangle into squares and go somewhere from there?
It seems an alternative solution would be too complicated and not worth looking for.
For rectangle you can use following regions:
I think the rectangle is not orthogonal to the coordinate system. First calculate the middle point of every side. This should be simple depending on how you have define the rectangle.
Then calculate the distance to this middle points. The smallest distance is the nearest side. You need not to calculate the full distance with pytagoras. The sum of the squared is enough.

Resources