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.

Popular Prag Prog topics Top

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
jeffmcompsci
Title: Design and Build Great Web APIs - typo “https://company-atk.herokuapp.com/2258ie4t68jv” (page 19, third bullet in URL list) Typo:...
New
cro
I am working on the “Your Turn” for chapter one and building out the restart button talked about on page 27. It recommends looking into ...
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
New
brian-m-ops
#book-python-testing-with-pytest-second-edition Hi. Thanks for writing the book. I am just learning so this might just of been an issue ...
New
patoncrispy
I’m new to Rust and am using this book to learn more as well as to feed my interest in game dev. I’ve just finished the flappy dragon exa...
New
Charles
In general, the book isn’t yet updated for Phoenix version 1.6. On page 18 of the book, the authors indicate that an auto generated of ro...
New
kolossal
Hi, I need some help, I’m new to rust and was learning through your book. but I got stuck at the last stage of distribution. Whenever I t...
New
redconfetti
Docker-Machine became part of the Docker Toolbox, which was deprecated in 2020, long after Docker Desktop supported Docker Engine nativel...
New

Other popular topics Top

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
You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
New
PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
New
AstonJ
Inspired by this post from @Carter, which languages, frameworks or other tech or tools do you think is killing it right now? :upside_down...
New
AstonJ
Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
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
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New
PragmaticBookshelf
Author Spotlight: Tammy Coron @Paradox927 Gaming, and writing games in particular, is about passion, vision, experience, and immersio...
New

Latest in PragProg

View all threads ❯