Draw a square, and then rotate it with rcos/rsin?
5 views (last 30 days)
Show older comments
Hi! I'm trying to draw a square, and then use various inputs to try and rotate it/move it around. But I'm not sure how I'm supposed to solve this.
It's supposed to be 2x2 matrix using sin and cos to rotate it.
I'm fairly new to Matlab.
Any ideas or hints on how to tackle this?
Thank you in advance.
0 Comments
Answers (3)
Image Analyst
on 21 Nov 2014
Sounds like homework so I won't just do it for you. I'm sure you already know the rotation array from Wikipedia or wherever:
rotationArray = [cosd(theta) sind(theta); -sind(theta) cosd(theta)];
But I've attached a demo that I already have that rotates an ellipse by varying angles. You should be able to take that example and apply it to a list of square coordinates rather than ellipse coordinates.
1 Comment
Image Analyst
on 21 Nov 2014
Alexander's "Answer" moved here:
Thank you. Yes, it's homework, but since none of my mates knew how to tackle it either, I figured we needed some aid. I'll try and analyze the code and see if I understand all the steps so I'll learn.
Appreciate the help.
chen xi li
on 1 Oct 2018
Edited: chen xi li
on 1 Oct 2018
d = sin2(π/6) + cos2(π/6) how to input it
1 Comment
Image Analyst
on 2 Oct 2018
Assuming the 2 means "squared", like this:
d = sin(pi/6) ^ 2 + cos(pi/6) ^ 2
you will, of course, get exactly 1.
chen xi li
on 15 Oct 2018
bmi how to solve it
1 Comment
Image Analyst
on 15 Oct 2018
He probably simply adapted my rotate_ellipse. It's trivial. Did you actually even try it?
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!