robcat2075

robcat2075

The Ray Tracer Challenge: Inversion of Rotation trouble

Title: Ray Trace Challenge: Inversion pg 49

I have gotten all my code (including my matrix multiplication and inversion routines) to pass the prescribed tests up through page 48, where we begin rotating on the X axis.

My code creates the desired result for the “half quarter” and “full quarter” rotations on the X axis.

However, on page 49 there is this last test proposed for the X rotations…

Next, add another test showing that the inverse of this rotation matrix simply
rotates in the opposite direction.

By an inversion, I do not get a rotation in the opposite direction. Instead, the point gets moved to 0,0,0

The matrix after the original PI/4 rotation operation looks like this…

Rotation PI/4.0 matrix values
        Matrix values
        | 1.0000        | 0.0000        | 0.0000        | 0.0000        |
        | 0.0000        | 0.7071         | -0.7071        | 0.0000        |
        | 0.0000        | 0.7071         | 0.7071          | 0.0000        |
        | 0.0000        | 0.0000       | 0.0000        | 1.0000        |

That matrix produces the desired result when multiplied by the tuple that represents the 0,1,0 starting point.

If I apply Inversion to that matrix, as the book directs, I get this matrix…

Rotation PI/4.0 matrix INVERTED values
        Matrix values
        | 1.0000         | 0.0000       | 0.0000        | 0.0000       |
        | 0.0000        | 0.0000       | 0.0000        | 0.0000       |
        | 0.0000        | 0.0000       | 0.0000        | 0.0000       |
        | 0.0000        | 0.0000       | 0.0000        | 1.0000        |

When multiplied by the 0,1,0 Tuple, this does not produce an opposite rotation, the Tuple is placed at 0,0,0.

Elsewhere on the internet I have read the correct way to reverse a rotation matrix is to transpose it.

Indeed, if I use my Transpose routine on the original rotation Matrix I get a matrix that produces a correct opposite rotation…

Rotation PI/4.0 matrix TRANSPOSED values
        Matrix values
        | 1.0000        | 0.0000      | 0.0000      | 0.0000       |
        | 0.0000       | 0.7071       | 0.7071       | 0.0000       |
        | 0.0000       | -0.7071      | 0.7071       | 0.0000       |
        | 0.0000       | 0.0000       | 0.0000     | 1.0000        |

Rotation PI/4.0  TRANSPOSED point values
values:         x= 0.000        y= 0.707        z= -0.707       w= 1

However, after searching this forum I have not seen any mention that the direction to invert rather than tranpose in this instance is a typo or other error.

What am I doing wrong?

Popular Prag Prog topics Top

raul
Page 28: It implements io.ReaderAt on the store type. Sorry if it’s a dumb question but was the io.ReaderAt supposed to be io.ReadAt? ...
New
alanq
This isn’t directly about the book contents so maybe not the right forum…but in some of the code apps (e.g. turbo/06) it sends a TURBO_ST...
New
rmurray10127
Title: Intuitive Python: docker run… denied error (page 2) Attempted to run the docker command in both CLI and Powershell PS C:\Users\r...
New
leba0495
Hello! Thanks for the great book. I was attempting the Trie (chap 17) exercises and for number 4 the solution provided for the autocorre...
New
leonW
I ran this command after installing the sample application: $ cards add do something --owner Brian And got a file not found error: Fil...
New
jskubick
I found an issue in Chapter 7 regarding android:backgroundTint vs app:backgroundTint. How to replicate: load chapter-7 from zipfile i...
New
adamwoolhether
Is there any place where we can discuss the solutions to some of the exercises? I can figure most of them out, but am having trouble with...
New
EdBorn
Title: Agile Web Development with Rails 7: (page 70) I am running windows 11 pro with rails 7.0.3 and ruby 3.1.2p20 (2022-04-12 revision...
New
New
roadbike
From page 13: On Python 3.7, you can install the libraries with pip by running these commands inside a Python venv using Visual Studio ...
New

Other popular topics Top

axelson
I’ve been really enjoying obsidian.md: It is very snappy (even though it is based on Electron). I love that it is all local by defaul...
New
New
Rainer
My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
New
AstonJ
I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl: The Ser...
New
dimitarvp
Small essay with thoughts on macOS vs. Linux: I know @Exadra37 is just waiting around the corner to scream at me “I TOLD YOU SO!!!” but I...
New
wmnnd
Here’s the story how one of the world’s first production deployments of LiveView came to be - and how trying to improve it almost caused ...
New
First poster: joeb
The File System Access API with Origin Private File System. WebKit supports new API that makes it possible for web apps to create, open,...
New
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New
PragmaticBookshelf
Author Spotlight: Bruce Tate @redrapids Programming languages always emerge out of need, and if that’s not always true, they’re defin...
New

Latest in PragProg

View all threads ❯