Search code examples
matrixtransformationsmalltalkcairopharo

How to make a perspective transformation with Athens/Cairo in Pharo Smalltalk


I found affine transformation functionality (rotate, shear, translate, scale) in Athens/Cairo in Pharo Smalltalk.

I am looking for a perspective transformation. Is this possible at all? At least there seem to be no convenience methods for this in the Cairo API.

perspective transformation


Solution

  • There is no perspective transformation, because matrices used in computation is 2x3 affine matrices, which cannot produce such transformation (no combination of scale/rotation on 2-D coordinate space can produce such result). OpenGL uses full 4x4 matrix for coordinate transformations (well, usually it is 3x3 + translation column), but it is enough to create transformations like perspective projection.