フィルターのクリア

How to create an off-center, rotated, cosine-ramped edged ellipse?

2 ビュー (過去 30 日間)
Han
Han 2015 年 12 月 18 日
編集済み: Han 2015 年 12 月 18 日
Hi all,
I'm trying to make an off-center, rotated, cosine-ramped edged ellipse. Managed to make it off-center and cosine-ramped the edges, but I'm having difficulties trying to rotate it. Here's my code so far:
imSize =128;
width=10;
height=20;
aspectRatio=width/height;
nCosSteps=5;
[X,Y]= meshgrid((-imSize/2+1:imSize/2),(-imSize/2+1:imSize/2));
radii = sqrt((X-centerX).^2 + ((Y-centerY)*aspectRatio).^2);
%%%set inner edge to zero
radii = radii - radii(floor(end/2)+centerX+floor(apWidth/2)
- nCosSteps,floor(end/2)+centerY+floor(apHeight/2)-nCosSteps);
%%%Do linear transform to set outer edge to pi
outerVal = radii(end/2+centerX+floor(apWidth/2)-1,
end/2+centerY+floor(apHeight/2)-1);
radii = radii * pi/outerVal ;
% set more central values 0 (ie, cos(0) = 1)
radii( find(radii<=0) ) = 0;
% set values more beyond steps to pi (ie, cos(pi) = 0)
radii( find(radii>=pi) ) = pi;
% Take cos of all the transformed radial values.
raisedCosMask = .5 + .5 * cos(radii);
if mod(imSize,2) == 1% odd number
raisedCosMask = raisedCosMask(1:end-1,1:end-1);
end
And this gives:
How should I proceed to rotate this ellipse (i.e., angles like 45 degrees, 20 degrees)? Any help would be greatly appreciated! :)

回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by