I created a driver to move an edge as a constant size hypotenuse of an animated right angle triangle.
import bpy
import math as m
def rigthAngleTransform(rot, length):
locY = length-(m.cos(rot)*length)-length
return locY
bpy.app.driver_namespace["rigthAngleTransform"] = rigthAngleTransform
The representation of these values:
This screenshot is not at the start frame! At the start frame the pivot is from "length" distance from the X axis and rot is 0d
Where rot is animated from 0d to 90d (the script uses radians!), while the pivot Y location coordinate is decreasing according to the following function:
locY = length-(cos(rot)*length)-length
The fun part it works perfectly as it should by math if I choose a frame with the mouse cursor. however if I play the animation or change the frames with the arrow keys it will deviate like this:
The end point at the x axis should not deviate from it
A good clue if I change the direction of the animation playback the direction of the deviation will be the opposite (hypotenuse will go under the x axis)
If my perception is correct, during animation the driver has a 1 frame latency.
Update:
My perception was correct I modified the script to use the z rotation value of the next frame, by adding 90/45d to the z rotation. Now it works perfectly during animation, if the interpolation is linear, and it will generate a deviation if I select a frame by clicking.
updated script:
import bpy
import math as m
def rigthAngleTransform(rot, length):
locY = length-(m.cos(rot+m.radians(90/45))*length)-length
return locY
bpy.app.driver_namespace["rigthAngleTransform"] = rigthAngleTransform