align rotations
This commit is contained in:
parent
a5e45c7439
commit
d081d1d42d
3 changed files with 209 additions and 10 deletions
|
@ -1,6 +1,9 @@
|
|||
|
||||
import time
|
||||
import datetime
|
||||
from mathutils import (
|
||||
Vector,
|
||||
)
|
||||
|
||||
def get_timestamp():
|
||||
return datetime.datetime \
|
||||
|
@ -10,9 +13,32 @@ def get_timestamp():
|
|||
def mapRange(in_value, in_min, in_max, out_min, out_max, clamp=False):
|
||||
output = out_min + ((out_max - out_min) / (in_max - in_min)) * (in_value - in_min)
|
||||
if clamp:
|
||||
if out_min < out_max:
|
||||
return min(out_max, max(out_min, output))
|
||||
else:
|
||||
return max(out_max, min(out_min, output))
|
||||
if out_min < out_max:
|
||||
return min(out_max, max(out_min, output))
|
||||
else:
|
||||
return max(out_max, min(out_min, output))
|
||||
else:
|
||||
return output
|
||||
return output
|
||||
|
||||
# # Evaluate a bezier curve for the parameter 0<=t<=1 along its length
|
||||
# def evaluateBezierPoint(p1, h1, h2, p2, t):
|
||||
# return ((1 - t)**3) * p1 + (3 * t * (1 - t)**2) * h1 + (3 * (t**2) * (1 - t)) * h2 + (t**3) * p2
|
||||
|
||||
|
||||
# # Evaluate the unit tangent on a bezier curve for t
|
||||
# def evaluateBezierTangent(p1, h1, h2, p2, t):
|
||||
# return (
|
||||
# (-3 * (1 - t)**2) * p1 + (-6 * t * (1 - t) + 3 * (1 - t)**2) * h1 +
|
||||
# (-3 * (t**2) + 6 * t * (1 - t)) * h2 + (3 * t**2) * p2
|
||||
# ).normalized()
|
||||
|
||||
# def calculateBezierLength(p1, h1, h2, p2, resolution=20):
|
||||
# step = 1/resolution
|
||||
# previous_p = p1
|
||||
# length = 0
|
||||
# for i in range(0, resolution):
|
||||
# t = (i + 1) * step
|
||||
# p = evaluateBezierPoint(p1, h1, h2, p2, t)
|
||||
# length += p.distance(previous_p)
|
||||
# previous_p = p
|
||||
# return length
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue