Hi Adam,
Here's the way the Tracker calculates rotation. It might be overkill,
but depending on your exact usage, you should be able to glean enough to
write a simpler expression / function to work for your case.
the Tracker uses 2 points to get the rotation in the following way.
Firstly, it gets the point-around-which-we-rotate, by averaging all of
the track locations that have "T" transform selected. So if only one
track has "T", it'll just be that point, otherwise it'll take the
average of the rest of them. Call this the 'input centre' point if we
calculate this at the Tracker's reference frame, and 'output centre'
point if it's calculated at the current frame.
Then, it takes all the track points with "R" transform selected, at
their reference frame (call these the 'input' points), and the current
frame ('output_points'), subtracts the respective input and output
centres, and calculates the average angular difference between the each
point.
Here's some pseudo-code to get that difference:
C = 0
S = 0
for all Trackers, indexed by 'j':
if Tracker 'j' uses rotation transform 'R':
source = input_points[j] - input_center
current = output_points[j] - output_center
# Running cosine of the angle between the two points:
C += source.x * current.x + source.y * current.y
# Running sin of the angle between the two points:
S += source.x * current.y - current.y * current.x
# Finally, calculate the rotation value
angle = atan2(S, C)
Hope that helps,
Dan.
On 09/02/2012 02:01, Adam Hazard wrote:
Anyone know how to have a rotation slider control a 2d point rotating
around another 2d point with an expression?
Basically I want to know how the tracker derives rotation from 2
points, but I guess in reverse.
Or a way to hack this together by linking parameters. I haven't found
a solution.
Thanks in advance
-Adam
_______________________________________________
Nuke-users mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
--
Dan Ring, Ph.D.
Research Engineer
The Foundry
6th Floor, The Communications Building,
48 Leicester Square,
London, WC2H 7LT, UK
Tel: +44 (0)20 7968 6828 - Fax: +44 (0)20 7930 8906
Web: www.thefoundry.co.uk
Email: [email protected]
The Foundry Visionmongers Ltd.
Registered in England and Wales No: 4642027
_______________________________________________
Nuke-users mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users