fix(perf): canonicalize angle in 3d rotations

This commit is contained in:
Ananth Venkatesh 2025-02-09 00:54:29 -05:00
parent d4dc6ab11f
commit 567742186b
Signed by: ananthv
GPG key ID: 4BB578E748CFE4FF

View file

@ -98,6 +98,16 @@ type Msg
| Copy String
modulo : Float -> Float -> Float
modulo a b =
b - toFloat (floor (b / a)) * a
canonicalize : Float -> Float
canonicalize angle =
modulo 360 angle
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
let
@ -134,7 +144,7 @@ update msg model =
}
Rotate time ->
wrap { model | angle = model.angle + 2 * (2 + sin (toFloat (Time.posixToMillis time) / 1000)) }
wrap { model | angle = canonicalize (model.angle + 2 * (2 + sin (toFloat (Time.posixToMillis time) / 1000))) }
Copy text ->
( model, copyToClipboard text )