Created
August 23, 2011 08:12
-
-
Save julik/1164618 to your computer and use it in GitHub Desktop.
Nuke corner pin to matrix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# and here is the script in case anyone is interested :) | |
import nuke | |
def getTheCornerpinAsMatrix(): | |
projectionMatrixTo = nuke.math.Matrix4() | |
projectionMatrixFrom = nuke.math.Matrix4() | |
#dir(projectionMatrix) | |
theCornerpinNode = nuke.selectedNode() | |
imageWidth = float(theCornerpinNode.width()) | |
imageHeight = float(theCornerpinNode.height()) | |
to1x, to1y = theCornerpinNode['to1'].value() | |
to2x, to2y = theCornerpinNode['to2'].value() | |
to3x, to3y = theCornerpinNode['to3'].value() | |
to4x, to4y = theCornerpinNode['to4'].value() | |
from1x, from1y = theCornerpinNode['from1'].value() | |
from2x, from2y = theCornerpinNode['from2'].value() | |
from3x, from3y = theCornerpinNode['from3'].value() | |
from4x, from4y = theCornerpinNode['from4'].value() | |
projectionMatrixTo.mapUnitSquareToQuad(to1x,to1y,to2x,to2y,to3x,to3y,to4x,to4y) | |
projectionMatrixFrom.mapUnitSquareToQuad(from1x,from1y,from2x,from2y,from3x,from3y,from4x,from4y) | |
theCornerpinAsMatrix = projectionMatrixTo*projectionMatrixFrom.inverse() | |
theCornerpinAsMatrix.transpose() | |
return theCornerpinAsMatrix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
added inverse option and exxtra matrix knob to calculations :)