Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

4. Identify cultural variations in communication style.

Answered: 1 week ago