Finding a a path between two points on a 3d surface that proceeds t... (2024)

25 views (last 30 days)

Show older comments

Mahesh on 19 Jul 2024 at 12:38

  • Link

    Direct link to this question

    https://ch.mathworks.com/matlabcentral/answers/2138761-finding-a-a-path-between-two-points-on-a-3d-surface-that-proceeds-through-lowest-value-points

  • Link

    Direct link to this question

    https://ch.mathworks.com/matlabcentral/answers/2138761-finding-a-a-path-between-two-points-on-a-3d-surface-that-proceeds-through-lowest-value-points

Commented: Mathieu NOE on 19 Jul 2024 at 17:13

  • data.txt

Hello,

I have data (100X50 array for X, Y and Z coordiantes ) corresponding to the surface shown in the below image. I am interested in obtaining paths from flat region (right side yellow circle) of the surface to the minima at red and brown cricle on the left side of the surface. Only condition is that the path should proceed through lowest value points along the Z axis. I could obtain one path connecting yellow and red circles by using "min" function in matlab. I tried find peaks in order to obtain the other path (shown with black arrow in the image). But, the well around the brown circle is very shallow resulting the findpeaks gives only one peak at the region of red circle. Could you please help me to obtain the second path that connects yellow and brown circles. I have also attached my data file. "Shortestpath" function in matlab might be useful for this purpose. I am however not sure how to use it.

These type of paths are referred as "minimum energy paths" in chemistry, assuming that the Z-axis is energy and X- and Y-axis represent molecular coordiantes. In other words, I am looking for a steepest descent path between yellow and brown circles.

Finding a a path between two points on a 3d surface that proceeds t... (2)

Thank you very much for your time

Regards,

Mahesh

1 Comment

Show -1 older commentsHide -1 older comments

Mathieu NOE on 19 Jul 2024 at 17:13

Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/2138761-finding-a-a-path-between-two-points-on-a-3d-surface-that-proceeds-through-lowest-value-points#comment_3215946

it would help if you could post the code and "Shortestpath" function

Sign in to comment.

Sign in to answer this question.

Answers (1)

Star Strider on 19 Jul 2024 at 16:26

  • Link

    Direct link to this answer

    https://ch.mathworks.com/matlabcentral/answers/2138761-finding-a-a-path-between-two-points-on-a-3d-surface-that-proceeds-through-lowest-value-points#answer_1488156

  • Link

    Direct link to this answer

    https://ch.mathworks.com/matlabcentral/answers/2138761-finding-a-a-path-between-two-points-on-a-3d-surface-that-proceeds-through-lowest-value-points#answer_1488156

Open in MATLAB Online

  • data.txt

I am not certain what you wantt, and I doubt there is a way to impoose the energy constraints on the path. (The shortestpath function is for graph objects. What you want to do will not apply since it is not a graph.)

I did two things here, the first was to determine the contours of the regions where the gradient result (numerical derivative) is 0 using the contour function (actually contour3 because I want to draw the contours on the gradient plot), then I drew the contours on the original plot, as well as a direct line from what I believe to be the desired origin to the desired end point. (I guessed at those using tthe contour results because they were not specifically stated in your question.)

Try this —

A1 = readmatrix('data.txt');

[U2,ix] = unique(A1(:,2),'stable');

coldim = mean(diff(ix));

xm = reshape(A1(:,1), coldim, []);

ym = reshape(A1(:,2), coldim, []);

zm = reshape(A1(:,3), coldim, []);

figure

surf(xm, ym,zm)

xlabel('X')

ylabel('Y')

title('Original Surface')

view(30,60)

Finding a a path between two points on a 3d surface that proceeds t... (5)

dx = abs(mean(diff(xm(:,1)))) % Step In The X (row) Direction

dx = 0.0202

dy = abs(mean(diff(ym(1,:)))) % Step In The Y (column) Direction

dy = 1.4286

dzm = gradient(zm, dy, dx); % Surface Numerical Derivative

figure

surf(xm, ym, dzm)

hold on

c = contour3(xm, ym, dzm, [0 0], 'r', 'LineWidth',2);

idx = find(c(1,:)==0);

hold off

xlabel('X')

ylabel('Y')

zlabel('dZ')

title('Derivative Surface')

view(30,60)

Finding a a path between two points on a 3d surface that proceeds t... (6)

% view(0,90)

Fz = scatteredInterpolant(A1(:,1), A1(:,2), zm(:));

idx = find(c(1,:)==0)

idx = 1x3

1 24 145

<mw-icon class=""></mw-icon>

<mw-icon class=""></mw-icon>

for k = 1:numel(idx)

seglen = c(2,idx(k));

xv{k} = c(1,idx(k)+(1:seglen));

yv{k} = c(2,idx(k)+(1:seglen));

zv{k} = Fz(xv{k}.',yv{k}.');

end

xe = mean(xv{3}) % End Point: X

xe = 1.2734

ye = mean(yv{3}) % End Point: Y

ye = 102.1280

xs = xv{2}(end) % Start Point: X

xs = 3

ys = yv{2}(end) % Start Point: Y

ys = 114.8958

N = 250;

xl = linspace(xs, xe, N); % Define Line: X

yl = linspace(ys, ye, N); % Define Line: Y

zl = Fz(xl.', yl.'); % Define Line: Z

rgb = 'rgb';

figure

surf(xm, ym,zm, 'DisplayName','Surface')

hold on

for k = 1:numel(zv)

plot3(xv{k}, yv{k}, zv{k}, rgb(k), 'LineWidth',2, "DisplayName",["Minimum Contour "+k])

end

plot3(xl.', yl.', zl, 'm', 'LineWidth',2, 'DisplayName','Direct Path')

hold off

xlabel('X')

ylabel('Y')

zlabel('Z')

title('Original Surface With Contour & Path Lines')

view(30,60)

legend('Location','bestoutside')

Finding a a path between two points on a 3d surface that proceeds t... (7)

.

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

See Also

Categories

MATLABGraphics2-D and 3-D PlotsSurfaces, Volumes, and PolygonsSurface and Mesh Plots

Find more on Surface and Mesh Plots in Help Center and File Exchange

Tags

  • minimum value path between two points on 3d grid

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


Finding a a path between two points on a 3d surface that proceeds t... (8)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

Finding a a path between two points on a 3d surface that proceeds t... (2024)

FAQs

How do you find the distance between two points on a 3d plane? ›

Similarly, to calculate the distance between two objects (or points) in space, the knowledge and formula of three dimensions – the distance between two points is required. PQ = d = √ [(x2 – x1)2 + (y2 – y1)2 + (z2 – z1)2].

What is the shortest path between two points on a surface? ›

Geodesic paths are sometimes defined as shortest path between points on a surface, however this is not always a satisfactory definition. In this paper we define as follows [15]: Definition 2.1 Geodesics are curves of zero geodesic curvature.

What is the shortest path between two points always along on the surface of a sphere? ›

The great-circle distance, orthodromic distance, or spherical distance is the distance between two points on a sphere, measured along the great-circle arc between them.

How do you find the shortest path between two points on a sphere? ›

Finding the shortest distance between two points on the sphere is not a simple calculation given their latitude and longitude. As proved below, the shortest path on the sphere is always a great circle, which is the intersection of the sphere with a plane through the origin.

How do you find a line through two points in 3D? ›

Any two points in 3D define a straight line. You probably meant to ask how to find equation of a line connecting two points in 3D space and the answer is: (B - A) = A + P . (B - A) where A and B are position vectors defining the two given points and P is a vector defining an arbitrary point on the line.

What's the formula for distance between two points? ›

The formula to find the distance between the two points is usually given by d=√((x2 – x1)² + (y2 – y1)²). This formula is used to find the distance between any two points on a coordinate plane or x-y plane.

What is the length of the path traveled between two points? ›

Distance is the total length of the path travelled between two points.

What is the shortest path between two points called? ›

A line segment is the shortest distance between any two points.

How do you find the distance between two points on the surface of a sphere? ›

For example, haversine(θ) = sin²(θ/2). The haversine formula is a very accurate way of computing distances between two points on the surface of a sphere using the latitude and longitude of the two points.

What is the shortest straight path between two points? ›

It was Archimedes who first articulated that the shortest path between two points is a straight line. You have most likely heard of the Law of Straight Lines, it's one of the basic principles of geometry.

What is the shortest path between two points on the surface of a sphere crossword? ›

The shortest path between two points on a curved surface, such as the surface of a sphere is called a geodesic.

How do you find the shortest distance between two points? ›

The Distance Formula. The shortest distance between two points is a straight line. This distance can be calculated by using the distance formula. The distance between two points ( x 1 , y 1 ) and ( x 2 , y 2 ) can be defined as d = ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2 .

How do you find the shortest path? ›

Dijkstra's Algorithm finds the shortest path between a given node (which is called the "source node") and all other nodes in a graph. This algorithm uses the weights of the edges to find the path that minimizes the total distance (weight) between the source node and all other nodes.

What is the actual path length between two points? ›

Distance is the length of the actual path followed by a body between two points. It is a scalar quantity and is defined only by magnitude and not by direction.

How do you find the distance between two parallel planes in 3D? ›

The formula for determining the distance between two planes π1: ax + by + cz + d1 = 0 and π2: ax + by + cz + d2 = 0 is |d2 – d1|/√(a2 + b2+ c2). The shortest distance between the surfaces of two planes can be used to calculate the distance between them.

How do you find the mid point between two points in 3D? ›

To find this center point, midpoint formula is applied. In 3-dimensional space, the midpoint between (x1, y1, z1) and (x2, y2, z1) is (x1+x2 )/2,(y1+y2 )/2,(z1+z2 )/2.

Top Articles
Latest Posts
Article information

Author: Virgilio Hermann JD

Last Updated:

Views: 6172

Rating: 4 / 5 (41 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Virgilio Hermann JD

Birthday: 1997-12-21

Address: 6946 Schoen Cove, Sipesshire, MO 55944

Phone: +3763365785260

Job: Accounting Engineer

Hobby: Web surfing, Rafting, Dowsing, Stand-up comedy, Ghost hunting, Swimming, Amateur radio

Introduction: My name is Virgilio Hermann JD, I am a fine, gifted, beautiful, encouraging, kind, talented, zealous person who loves writing and wants to share my knowledge and understanding with you.