logoalt Hacker News

coldcity_againtoday at 5:24 PM1 replyview on HN

I've been thinking about this since [1] the other day, but I still love how rotation by small angles lets you drop trig entirely.

Let α represent a roll rotation, and β a pitch rotation.

Let R(α) be:

    ( cos α   sin α   0)
    (-sin α   cos α   0)
    (   0       0     1)
Let R(β) be:

    (1     0       0   )
    (0   cos β   -sin β)
    (0   sin β    cos β)
Combine them:

    R(β).R(α) = (    cos α           sin α          0   )
                ((-sin α*cos β)   (cos α*cos β)   -sin β)
                ((-sin α*sin β)   (cos α*sin β)    cos β)
But! For small α and β, just approximate:

    ( 1   α   0)
    (-α   1  -β)
    ( 0   β   1)
So now:

    x' = x + αy
    y' = y - αx - βz
    z' = z + βy
[1]https://news.ycombinator.com/item?id=47348192

Replies

coldcity_againtoday at 5:32 PM

If you just see the conclusion I think it's hard to immediately grok how rotation can arise from this.

This is a great technique for cheaply doing 3D starfields etc on 8-bit machines.

Look ma, no sine table!

show 1 reply