z_media_rotate3d (zotonic_core v1.0.0-rc.10)

Calculate the ImageMagick distortion parameters for a 3D rotation.

Link to this section Summary

Functions

Calculate the transformation matrix for the perspective. Translate the corner points of the image to the arguments for the ImageMagick distort function. This code has been derived from http://www.fmwconcepts.com/imagemagick/3Drotate/index.php

Link to this section Types

-type matrix() :: [[number()]].

Link to this section Functions

Link to this function

rotate3d(Width, Height, Roll, Tilt, Pan)

-spec rotate3d(Width :: non_neg_integer(),
         Height :: non_neg_integer(),
         Roll :: number(),
         Tilt :: number(),
         Pan :: number()) ->
            {ok, string()} | {error, term()}.

Calculate the transformation matrix for the perspective. Translate the corner points of the image to the arguments for the ImageMagick distort function. This code has been derived from http://www.fmwconcepts.com/imagemagick/3Drotate/index.php

Here we don't scale the image, the image is rotated from the center of the image, and we use a fixed viewing point that is compatible with the viewing point used in the mod_image_edit css3 transformations.