Measuring and Changing

조회 수: 1(최근 30일)
Majid Al-Sirafi
Majid Al-Sirafi 2012년 3월 21일
High everyone I have line of two points: p1(1.325,2.732)-p2(12.334,30.257) and I want to do the following: 1- Measure the distance between p1&p2 and the distance will be D1. 2- Change the distance D1 into D2. 3- Find the difference between D1 & D2… result=difference(D1,D2). 4- Change the points values (moving the points), according to the value of result.
thank you
  댓글 수: 3
Majid Al-Sirafi
Majid Al-Sirafi 2012년 3월 21일
i will simplify the question
1- finding the distance between p1 and p2 for example suppose that the distance is 4.333
2- for example ,by changing this distance into 4.999 (this will be a new distance)
3- finding the difference (4.333,4.999)
4. dividing the result by 2, let the result will be R
5. move p1 and p2 by this R

댓글을 달려면 로그인하십시오.

답변(1개)

Kevin Holst
Kevin Holst 2012년 3월 21일
if p1 and p2 are 2 element vectors:
1:
d1 = sqrt(sum((p1-p2).^2));
2: No explanation should be required.
3:
diff = d2-d1; %...really
4: This is very slightly more complicated, mainly due to a lack of clarity, and it seems to be the crux of this homework problem. Are you simply wanting to move the points along the same line apart or together to get the new distance? If so, I'd suggest looking at the 2d distance equation d = sqrt(dx^2 + dy^2). If you want to move each point by a given distance, and you know the slope = dy/dx, you can solve for dy and dx.
  댓글 수: 1
Majid Al-Sirafi
Majid Al-Sirafi 2012년 3월 21일
Dear
I have ESRI shape file this file hold polygon feature, and I want to change the length of some ledge within polygon…
this length(distance) can be change by :-
first, measuring the distance between two points of edge (p1 and p2) (I don’t know the equation of measuring)
second, after finding the distance we can change the value of this distance
third, finding the difference between old and new distance
fourth, according to this changing the position of each point (p1 and p2)point will be change (I don’t know the equation of changing position)
thanks

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by