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

jeffmcompsci
Title: Design and Build Great Web APIs - typo “https://company-atk.herokuapp.com/2258ie4t68jv” (page 19, third bullet in URL list) Typo:...
New
jesse050717
Title: Web Development with Clojure, Third Edition, pg 116 Hi - I just started chapter 5 and I am stuck on page 116 while trying to star...
New
Alexandr
Hi everyone! There is an error on the page 71 in the book “Programming machine learning from coding to depp learning” P. Perrotta. You c...
New
jdufour
Hello! On page xix of the preface, it says there is a community forum "… for help if your’re stuck on one of the exercises in this book… ...
New
herminiotorres
Hi! I know not the intentions behind this narrative when called, on page XI: mount() |> handle_event() |> render() but the correc...
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
akraut
The markup used to display the uploaded image results in a Phoenix.LiveView.HTMLTokenizer.ParseError error. lib/pento_web/live/product_l...
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
taguniversalmachine
Hi, I am getting an error I cannot figure out on my test. I have what I think is the exact code from the book, other than I changed “us...
New
jonmac
The allprojects block listed on page 245 produces the following error when syncing gradle: “org.gradle.api.GradleScriptException: A prob...
New

Other popular topics Top

PragmaticBookshelf
A PragProg Hero’s Journey with Brian P. Hogan @bphogan Have you ever worried that your only legacy will be in the form of legacy...
New
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
Rainer
Not sure if following fits exactly this thread, or if we should have a hobby thread… For many years I’m designing and building model air...
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
Build highly interactive applications without ever leaving Elixir, the way the experts do. Let LiveView take care of performance, scalabi...
New
AstonJ
Seems like a lot of people caught it - just wondered whether any of you did? As far as I know I didn’t, but it wouldn’t surprise me if I...
New
mafinar
Crystal recently reached version 1. I had been following it for awhile but never got to really learn it. Most languages I picked up out o...
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: 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

Sub Categories: