# Connect two points with invisible vector and evenly spaced markers along the vector between them and Access Marking coordinates to draw circles around them.

4 vues (au cours des 30 derniers jours)
Vance Blake le 29 Juin 2020
Commenté : Vance Blake le 29 Juin 2020
Hi, I am trying to use elements of this solution https://www.mathworks.com/matlabcentral/answers/233078-how-do-i-get-evenly-spaced-marks-in-my-plots to draw an invisible vector between two points, and then place markers along that vector that are equally spaced in increments of 8 units apart. I think this solution has just about everything I need, except I do not know how to access the markers coordinate data in order to draw circles around them using viscircles. Any help would be greatly appreciated.
% The 2 points I am trying to connect
P_1 = [52.7102,41.0737];
P_2 = [30.5984,56.2307];
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Adam Danz le 29 Juin 2020
Assuming P_1 and P_2 and (x,y) coordinates, the steps are
1. compute slope between the two points
2. choose the number of points beteween and including the end points (see nPoints variable).
3. Given the slope, and point P_1, compute the coordaintes at equally spaced intervals in the direction of P_2.
% P_1 = (x,y)
% P_2 = (x,y)
P_1 = [52.7102,41.0737];
P_2 = [30.5984,56.2307];
plot(P_1(1),P_1(2),'bo')
hold on
plot(P_2(1),P_2(2),'bo')
% Get eq of line
coefs = polyfit([P_1(1),P_2(1)], [P_1(2), P_2(2)],1);
% Get distance
d = sqrt((P_2(1)-P_1(1))^2 + (P_2(2)-P_1(2))^2);
% number of points between and including end points
nPoints = 5;
% Compute distance of each point from P_1
pointDist = linspace(0,d,nPoints);
% Compute (x,y) coordinates of nPoints **in both directions** from P_1
x = P_1(1) + [-1;1].*(pointDist .* sqrt(1/(1+coefs(1)^2)));
y = P_1(2) + [-1;1].*(coefs(1).*pointDist .* sqrt(1/(1+coefs(1)^2)));
% Chose which set of coordinates to use
% Distance should decrease as each coordinate approaches P_2
isDecreasing = all(diff(sqrt((P_2(1)-x).^2 + (P_2(2)-y).^2),1,2) < 0, 2);
x = x(isDecreasing,:);
y = y(isDecreasing,:);
hold on
plot(x, y, 'r+')
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Vance Blake le 29 Juin 2020
Thank You!

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Polar Plots dans Help Center et File Exchange

R2019a

### Community Treasure Hunt

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

Start Hunting!

Translated by
The text passage describes a MATLAB user's request for help in creating an invisible vector between two points and placing evenly spaced markers along it, with the goal of drawing circles around these markers. The user provides the coordinates of the two points and links to a related solution but is unsure how to access the marker coordinates.
no_question

the passage does not contain a direct mathematical question or calculation request. it is a request for assistance in implementing a specific matlab function, which involves mathematical concepts but does not explicitly pose a question or provide an answer to a mathematical problem.
Given a text passage, determine:
    1. If it contains a mathematical question (including word problems or calculations)
    2. If an answer to that mathematical question is provided in the text

First, describe the content structure you found in 1-2 sentences.

Then provide your analysis in the following format:
TYPE: <one of the following values>
- NO_QUESTION
- SINGLE_QUESTION
- SINGLE_QUESTION_WITH_ANSWER
- MULTIPLE_QUESTIONS
- MULTIPLE_QUESTIONS_WITH_ANSWERS
system
# Connect two points with invisible vector and evenly spaced markers along the vector between them and Access Marking coordinates to draw circles around them.

4 vues (au cours des 30 derniers jours)
Vance Blake le 29 Juin 2020
Commenté : Vance Blake le 29 Juin 2020
Hi, I am trying to use elements of this solution https://www.mathworks.com/matlabcentral/answers/233078-how-do-i-get-evenly-spaced-marks-in-my-plots to draw an invisible vector between two points, and then place markers along that vector that are equally spaced in increments of 8 units apart. I think this solution has just about everything I need, except I do not know how to access the markers coordinate data in order to draw circles around them using viscircles. Any help would be greatly appreciated.
% The 2 points I am trying to connect
P_1 = [52.7102,41.0737];
P_2 = [30.5984,56.2307];
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Adam Danz le 29 Juin 2020
Assuming P_1 and P_2 and (x,y) coordinates, the steps are
1. compute slope between the two points
2. choose the number of points beteween and including the end points (see nPoints variable).
3. Given the slope, and point P_1, compute the coordaintes at equally spaced intervals in the direction of P_2.
% P_1 = (x,y)
% P_2 = (x,y)
P_1 = [52.7102,41.0737];
P_2 = [30.5984,56.2307];
plot(P_1(1),P_1(2),'bo')
hold on
plot(P_2(1),P_2(2),'bo')
% Get eq of line
coefs = polyfit([P_1(1),P_2(1)], [P_1(2), P_2(2)],1);
% Get distance
d = sqrt((P_2(1)-P_1(1))^2 + (P_2(2)-P_1(2))^2);
% number of points between and including end points
nPoints = 5;
% Compute distance of each point from P_1
pointDist = linspace(0,d,nPoints);
% Compute (x,y) coordinates of nPoints **in both directions** from P_1
x = P_1(1) + [-1;1].*(pointDist .* sqrt(1/(1+coefs(1)^2)));
y = P_1(2) + [-1;1].*(coefs(1).*pointDist .* sqrt(1/(1+coefs(1)^2)));
% Chose which set of coordinates to use
% Distance should decrease as each coordinate approaches P_2
isDecreasing = all(diff(sqrt((P_2(1)-x).^2 + (P_2(2)-y).^2),1,2) < 0, 2);
x = x(isDecreasing,:);
y = y(isDecreasing,:);
hold on
plot(x, y, 'r+')
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Vance Blake le 29 Juin 2020
Thank You!

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Polar Plots dans Help Center et File Exchange

R2019a

### Community Treasure Hunt

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

Start Hunting!

Translated by
user
The text passage describes a MATLAB user's request for help in creating an invisible vector between two points and placing evenly spaced markers along it, with the goal of drawing circles around these markers. The user provides the coordinates of the two points and links to a related solution but is unsure how to access the marker coordinates.

TYPE: NO_QUESTION

The passage does not contain a direct mathematical question or calculation request. It is a request for assistance in implementing a specific MATLAB function, which involves mathematical concepts but does not explicitly pose a question or provide an answer to a mathematical problem.