ianmackenzie/elm-geometry

Remove 'clever' optimization in rotation functions?

Aperta

#73 aperta il 17 set 2018

 (3 commenti) (0 reazioni) (1 assegnatario)Elm (28 fork)auto 404
Hacktoberfest

Metriche repository

Star
 (186 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

Currently, rotateAround functions are optimized for partial application - they cache computed sines/cosines etc. in a returned lambda, which is then just immediately called and discarded if rotateAround is called with three arguments instead of two. This makes cases like

List.map (Point3d.rotateAround axis angle) points

more efficient since sines/cosines etc. are only calculated once, but

Point3d.rotateAround axis angle point

less efficent since a lambda function is allocated and then immediately discarded.

It may be better to switch to the 'naive' implementation, and use the 'frame trick' for efficient transformations where necessary. This would make efficient single calculations possible (currently there's no easy way to avoid the lambda-allocation overhead), and there would be a consistent story for optimization - just use frames!

Guida contributor