### Season 00 Day 6 – Theory and Applied vectors, IK pedals

“More on vectors while we actually show some application, and eventually make it to hooking up the pedals’ geo to the IK pedals control in the niche of time”

“Day 6, crash course in vector math, sprinkle of matrix math, and finally, applying in Maya. IK pedals connected to the geometry in the niche of time.”

continuing from last video cult-rig-season-00-day-005-vectors

## Quick catch up:

- Shout out to
*animBlendNodeAdditiveRotation*for angle connections without unitConvert nodes. **Pythagorean theorem**reminder for dealing with vector length- |V| or ||V|| is how you might see will be an absolute length of a vector, if you read about vectors in math books
- a unit vector is the vector compressed in to a 0 to 1 range

if you want to scale it, normalize it first then * by value to scale it up to be longer.

## How to do this with nodes: Vector scale and playing with vector math.

- create a control transform group “pedal_ik_ctrl”
- Add a cone polygon primitive
- Connect the ik control to drive the cone
- create the node
**vectorProduct** - connect ik translate to node input and go output to the cone translate.
- set the
**vectorProduct**attribute normalize output this crates a “follow” that is limited to a range of 1 and set to “no operation” because we only want the value normalized.

- create the node

## How do we create the Math with only nodes?

- interesting tip that comes up later: If you have two vectors and normalize them then do dotProduct you get the angle between them
- Create a spherical constraint with just vector math(13:29)
- ik ctrl node translate – vector Product-translate of target
- To control the length is multiply the vectorProduct by a value with a multiplydivide node before the target translate.
- If you want to lock this sphere to a single plane you need to set the axis in the mitiplyDivde node to zero.

### Need to control this effect or build on.

- dotProduct
- ||a|| *||b||* cos – if you have two normalized vectors multiplied by COS gives you an angle.
- If your vectors are aligned (angle zero) the COS of that angle is going to be 1
- ||b|| * COS normalized gives you the magnitude(length) of the vector

- So with out a “length node” in Maya we can use the
**vectorProduct**node- pedal_ik_ctrl.translate out to vectorProduct 1 node (normalizing the value no operation) -out to vectorProduct 2nd node input 1
- pedal_ik_ctrl.translate out to vectorProduct 2 node input 2 (with no normalizing set to dotProduct)

- We get the result of the length of the vector
- Condition node (if length of first vector in to “first term” ) is greater than 3 (then we want the reScaled vector from multiplyDivde node “second term” )

multiplyDivide.output – Color if true.

otherwise if the length is less than, use the pedal_ik_ctrl translate.

Then take**condition.out**to the**cone.translate.** - This creates an “IK” like behavior by creating a limited range

## RIGGING : Back to rigging the bike pedals

Raf now uses what he just worked through with the vectors to create the rigging. And updates the names of the nodes.

- pedals_M_pedal_IK_ctrl_srtBuffer
- pedals_M_pedal_IK_ctrl

- pedals_M_pedal_IK_ctrl. translate->vectorProduct (no operation) – multipleyDivide

We want to have our **pedals_M_pedal_ik_ctrl_srtBuffer** end up in the same space as the the **pedal_Mstaff_ctrl_srtBuffer** + an offset

- parent
**pedals_M_pedal_IK_ctrl_srtBuffer**under pedals_M_cmpnt-**control** - world2Pedals_offset_srt->
**wheel_M_main_ctrl_wMtx_output_fNode2**-> pedals_M_pedal_IK_ctrl_srtBuffer - create a new node
**staff2pedals_offset_srt**that is a child of**pedals_M_cmpnt- input- world2pedals_offset_srt**(rename name to**world2staff_offset_srt**) **staff2pedals_offset_srt**world matrix out- to new decomposeMatrix node**wheel_M_main_ctrl_wMtx_output_fNode3-**srt out to**pedals_M_pedal_IK_ctrl_srtBuffer**

Now the IK control starts in the same place as the FK

At this point Raf also digs in to Matrix math (1:00hr) to setup the information needed to create context to the nodes and rigging that he needs to do to make the IK buffer work in the rig.

*Maya uses row matrices, reading top to bottom across the matrix 1,0,0,0 x 0,1,0,0 y 0,0,1,0 z 0,0,0,1 (w) displacement from world 0,0,0

## Continue the rig

- world2staff_offset_srt
- pedals_M_peal_IK_ctrl

New node time ( **multiplyMatrix** )

Take the inverse matrix from world2staff_offset_srt ->multMatrix.Matrix In[2]

and pedals_M_peal_IK_ctrl.worldMatrix to ->multMatrix.Matrix In[1]

Now decompose the multMatrix output and drive a sphere for visualize the output of the offset we now need in order to drive our pedals.

delete it and create a cone.

parent the code under the **world2staff_offset_srt** for visualization of the pivot.

- multMatrix-decompose->and attach it to the translate/rotate to check that your offset goes to the pedal location.

But we need rotations, not translate

- create vectorProduct and set it to
**no operation** - Dot product can give you both projection and angle of the vector.
- New node (angle between)
- multMatrix-decompose-Y and Z in to the angle between vector Y.Z and then angle.euler out to the cone to show rotation. of only Y and Z, keeping X from solving and creating a flat plane of rotation
- To invert the value push the Euler out to
**animBlendnodeAdditiveRotation**and – the weight so you can get the rotation angle in the direction you need. - To do the final rig hook up between the IK and FK using the existing
**animBlendnodeAdditiveRotation**node, take and pedals_M_staff_Ctrl (our fk rig) .Rotate into**animBlendnodeAdditiveRotation.inputb** **then**animBlendnodeAdditiveRotation.**Output**– to Deform-**pedals_M_pole_srt**

- Now the weight value on the animBlend node will mix between the IK or FK rig system.

## What does this give us?

- A rig that doesn’t depend on hierarchy
- no relationships with layers of constraints because the rigging is managed with pure math and in the DG not in the hiearchy.
- A deeper understanding of what Maya is managing behind the scenes when you are doing constraints and parents etc in the DAG.

**Get i****nvolved:**

Follow Raf on twitter for announcements and news

https://twitter.com/ThE_JacO

Follow the Streams live on Twitch

https://www.twitch.tv/cultofrig/

Subscribe and watch past broadcasts

Cult of Rig -YouTube

And keep up to date with news on the website

http://www.cultofrig.com