フィルターのクリア

Closed-curve point offset

2 ビュー (過去 30 日間)
Alejandro Fernández
Alejandro Fernández 2020 年 1 月 31 日
コメント済み: KSSV 2020 年 2 月 1 日
Hi, I was wondering if anyone would know how to offset a closed curve where I know the x and y coordinates of the points (black curve) and also know the distance at which I want to create the blue curve and the distance at which I want the red curve.
In short, what I want to get are the coordinates of the red and blue curve points.
I tried with Offset Curve but I couldn't get it to work properly.

回答 (1 件)

KSSV
KSSV 2020 年 1 月 31 日
編集済み: KSSV 2020 年 1 月 31 日
Try something like this. S is a Affine transformation matrix for scaling.
% circle of radius 1 for demo
th = linspace(0,2*pi) ;
x = cos(th) ;
y = sin(th) ;
o = ones(size(x)) ;
C = [x ; y ;o]' ;
% up scaling by 1.5
cx = 1.5 ; cy = 1.5 ;
S = [cx 0 0 ; 0 cy 0 ; 0 0 1] ;
C0 = C*S ;
x0 = C0(:,1) ; y0 = C0(:,2) ;
% downscaling by 0.5
cx = 0.5 ; cy = 0.5 ;
S = [cx 0 0 ; 0 cy 0 ; 0 0 1] ;
C1 = C*S ;
x1 = C1(:,1) ; y1 = C1(:,2) ;
figure
hold on
plot(x,y,'k')
plot(x0,y0,'b')
plot(x1,y1,'r')
  3 件のコメント
Alejandro Fernández
Alejandro Fernández 2020 年 1 月 31 日
These are my points (I narrowed it down a bit so as not to have to pass you the total)
20071345 18508878
22889302 22151369
29597266 17896695
37285389 20069946
37867359 6969222
25615370 10795368
17865987 6357039
13822830 16733547
21878513 13550193
18876776 17070247
20071345 18508878
KSSV
KSSV 2020 年 2 月 1 日
points = [20071345 18508878
22889302 22151369
29597266 17896695
37285389 20069946
37867359 6969222
25615370 10795368
17865987 6357039
13822830 16733547
21878513 13550193
18876776 17070247
20071345 18508878];
x = points(:,1) ;
y = points(:,2) ;
o = ones(size(x)) ;
C = [x y o] ;
center = [mean(x) mean(y) 1] ;
C = C-center ;
cx = 1.5 ; cy = 1.5 ;
S = [cx 0 0 ; 0 cy 0 ; 0 0 1] ;
C0 = C*S+center ;
x0 = C0(:,1) ; y0 = C0(:,2) ;
cx = 0.5 ; cy = 0.5 ;
S = [cx 0 0 ; 0 cy 0 ; 0 0 1] ;
C1 = C*S+[mean(x) mean(y) 1] ;
x1 = C1(:,1) ; y1 = C1(:,2) ;
figure
hold on
plot(x,y,'k')
plot(x0,y0,'b')
plot(x1,y1,'r')

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by