{"repo":"paulz/PerspectiveTransform","free":true,"listed":false,"github":"https://github.com/paulz/PerspectiveTransform","clone":"git clone https://github.com/paulz/PerspectiveTransform.git","description":"Calculate CATransform3D between two Perspectives","language":"Swift","stars":175,"topics":["swift","xcode","matrix","polygon","animation","3d-graphics","catransform3d","perspective","agumentedreality"],"license":"MIT","category":"chat-messaging","readme_excerpt":"Perspective Transform [![Carthage compatible][carthage-badge]](https://github.com/Carthage/Carthage) [![Swift][swift-badge]][swift-url] PerspectiveTransform caclulates homogeneous transformation matrix for a view 3D projection in 2D. It can be used to place views within given image visual perspective using Core Animation CATransform3D and CALayer.tranform . Projection is caclulated between source and destination perspectives that are defined by 4 corners, assuming they form a Quadrilateral. CATransform3D To place an overlay image on top of a container image with matching persperctive we can use Core Animation transform matrix. CATransform3D is a tranformation matrix that is used to rotate, scale, translate, skew, and project the layer content. It can also be used to describe a perspective projectection of 2D shape in 3D space. Container Overlay Combination ------------- ------------- --- Core Animation allow applying CATransform3D to CALayer via transform property: In detail CATransform3D is a 4 x 4 matrix which takes 16 parameters to build. Translation and scale are represented by their axis components: (tX, tY) and (sX, sY) within the matrix. While 3D rotation is represented by multiple values: r12, r21, r13, r31, r32, r23. Perspective Transform based on 4 corners We can easily see 4 points with container image where the corners of the overlay image should be. In general it is a 4 point polygon. Using an SVG editor we can draw that polygon using container image as a backgro","default_branch":null,"files":null,"tree":[],"storefront":"/r/paulz","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/paulz/PerspectiveTransform/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}