필터 지우기
필터 지우기

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 CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by