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?

First Post!

robcat2075

robcat2075

Hold it… false alarm… I think.

Just by chance I caught a line of code where I was loading a double value into an int variable.

Fixing that has made the inverted rotation result come out correctly.

I wish I knew enough about matrix math to know why the wrong version was good enough for all the tests except that inverted rotation.

Where Next?

Popular Pragmatic Bookshelf topics Top

abtin
page 20: … protoc command… I had to additionally run the following go get commands in order to be able to compile protobuf code using go...
New
New
belgoros
Following the steps described in Chapter 6 of the book, I’m stuck with running the migration as described on page 84: bundle exec sequel...
New
herminiotorres
Hi! I know not the intentions behind this narrative when called, on page XI: mount() |> handle_event() |> render() but the correc...
New
nicoatridge
Hi, I have just acquired Michael Fazio’s “Kotlin and Android Development” to learn about game programming for Android. I have a game in p...
New
brunogirin
When trying to run tox in parallel as explained on page 151, I got the following error: tox: error: argument -p/–parallel: expected one...
New
taguniversalmachine
It seems the second code snippet is missing the code to set the current_user: current_user: Accounts.get_user_by_session_token(session["...
New
andreheijstek
After running /bin/setup, the first error was: The foreman' command exists in these Ruby versions: That was easy to fix: gem install fore...
New
SlowburnAZ
Getting an error when installing the dependencies at the start of this chapter: could not compile dependency :exla, "mix compile" failed...
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

malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New
wolf4earth
@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness. https://f...
New
AstonJ
Or looking forward to? :nerd_face:
New
AstonJ
There’s a whole world of custom keycaps out there that I didn’t know existed! Check out all of our Keycaps threads here: https://forum....
New
Exadra37
On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a ...
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
PragmaticBookshelf
Author Spotlight Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
First poster: bot
The overengineered Solution to my Pigeon Problem. TL;DR: I built a wifi-equipped water gun to shoot the pigeons on my balcony, controlle...
New
New
PragmaticBookshelf
Develop, deploy, and debug BEAM applications using BEAMOps: a new paradigm that focuses on scalability, fault tolerance, and owning each ...
New

Sub Categories: