## Rotations in 3 Dimensions

View as PDF

Points: 12
Time limit: 1.0s
Memory limit: 256M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Your task is simple: given some points in 3D, rotate them around an axis of rotation.

#### Input Specification

The first line of input will contain , the number of test cases .
The next lines will each contain 7 real numbers to 6 decimal places, . You are to rotate the point around the axis of rotation such that if you look at the origin from the axis of rotation, it will be rotated radians counterclockwise. All coordinates will have absolute value of at most and will be such that . It is guaranteed at least one of is nonzero.

#### Output Specification

Output lines, each line should have the , the result of rotation as three space-separated real numbers. Your answer will be judged as correct if it is within an absolute or relative error of .

#### Sample Input

2
0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 3.141593
1.000000 0.000000 0.000000 1.000000 1.000000 1.000000 1.570796

#### Sample Output

0.000000 0.000000 0.000000
0.333334 0.910683 -0.244017

• commented on Jan. 16, 2021, 8:04 p.m.

can someone tell me where is the fault in my code? it works for the exemple but it gives me all WA

• commented on Dec. 24, 2019, 1:45 a.m. edited

I'm sure my method of solving this problem is correct yet I still get WA's. What am I doing wrong?

NVM: I'm just bad at math

• commented on Dec. 31, 2019, 5:26 p.m. edited

nah you aren't :D

• commented on July 24, 2020, 2:46 p.m.

Bruh

• commented on Aug. 17, 2019, 10:02 p.m.

Hey can someone please take a look at the code, at this point I'm just wondering if I've screwed up the precision.

• commented on July 14, 2019, 5:35 p.m.

Hi,I am getting this weird compilation error :

/tmp/tmp0n9ykg_t/3drotate.d: Error: module 3drotate has
non-identifier characters in filename, use module declaration instead

Language : D(dmd 2.86.0 -64) please fix it. Thanks.

• commented on March 3, 2018, 12:07 p.m.

should the first line in the sample output be 2.000000 0.000000 0.000000 since if you look at the origin from (1, 0, 0) and rotate the point (0, 0, 0) 180 degrees counterclockwise then it will end up at (2, 0, 0)?

• commented on Jan. 15, 2016, 12:00 a.m.

Sample input and output work perfectly. I tried printf("%f %f %f\n", x, y, z), printf("%.6f %.6f %.6f\n", x, y, z), %e, and many other combinations and all of them return WA... Im using g++ as well. What did I do wrong?

• commented on Jan. 15, 2016, 12:18 a.m.

Your code suffers from floating point precision issues: if you change your variables to doubles, your solution passes.

• commented on Jan. 15, 2016, 12:37 a.m.

Thanks mate, some of math was already in doubles but after changing data to doubles from float, everything worked.

• commented on Oct. 26, 2015, 8:18 p.m.

First of all, I'm wondering what's the order of rotation?

Secondly, say if I want to rotate pie/4 (45 degree) by the z-axis, and then for the next rotation, let say by the x-axis, is it rotating along the old x-axis or the new x-axis, which is the axis produced after the previous rotation with a 45 degree offset?

Can someone explain this program to me?

Thank you

• commented on Dec. 2, 2015, 9:45 p.m.

Now that you've solved it, can you explain it to us?

^ serious question. Thanks!

• commented on Dec. 7, 2016, 12:21 a.m.

Hi, I notice that you convert the angle to radian value in your code.

But the input specification has said that the angle is already radian