I want to vary how much of a plane is filled with the angle of the plane with the horizontal, any help?

조회 수: 1 (최근 30일)
I am running an experiment and currently have a 300x300 zeros matrix and the lower half filled with ones to get a half-plane image. Now I want to 'tilt' this plane with different angles to see how this changes what I am testing. Is there a code I could use to do this?
Any more questions on this (cause I know this could be a bit confusing) please just drop a comment or send me a message.
  댓글 수: 3
Jan
Jan 2017년 7월 4일
편집: Jan 2017년 7월 6일
An angle is not enough for tilting, but you need a center of rotations also: Is it at [150.5, 150.5]?
Daniel Gray
Daniel Gray 2017년 7월 4일
Yes sorry, because of it being a matrix, we'll just make the centre of rotation [150 150]

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

답변 (1개)

Jan
Jan 2017년 7월 4일
편집: Jan 2017년 7월 4일
x = 1:300;
y = 1:300;
m = atan(30 * pi / 180); % 30 deg
k = bsxfun(@plus, m * (x - 150), y.' - 150) > 0; % Rotate around [150,150]
imagesc(k);
Since R2016b this is simpler:
k = (m * (x - 150)) + (y.' - 150) > 0;
  댓글 수: 4
Daniel Gray
Daniel Gray 2017년 7월 5일
Sorry yes I should have been more clear. I wanted the angle to be defined as between the horizontal across the centre and the new 'tilted plane' about the centre of rotation. If that doesn't make sense I can send you a diagram
Jan
Jan 2017년 7월 6일
Well, in the code I've posted I used 30 deg as angle. You can replace the angle by a variable:
YourAngle = 17.3; % deg
m = atan(YourAngle * pi / 180); % 30 deg
But if you ran the code with 45 deg, you have done this already. Therefore I do not understand, what the problem is now. What is the difference between the result my code creates and the wanted matrix?

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

카테고리

Help CenterFile Exchange에서 Denoising and Compression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by