View Full Version : I was no good at Math at school and still arent!
Mattrne 04 April 2008, 01:15 PM Part of my brain is telling em that logically I should be able to do this so hopefully someone out there will be able to help!
I currently have a reaction manager driven proof of concept which take the X rotation of the clavicle bone and drives the X rotation of a cube.
I have 2 states, which are the clavicle bone in its X axis, with slave values which are the rotation of the cube on its X axis. The values are as follows;
State01 = 27.516 (lets call this A)
cube rotation X = 18.687 (lets call this B)
State02 = 65.838 (lets call this C)
cube rotation X = 8.487 (lets call this D)
Now I am trying to see if i can convert this into an expression so I can get it working in our engine, but no matter how much trawling through high school math websites I cant seem to find a way to figure this out!
I wish I had actually understood and concentrated at school now rather than thinking about going home and playing wing commander ;)


drdubosc
04 April 2008, 02:07 PM
Assuming a linear relationship between State and CubeRotaion (i.e. CubeRotation = State*x+k), then the simultaneous equation solves as:
CubeRotation = (State*0.10926)+15.6806
Mattrne
04 April 2008, 02:13 PM
Great thanks for that! :)
Can I ask how you calculated X and K?
i want to really get my head around this because I expect I will use this a lot!
drdubosc
04 April 2008, 03:26 PM
Can I ask how you calculated X and K?
Assuming State*x+k = Rotation we are given:
eq1: 27.516*x + k = 18.687
eq2: 65.838*x + k = 8.487
and therefore:
eq3: (eq1  eq2) 93.354*x = 10.2
eq4: (eq3 / 93.354) x = 0.10926
eq5: (substitute x into eq1) 3.0064 + k = 18.687
eq6: (eq5  3.0064) k = 15.6806
sorry, tried to get it to line up, but don't know how to do that ...:)
drdubosc
04 April 2008, 04:57 PM
This maxscript fn uses Cramers Rule (http://en.wikipedia.org/wiki/Cramer's_rule)to solve equations in the form:
ax+by=e
cx+dy=f
returning x and y in an array.
fn solveSimul2 a b e c d f = (
TODO: needs an escape clause for a*d==b*c
in which case no unique solution
#((e*db*f)/(a*db*c),(a*fe*c)/(a*db*c))
)
 example, finding x & k in your problem:
 (b & d are both 1 in this case)
solveSimul2 27.516 1 18.687 65.838 1 8.487
which returns #(0.109262,15.6806)
Mattrne
04 April 2008, 05:34 PM
Cool I'll have a look at that. I just got this working with the following;
masterBone = $Bone_L_Clavicle
elr = quatToEuler masterBone.rotation order: 1
lcX = elr.x as float
lcY = elr.y as float
lcZ = elr.Z as float
a_x = 1.814 this is state01 value
b_x = 9.247 this is driven value of state 1
c_x = 34.161this is state02 value
d_x = 17.247 this is driven value of state02
mforx = (b_xd_x) / (a_xc_x)
nforx = b_x  (mforx * a_x)
outputx = (mforx * a_x + nforx)
a_y = 1.814this is state01 value
b_y = 5.1this is driven value of state 1
c_y = 30.501this is state02 value
d_y = 5.1 this is driven value of state02
mfory = (b_yd_y) / (a_yc_y)
nfory = b_y  (mfory * a_y)
outputy = (mfory * lcy + nfory)
a_z = 27.516 this is state01 value
b_z = 18.687 this is driven value of state 1
c_z = 65.838 this is state02 value
d_z = 8.487 this is driven value of state02
mforz = (b_zd_z) / (a_zc_z)
nforz = b_z  (mforz * a_z)
outputz = (mforz * lcz + nforz)
pecRotX = outputX
pecRotY = outputY
pecRotZ = outputZ
value = inverse (eulerToQuat (eulerangles pecRotX pecRotY pecRotZ) order:1)
This now perfectly mirrors my test setup which was done via reaction manager. Thanks so much for all your help on this one :)
drdubosc
04 April 2008, 05:43 PM
Beat me to it! :thumbsup:
eek
04 April 2008, 06:13 PM
Could we use linear interpolation too?
t = 27.516  the shoulder rotation.
n = abs((27.516  t) / (65.838  27.516))
(1n)*18.687 + 8.487 * n  output sent to cube.
drdubosc
04 April 2008, 06:38 PM
Could we use linear interpolation too?
t = 27.516  the shoulder rotation.
n = abs((27.516  t) / (65.838  27.516))
(1n)*18.687 + 8.487 * n  output sent to cube.
Of course! ..... what we need from you, eek, is how to put the eases in! :twisted:
eek
04 April 2008, 06:59 PM
Of course! ..... what we need from you, eek, is how to put the eases in! :twisted:
Lol  maybe easier, but a little quicker. Wondering what this would do with more states  seems reminicent of a polynormial..
CGTalk Moderation
04 April 2008, 06:59 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.