Trylon wrote:Grogyan wrote:Anyone here familiar with calculus?
Mine's a bit rusty, but well, it never hurts to try
Though I didn't exactly get the full problem, so if you could explain it in a bit more detail I might actually have a chance of helping out
I'm trying to use this as a basis, but I don't understand the math terminology to be able to read it
http://en.wikipedia.org/wiki/B%C3%A9zier_curve
Essentially a bezier curve segment has 2 knots/anchors and 2 handles
In Blender its more detailed
Where C is the knot
Where H is a Handle
Where B is the internally calculated Bezier Curve
Where O is the ObData center
In the Above example Blender doesn't see a segment, it instead sees a 3 x 3 matrix called a BezTriple
I have got data of the vectors named as
H1_X
H1_Y
H1_Z
P_X
P_Y
P_Z
H2_X
H2_Y
H2_Z
But because I am just focusing on Yaw rotations at the moment, the vectors that are of interest right now are
H1_X
H1_Y
P_X
P_Y
H2_X
H2_Y
- Code: Select all
Radian = 6.283185307179586476925286766559
print "function."
SideB = H2_X - P_X
SideA = H2_Y - P_Y
print "Side A: %s Side B: %s" % (SideA, SideB)
AngleC = atan2 (SideB, SideA)
AngleC = (AngleC * Radian)
print "Arc tan: %s" % AngleC
SideE = H1_X - P_X
SideD = H1_Y - P_Y
print "Side D: %s Side E: %s" % (SideD, SideE)
AngleF = atan2 (SideE, SideD)
AngleF = (AngleF * Radian)
print "Arc tan: %s" % AngleF
AngleG = (AngleC + AngleF) / 2
#AngleF = 180 +AngleF
#AngleC = (90 * myBezPointNumber)
#Angle = Blender.Mathutils.AngleBetweenVecs (SideA, SideB)
#print"BezNumber: %s" % myBezPointNumber
#print"AngleC: %s" % AngleC
# make 3 BezTriples, and mke sure their handles are FREE
# pass eacch of these 3 new BezTriples for X, Y and Z
# to their relevant IPO's
#myIPOCurvePitch = Blender.BezTriple.New(myCurrentPathLen - myHandleIter, Angle, 0, myCurrentPathLen, Angle, 0, myCurrentPathLen + myHandleIter, Angle, 0)
#myIPOCurveRoll = Blender.BezTriple.New(myCurrentPathLen - myHandleIter, Angle, 0, myCurrentPathLen, Angle, 0, myCurrentPathLen + myHandleIter, Angle, 0)
myIPOCurveYaw = Blender.BezTriple.New(myCurrentPathLen - myHandleIter, AngleF / 10, 0, myCurrentPathLen, AngleG / 10, 0, myCurrentPathLen + myHandleIter, AngleC / 10, 0)
#myIPOCurvePitch.handleTypes = (Blender.BezTriple.HandleTypes.FREE, Blender.BezTriple.HandleTypes.FREE)
#myIPOCurveRoll.handleTypes = (Blender.BezTriple.HandleTypes.FREE, Blender.BezTriple.HandleTypes.FREE)
myIPOCurveYaw.handleTypes = (Blender.BezTriple.HandleTypes.FREE, Blender.BezTriple.HandleTypes.FREE)
#myIPOCurveRot_X.append(myIPOCurvePitch)
#myIPOCurveRot_Y.append(myIPOCurveRoll)
myIPOCurveRot_Z.append(myIPOCurveYaw)
Everything behind the '#' symbol is commented out
atan2 works just the same as Microsoft Excel, takes two numbers, and returns an arc tangent in Radians,
And works also in the normal way if trigonometry X axis divided by Y axis or Adjacent divided by the Opposite
This is an example of how Blender see it
The vectors are set into the BezTriple and sent to the IPO window
It goes,
Frame Number, Value, Zero
Frame Number, Value, Zero
Frame Number, Value, Zero
The way I have set it up is
Frame Number for Handle 1, Value from Knot, Zero
Frame Number for Knot, Knot value is some calculation based on the other 2 handles, Zero
Frame Number for Handle 2, Value from Knot
And the handles are set to free and unconstrained
Added to the problem, is that I don't know what the angle is referenced to when at Zero, it could be Y or X
So the real question is, without using a cubic polynomial algorithm (because Blender is already doing that), what will the Algorithm be to get the object to rotate as it is following the curve at an point in time, but using as few keyframes as possible, eg, a 3 knot curve will have 2 segments and 3 keyframes that spans 120 frames or 4 seconds?
The first keyframe will alwyas be 1 and the first handle rejected, unless its used for a cyclic path.
I think that is all I can think of to describe what I am doing