We changed our privacy policy. Read more.

Questions tagged [distance]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
0answers
34 views

Accelerate the distance function of two point sets

I have two point sets point and impPoint. I want to calculate a distance function from each element in the ...
17
votes
4answers
488 views

Pathfinding on 2D regions

How can I find a shortest or near optimal route between two points where the route is constrained within a 2D region? First, consider the following bundle of lines: ...
0
votes
0answers
33 views

The smallest (and biggest) distance of points from the function

please give me an advice. I have points ("data", x and y coordinates). For these points, I created a residual function ...
2
votes
1answer
81 views

How to find the minimum Hamming distance?

I have a vector $v = (9, 2, 3, 4, 8)$. Vector space over $\mathbb{Z}_{11}$ is generated by a set: $e_{1} = (4, 2, 0, 0, 1)$, $e_{2} = (1, 9, 0, 1, 0)$, $e_{3} = (5, 0, 1, 0, 0)$, $e_{4} = (0, 7, 0, 0,...
4
votes
1answer
158 views

Why does MMA force a DistanceFunctions to be positive?

Consider the following piece of code: DistanceMatrix[Range[10], DistanceFunction -> Function[{x, y}, x - y]] I would have expected it to return a skew-symmetric ...
3
votes
1answer
141 views

Distance between two points in a picture

I have this picture: I'de like to obtain the distance between two of these points. The black scale bar is 3$\mu m$. To do so, I import the image to Mathematica and call it pic. Then by finding ...
1
vote
1answer
116 views

Possible bug in RegionDistance with RegionBoundary?

Code as simple as it is: ...
5
votes
1answer
70 views

Improving performace of `GeoDistance` and `NearestNeighborGraph`

I am trying to construct a NearestNeighborGraph of the 3143 US counties, using their latitude and longitude positions. ...
17
votes
4answers
919 views

Find the equidistance curve between two curves

I have three function $f(x)=x^x$, $g(x)=\ln(x)^{\ln(x)}$, $h(x)=\ln(x)^2$ and I want to find (numerically) $C$ the center of the circle tangent to the three curves. I think that one way is to find ...
6
votes
1answer
63 views

Force two distance matrices to use and show a common legend

I have two distance matrices. Both are comparing two entities in the same way. I create each matrix using ...
0
votes
0answers
26 views

FindClusters Hamming Distance giving error

I am trying to run FindClusters[hex, DistanceFunction -> HammingDistance[IntegerDigits[#, 2, 8], IntegerDigits[0, 2, 8]] &] over a list of data but I keep ...
6
votes
1answer
131 views

How to TextRecognize sparse grid of tabular data?

I cannot give the actual image (contains private information) but the results of ...
0
votes
1answer
45 views

How can I plot various points on a world map and compare distances?

How can I plot various points on a world map and compare distances? For example, the distance between Jerusalem and Westford, MA compared to the distance between Westford, MA and Recife, Brasil? Then ...
0
votes
1answer
62 views

Maximize a simple expression based on EuclideanDistance takes too long

Do you know if there is a mistake in this command syntax? It is very simple and still it takes too long. I cannot obtain any result at all: ...
2
votes
2answers
145 views

Get 3D surface grown by constant distance

There is a nice example of how to generate an isometric visualisation of surfaces which are at a constant distance from a given region. All these examples are just working on one single region. If one ...
0
votes
0answers
73 views

Total Variation Distance(between Gaussians)

I am interested in a tool that calculates the total variation distance between two multivariate Normal distributions. Any help will be much appreciated as I am a complete beginner.(So far, I have ...
1
vote
2answers
109 views

How to find the shortest distance between two regions?

I need to find the shortest distance between the two regions and the two points of the shortest distance, but the following code cannot achieve this requirement: ...
2
votes
1answer
102 views

For an enclosed surface region, how to find the furthest point on that surface to another point that is not on that surface?

I have an enclosed 3D surface (a distorted sphere surface region, which is got by finding an enclosed contour of a 3D volumetric data, and apply RegionBoundary[BoundaryDiscretizeGraphics[ ]] to get ...
7
votes
4answers
671 views

Find smallest distance from a point to a Bézier curve

I wish to find the smallest distance from a point to a curved defined via a Bézier function. I want to do this automatically. For particular cases it is not to difficult. Here is a minimum working ...
1
vote
2answers
69 views

How to change color of DistanceTransform image?

I want to overlay a set of points onto a distance transform of them. But, I don't really like the black default color of the distance transform. Is there a way to change this? Given the points ...
2
votes
0answers
51 views

Display minimum distance and minimum-distance path between two points on a polyhedron

Given a genus-zero polyhedron (e.g., PolyhedronData["Dodecahedron"]) and a point $P$ anywhere on its surface, color all points on the polyhedron by the length of ...
5
votes
2answers
464 views

Distance between a point and a curve

I have the general equation of an elipse and a point P0: elipse=0.31368-0.113863x-0.00127066x^2+0.00329003y+0.000817666xy+0.0000929297y^2 P0={-6.4,172.0} I would ...
4
votes
1answer
123 views

Distance between two cities

I need help calculating the distance between 2 cities in Wolfram MAthematica. I would need to create two drop-down lists of European capitals. After selecting any two cities from the lists, I would ...
5
votes
2answers
92 views

Breaking a Kinked line into $(n-1)$ segments of equal Euclidean distance?

I'm wondering if anyone has a nice solution for breaking a kinked line into $(n-1)$ segments of equal euclidean distance? Here is a MWE of my attempt. I think it does the job, and I'm sure the code ...
0
votes
1answer
287 views

Calculating the distance between two points and get direction [closed]

I am programming a molecular dynamics program with periodic boundary conditions. Here, I have a problem: I have a list of coordinates like ...
10
votes
2answers
651 views

Distance measures on a map of a game

I have an image which my DM made of map for a DND game and I want to do two things. Click on two points on my map, then based on the key for scaling have Mathematica tell me how far apart those ...
3
votes
2answers
391 views

Find the smallest and largest distance between two points distributed in 3D space

Suppose I have some 3D points, e.g. {{0, 0, 1}, {0, 0, 1.3}, {0, 1, 0}, {1.2, 0, 0}}. Now I want to find the smallest and largest distance between two points. A ...
3
votes
1answer
468 views

Filtering a point cloud: How to reject some points in a 3D cloud of particles?

I'm having an issue with a 3D distribution of points. The distribution is really nice looking in Mathematica, but it is used in an OpenGL astronomy program (Celestia) to generate a nebula, with ...
2
votes
1answer
81 views

Perpendicular chord lengths from the boundary points of an arbitary 2D shape

Let's generate an arbitrary convex domain with smooth boundaries: Graphics[BSplineCurve[{{1, 4}, {5, 3}, {9, 4}, {5, 5}, {8, 7}}, SplineClosed -> True]] I'...
7
votes
2answers
1k views

Find distance along a path (GPS coordinates)

I have an imported version of a GPX file plotting the route of a trail. I also have a list of coordinates for waypoints along the route. I am trying to calculate how far along the route each ...
10
votes
2answers
215 views

How to return the coordinates of the respective 3 vertexes of a DelaunayMesh's face?

I have a set of points pts1 and a point redPts as below:- ...
14
votes
3answers
420 views

Is there a built-in function I can use to measure the similarity of two trees?

This is a higher level question, and I don't expect a full answer, but maybe a nudge in the right direction would help, or maybe there is a built in Mathematica function that does something very ...
3
votes
1answer
74 views

How to compute distance between movable items in the screen?

I want to design a box in which I can move a set of items. Specifically, there should be N items (e.g. little balls with numbers inside). Items can be arranged with the mouse inside a box, and, in ...
5
votes
1answer
105 views

How do I plot a distance map in $R^2$ to a curve given in form $y=f(x)$?

As in the title, I'd like to display image using DensityPlot representing distance to a given curve, e.g., $y=x^2$. I find it difficult to derive distance ...
3
votes
0answers
125 views

Finding the shortest distance of two points and an area

So I have a region defined by something like MeshRegion[{{0, 0}, {1, 1}, {2, 1/2}, {2, -1/2}}, {Line[{1, 2}], Line[{2, 3}], Line[{3, 4}], Line[{4, 1}]}], and two ...
3
votes
1answer
161 views

How to get the coordinates of the closest point along a line?

I have a plot as below (the plot is just for illustration purpose. in my real problem, I just have pts1):- ...
2
votes
0answers
242 views

How to speed up DistanceMatrix? [duplicate]

I need to compute a fast DistanceMatrix (euclidean distance) of a large vector. Let say x = Table[Sin[t],{t,1,10000}] But pre defined function Distancematrix[x] ...
3
votes
2answers
152 views

Negative Correlation Distance

Bug introduced in 8.0 or earlier and fixed in 11.2.0 CorrelationDistance[{-53.0, 4.3}, {-23.0, 5.4}] is a negative number. It is close to zero, to be sure, but ...
3
votes
2answers
468 views

How to calculate the distance that from the pixel to image edges

I have such image: It is a binary image, I mean the pixel value is 0 or 1, but now, I hope to replace every pixel value with ...
1
vote
3answers
418 views

Find the value of parameter for the closest point on a curve

I can find the nearest point to {x0,y0} on a curve fast and easy by replacing the curve {x[t],y[t]} with line segments: ...
12
votes
5answers
5k views

How do I find the Euclidean distance between one point and all the points in a list?

I want to find the Euclidean distance between one point (x1) and a list of points (y1), which contains a lot of coordinates x1 = killer[[2]] {6.05102, 5.87667} ...
2
votes
1answer
219 views

How to measure distance exactly from a graph?

Is there any way to measure a distance from a graph in centimeter or inch exactly in Mathematica? I tried to use toolbar Ruler but I can only use it to measure width horizontally and can't switch it ...
3
votes
0answers
115 views

Getting Distances from Nearest Function [closed]

I am fairly new to mathematica. I am trying to find a way to mock python's KDTree.query function in mathematica. Basically I have 9 vectors (each length two). I want to know the three closest vectors ...
0
votes
1answer
183 views

use of GeoDistance on WGS84 spheroid

The reference WGS84 describes the Earth as oblate spheroid with semi-minor axis (radius to poles) of 6356.752 km and semi-major axis (radius to equator) of 6378.137 km. I am considering the distance ...
17
votes
2answers
5k views

What is the closest star to Earth other than the sun?

How to find the Sun's nearest neighbor star using Mathematica? I tried but it didn't work
2
votes
1answer
1k views

Mahalanobis distance between two vectors

I want to calculate the Mahalanobis distance between two vectors that represent two points. For example: ...
4
votes
3answers
822 views

Find nearest distance of an interior point from perimeter

By definition, the interior point is a point inside an arbitrary region like this: In picture above, $y$ is an interior point of region. My question is how to find the distance of an interior point ...
2
votes
1answer
148 views

How can I subtract the components of these 2 solutions if the components are interpolating functions?

I have solved for solutions of the Lorentz system but for some reason Mathematica spit out InterpolatingFunction[] as components. Input 1: ...
1
vote
1answer
74 views

A measure of disconnectedness for points in the plane

I am inexperienced with Mathematica, so I apologize if I advertise my ignorance. I am trying to write a code that will assign a measure of 'disconnectedness' to a finite set $S$ of points in the ...
1
vote
2answers
128 views

Region and Infinite Line Intersection does not yield correct results with Maximize

I have a list of points pixelvaluepos that I can use to convert to a BoundaryMeshRegion. I also happen to know the centroid <...