Animations - Creating a Curve2IPO wizard

Re: Animations - Creating a Curve2IPO wizard

Postby Grogyan » Wed Sep 17, 2008 10:20 pm

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 :D


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
Image

In Blender its more detailed
Image

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

Image
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
Attachments
Angles.png
Angles.png (22.66 KiB) Viewed 5214 times
Better to have loved and lost than never to have loved at all
User avatar
Grogyan
 
Posts: 1203
Joined: Thu Oct 11, 2007 1:27 am

Re: Animations - Creating a Curve2IPO wizard

Postby Grogyan » Sat Oct 04, 2008 8:18 pm

Aspirin please?

I am still no further along, google isn't helping much either

I have just finished reading this article on bezier splines
http://www.gamedev.net/reference/progra ... av_bezier/

And now my head is pulsing with pain :P Image

There doesn't seem to be much info on extracting any rotational data from a bezier spline on the web


I could do with some suggestions, please?
Better to have loved and lost than never to have loved at all
User avatar
Grogyan
 
Posts: 1203
Joined: Thu Oct 11, 2007 1:27 am

Re: Animations - Creating a Curve2IPO wizard

Postby Trylon » Sun Oct 05, 2008 5:51 am

Sorry, can't seem to get my head around it either....

Though as to rotation - it seems to me that you'd need to use the tangent line of any given point on the curve in order to calculate its rotation.

Once you have the tangent line you should have a base for rotations.

EDIT:
Wait a second, since the line between handle and knot is effectively the tangent line of the knot, can't you use that to establish rotation?
One day I ran through the cleft for the fiftieth time, and found that uru held no peace for me anymore.
User avatar
Trylon
 
Posts: 1446
Joined: Fri Sep 28, 2007 11:08 pm
Location: Gone from Uru

Re: Animations - Creating a Curve2IPO wizard

Postby Grogyan » Sun Oct 05, 2008 10:07 pm

When I first read your post Trylon I thought that was what I was trying to do in the first place, but then I followed that linky to wiki and found I was wrong :P as usual

Still I have read through it like 5 - 10 times and I still don't quite understand what they are talking about tangent lines on a curve - some basic math that missed me at high school maybe or I never did because I didn't do 6th form math lol

So what I have done, is create a new curve that is a bezier circle, and using that as a reference to see if the rotations will work , if they ever will.

So if I understood that wiki, the tangent intersection the knot is as you say the point of tangency and the handles the line which it continues through, so i am guessing here that they mean that the line is hypotenuse of the tangent intersect and handle, which is what I am trying to achieve with the arc tangent function.
I think I saw an equation for the slope or gradient using just vectors, in a math book I was attempting to study, is this the same thing as that tangent line?
Better to have loved and lost than never to have loved at all
User avatar
Grogyan
 
Posts: 1203
Joined: Thu Oct 11, 2007 1:27 am

Re: Animations - Creating a Curve2IPO wizard

Postby Grogyan » Tue Oct 07, 2008 9:58 pm

I had a wee thought today when I was at work, that perhaps why its not working out so well is that its missing a vector.

Right now its just getting the "tangent lines"? but without a rotation to add with.

So I thought that maybe the best thing to do would be to use the knots as that extra set of vector variables, but the problem I see with this is when either X = 0 or Y = 0, how to tell the script that you want say to turn right by 90 degrees.


One thing I have noticed with this is that I am going nutty, lines, curves, circles, tangents, all making my head spin daily
Better to have loved and lost than never to have loved at all
User avatar
Grogyan
 
Posts: 1203
Joined: Thu Oct 11, 2007 1:27 am

Re: Animations - Creating a Curve2IPO wizard

Postby Grogyan » Thu Oct 09, 2008 8:38 pm

Still thinking, I realised that there is a major flaw in the plan to iterate angles with arc tangent, that is you can't get a result if an angle is 90 degrees.

That means that i'll have to use arc sine and arc cosine functions, reason for using both is that you still have to consider what happens when either X or Y = 0, and what you would effectively have is a straight line with 3 points or do I?, its been awhile since I had to do trig, so I am questioning my logic more.
Like if I follow this path of logic how would I quantify angles larger than 180 degrees?

Which now means that I have to add yet another algorithm, one that everyone knows
c.c = (a.a)+(b.b)
Then do regular secant trig to find the angles correlating to the (tangent?) line.
Better to have loved and lost than never to have loved at all
User avatar
Grogyan
 
Posts: 1203
Joined: Thu Oct 11, 2007 1:27 am

Re: Animations - Creating a Curve2IPO wizard

Postby Paradox » Sat Oct 11, 2008 2:29 pm

Pythagorean Theorem is great for right triangles (with a 90° angle in one corner). But the expanded cosine law is probably better if you have non-right triangles.

a,b,c are angles
A,B,C are lengths of sides. Length A is opposite to angle a.

C² = A² + B² + (2 × A × B × cos(c))
Paradox
 
Posts: 1290
Joined: Fri Sep 28, 2007 6:48 pm
Location: Canada

Re: Animations - Creating a Curve2IPO wizard

Postby Grogyan » Sat Oct 11, 2008 6:32 pm

I know that formula, I had it in my text book somewhere, now I just have to find that book ha ha, because it has to adaptively understand what the angle is, both acute and obtuse.

Thanks Paradox, i'll look into it.
Better to have loved and lost than never to have loved at all
User avatar
Grogyan
 
Posts: 1203
Joined: Thu Oct 11, 2007 1:27 am

Re: Animations - Creating a Curve2IPO wizard

Postby Grogyan » Sun Oct 19, 2008 8:49 pm

An update on this project,
Sorry Paradox, that equation won't work.

I can see this going either,
reconfiguring the equation for a b-spline to determine the angles,
or do a boolean check on the positive or negative portion of either X or Y axis to force a direction, problem with this idea, is how would you force it it the other direction?
or leave this project, and leave it for someone else who is a lot smarter than me to figure it out

My plan to tackle it with the right angle rule would work, the only case which it doesn't is when the curve has any straight bits ie, the handles and or last and current control point lay on the same gradient ie X or Y = 0, which isn't good enough that's why its taking so damn long to do, this problem will inevitably will come up, and it would be a very VERY nasty bug, not unlike the other bug which i'll fix when this rotations set is done
Better to have loved and lost than never to have loved at all
User avatar
Grogyan
 
Posts: 1203
Joined: Thu Oct 11, 2007 1:27 am

Re: Animations - Creating a Curve2IPO wizard

Postby Grogyan » Mon Oct 20, 2008 11:35 pm

been thinking about this idea all day, and it almost seems viable
Image
Consider each individual segment with 2 knots and 2 handles going from left to right (but ignore in the above example the far left handle and the far right hand side handle) calling them Knot 1 and Handle 1, Knot 2 and Handle 2, then I can say that there is a relationship of these vectors to one another in terms or circular quadrants eg 4 slices of cake and you know where to place the knife to start then next cut and where it will end, and want to know what size of piece your cutting

Breakdown
Get the Last Knot and compare with Current Knot
if KnotX/HandleX in + + Quadrant
if KnotX/HandleX in - + Quadrant
if KnotX/HandleX in - - Quadrant
if KnotX/HandleX in+ - Quadrant

And align itself as the forward bias
then do the same as stated above for Handle 1 of Knot 1
Then Handle 2 for Knot 2

then just use 1/sine for angles and add to last rotation and add the handle angles based on their relationship of the forward bias

I am only worried about how to attribute the previous segment to the current, maybe its just easier to forget about it and consider it on a per segment basis

Yeah I had huge headache today even thinking about it, I don't blame anyone for not following
Better to have loved and lost than never to have loved at all
User avatar
Grogyan
 
Posts: 1203
Joined: Thu Oct 11, 2007 1:27 am

PreviousNext

Return to Grogyan's Journal

Who is online

Users browsing this forum: No registered users and 0 guests

cron