Tip:
Highlight text to annotate it
X
Introduction to ICE kinematics. Part 06 - Point to cluster constrain
In this tutorial we will create "Point to cluster constrain"
Such constrain attach one object to a cluster on another object
Let's create sphere
Null
And will do so this null attach to a cluster on this sphere
For this...
Add a cluster
Next we should find coordinates of all cluster's points
Cluster has only two attributes
Here is attribute, which say is point on the cluster or not
For finding coordinates of the cluster's points we take coordinates of all sphere's points
This is attribute "PointPosition"
And then use the node "Filter"
This node pass only values with "true" in the port "Keep"
These are exactly points of a cluster
Next we should construct an array from obtained set
Because we get some values with context "per point"
Next we find average of this array
Ok, obtained value is a center point of a cluster
But these coordinates are coordinates in a sphere's local coordinate system
And we need global coordinates
As we know, we can find it by multiplying coordinates to the transform matrix of a sphere
Take this matrix
Kinematics... Global transform
And multiply vector to this matrix
Obtained value is a global coordinates of cluster center
Next we should find a point in the sphere, closest to previous one
For this we use "Get Closest Location"
And find the closest point on the sphere
But not by using our previous point
Because for node "Get Closest Location" the position should be in the local coordinate system of the null
That's why we should translate coordinates of a point to the local coordinate system of the null
For this we should multiply the point to matrix, which inverse to the transform matrix of the null
Get the transform matrix
Of our null
Find inverse
And multiply...
Obtained vector to this matrix
Ok, we obtain the same point but in nulls's local coordinate system
And set it to "Position"
We obtain location in a null's local coordinate system
Translate it to a global coordinate system
Extract "PointPosition"
And translate to global coordinate system by multiplying this value to transform matrix of a null
Next with the help of "SRT To Matrix" set this value as a position in space
And set the matrix to global transforms
We see that null jumps to the center of the cluster
Now, when we rotate the sphere, the null placed in the center of the cluster
But we see that null keeps his initial orientation
Because we not calculate his rotation
Let's translate "Scale" without changes
Let's calculate the rotation of the null
We need to attach null to the sphere
So, we will be use the local coordinate system of a polygon
With the closest point to the cluster's center
This local coordinate system holds in the attribute
"PolygonReferenceFrame"
The value of this attribute is a 3x3 matrix
Let's visualize it
Numerically
Here is this matrix
Rows of this matrix are coordinates of local bases vectors
This matrix is a matrix in null's local coordinate system
Really, when we rotate the null, we change the local coordinate system and matrix is changed too
We need...
Translate each vector from this matrix to global coordinate system
For this separate matrix to vectors
With the help of node "3x3 matrix to 3d Vector"
Here we should translate each vector to the global coordinate system
By multiplying to the null's transform matrix
Instead of doing it for each vector separately
We construct a 4x4 matrix
And multiply it to the transform matrix
Here we translate vectors one-to-one
This translation mean...
Which basis vector of null's local coordinate system we place along basis local vectors of the polygon
In this case it means that local Ox directed along polygon's Ox and so on
If we need other alignment, we can connect ports in other order
Next multiply obtained matrix...
The fourth row is unimportant for us
Multiply our matrix to the transform matrix of the null
Next we need...
Extract the rotation from this matrix
Because we need only the null's rotation
We do this with the help of "Matrix to SRT"
This node extract the rotation
Ok, now, when we rotate the sphere
We see that our null placed in fixed orientation with respect to the polygon
It scales himself, but not translate and rotate
Out lesson is over