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

johnp
Running the examples in chapter 5 c under pytest 5.4.1 causes an AttributeError: ‘module’ object has no attribute ‘config’. In particula...
New
brianokken
Many tasks_proj/tests directories exist in chapters 2, 3, 5 that have tests that use the custom markers smoke and get, which are not decl...
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
jgchristopher
“The ProductLive.Index template calls a helper function, live_component/3, that in turn calls on the modal component. ” Excerpt From: Br...
New
digitalbias
Title: Build a Weather Station with Elixir and Nerves: Problem connecting to Postgres with Grafana on (page 64) If you follow the defau...
New
New
mert
AWDWR 7, page 152, page 153: Hello everyone, I’m a little bit lost on the hotwire part. I didn’t fully understand it. On page 152 @rub...
New
New
gorkaio
root_layout: {PentoWeb.LayoutView, :root}, This results in the following following error: no “root” html template defined for PentoWeb...
New
mcpierce
@mfazio23 I’ve applied the changes from Chapter 5 of the book and everything builds correctly and runs. But, when I try to start a game,...
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
dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
New
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
Help
I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
New
PragmaticBookshelf
Author Spotlight: Peter Ullrich @PJUllrich Data is at the core of every business, but it is useless if nobody can access and analyze ...
New
New

Sub Categories: