create point betweem two points
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hi every one
I have two points, for example
(2,5)-(10,15)... how can I create a new point between them???
thanks a loot
majid
채택된 답변
Walter Roberson
2012년 7월 15일
NumberNewPoints = 3;
xvals = linspace(2, 10, NumberNewPoints+2);
yvals = linspace(5, 15, NumberNewPoints+2);
pts = [xvals(:), yvals(:)];
Now the points are the rows.
댓글 수: 11
Majid Al-Sirafi
2012년 7월 15일
thank you dear walter
now how can I move the created points ( for example i want to move one created point) between two original points
thanks dear
Walter Roberson
2012년 7월 15일
Which mechanism were you thinking of for moving the points?
Majid Al-Sirafi
2012년 7월 15일
dear walter
the mechanism is straight moving (that means the created points move between (2,5) and (10,15) and do not exceed them)
thanks dear
Let the original point be (x1,y1) and the final point be (x2,y2), and let t be a proportion of the time for the movement (i.e. t=0 when at the starting point, t=1 when at the ending point.) Then,
newpoints = (x1(:) + (x2(:)-x1(:)) .* t, y1(:) + (y2(:)-y1(:)) .* t]
please dear let dear apply the equation with the following data let p1(2,5) and p2(10,15) and we want to move p1 by 1 time to p2 so,
newpoints = [2 + (10-2) .*2, 5 + (15-5) .*2]
newpoints = 18 25
x=18 and y=25 ... is this ok ???
thanks dear
thanks a lot dear
You used 2 for your time t, not 1. t should be the portion along the line segment that you want, not the absolute time.
If you are starting at time 0 and ending at time Tmax, then the "t" of the equation should be the current time divided by Tmax:
newpoints = (x1(:) + (x2(:)-x1(:)) .* T/Tmax, y1(:) + (y2(:)-y1(:)) .* T/Tmax]
For example if you are at time T now and your last time for the movement is Tmax = 7.3, then you would have
newpoints = (x1(:) + (x2(:)-x1(:)) .* T/7.3, y1(:) + (y2(:)-y1(:)) .* T/7.3]
Majid Al-Sirafi
2012년 7월 16일
Please dear walter
apply that with the actual values please I have p1(2,5) and p2(10,15) and i want to move from p1 to p2, apply that with your equation, and what the new value of x and y
Image Analyst
2012년 7월 16일
Walter just loves it when people call him dear. ;-)
x = 2 + 8 .* T/Tmax;
y = 5 + 10 .* T/Tmax;
Where T is the time since the start, and Tmax is the time at which you want to reach the second point.
Majid Al-Sirafi
2012년 7월 16일
dear watler according to your code
NumberNewPoints = 3;
xvals = linspace(2, 10, NumberNewPoints+2);
yvals = linspace(5, 15, NumberNewPoints+2);
pts = [xvals(:), yvals(:)];
but I choose NumberNewPoints = 1;
so, the new created point is (6,10) how can I move this created point between p1(2,5) and p2(10,5).. that means i want to move this created point to p1 at first state , and move the created point to p2 at a second state,and the movement time is 2. But this movement do not exceed P1 and p2
thanks a lot
Walter Roberson
2012년 7월 16일
편집: Walter Roberson
2018년 1월 28일
pts(1,:) %x,y for starting point
pts(2,:) %x,y for intermediate point
pts(3,:) %x,y for final point
추가 답변 (1개)
Andrei Bobrov
2012년 7월 16일
out = ([10,15]-[2,5])*(2*rand-1)+[2,5]
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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
- United Kingdom (English)
