Rotated point

Report a typo

You have coordinates of point, and an angle. You need to calculate the coordinates of the new point, which are obtained as a result of rotating (counterclockwise) the original point by a given angle. You can find a formula here.

given angle

You will get three numbers: the x and y coordinates and the angle in degrees. Calculate new coordinates and round them before the output.

You've encountered a challenging problem — time to put your thinking cap on 💡🧢! The task statement and HINT should help you solve it; however, if this problem is too complex, you can postpone it and come back later to try and solve it.

Tip:

Correct formulas are:

  • x' = x*cos(angle) - y*sin(angle)
  • y' = x*sin(angle) + y*cos(angle)

Sample Input 1:

5 0 90

Sample Output 1:

0 5
Write a program in Go
package main

import (
"fmt"
"math"
)

const ToRadians = math.Pi / 180

func main() {
var x, y, angle float64

fmt.Scan(&x, &y, &angle)

angle *= ToRadians

// Calculate the new coordinates below:
newX := ?
newY := ?

// Round newX and newY to the nearest integer:
newX = math.?
newY = math.?

fmt.Println(?, ?)
}
___

Create a free account to access the full topic