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










Other popular topics










Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /opensuse
- /rust
- /kotlin
- /ruby
- /erlang
- /python
- /clojure
- /react
- /quarkus
- /go
- /vapor
- /v
- /react-native
- /wasm
- /security
- /django
- /nodejs
- /centos
- /haskell
- /rails
- /fable
- /gleam
- /swift
- /js
- /deno
- /assemblyscript
- /tailwind
- /laravel
- /symfony
- /phoenix
- /crystal
- /typescript
- /debian
- /adonisjs
- /julia
- /arch-linux
- /svelte
- /spring
- /flutter
- /c-plus-plus
- /preact
- /actix
- /java
- /angular
- /ocaml
- /zig
- /kubuntu
- /scala
- /zotonic
- /vim
- /rocky
- /lisp
- /html
- /keyboards
- /nim
- /vuejs
- /emacs
- /elm
- /nerves