Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need to r otate each vertex ( x i , y i ) by degrees counterclockwise, around the origin. Hint: xiyi=xicosyisin=yicos+xisin xi=xicosyisinyi=yicos+xisin My code
I need to rotate each vertex (x i, y i) by degrees counterclockwise, around the origin.
Hint:
xiyi=xicosyisin=yicos+xisin
xi=xicosyisinyi=yicos+xisin
My code is
public static void rotate(double[] x, double[] y, double theta) { for (int i = 0; i < x.length; i++) { x[i] = Math.cos(Math.toRadians(theta)) * x[i] - Math.sin(Math.toRadians(theta)) * y[i]; } for (int i = 0; i < y.length; i++) { y[i] = Math.cos(Math.toRadians(theta)) * y[i] + Math.sin(Math.toRadians(theta)) * x[i]; } }
But it doesn't seem to work, particularly on the y.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started