Jump to content

Dear Visitors

If your confirmation email doesn't arrive, give us some time while we manually approve your account. Support ticket is not necessary, we are checking new registrations regularly and approving if registration requirements are met.

Please read Rules & Guidelines before posting around Forums. Information we seek is minimal and in the end saves us a lot of time and we are able to provide solutions faster.

Please consider supporting us via Contributions for all the work we are doing. Contributing even with the smallest amount, will remove ALL AD's and unlock some nice features like being able to be Tipped for providing help, or file etc.


Angle difference between 2 matrices


Sandidolsak
Go to solution Solved by srek,

Recommended Posts

I don't get any video, so - what are you exactly trying to do?

 

An angle in space is defined between two vectors, so you could get that angle between e.g. the x axes of the matrices. No idea whether you can use that. Or you calculate the transformation matrix between the two matrices, and take the HPB rotation of that transformation. Or you find the rotational axis (if there is one) that allows the matrices to be rotated into each other (I'm actually not sure whether that is mathematically always possible right now). Or you use quaternions.

etc pp

 

Link to comment
  • Customer

Hm the link works fine here, this is the file from the description

dropbox.com/s/irhnbnqt737cjm2/speed%20to%20weight%20v2.c4d?dl=1

He made a python effector that changes weight on velocity, I am trying to convert it to angle based instead (faster rotation = more weight)

Tried converting matrixes to hpb then using VectorAngle to get the difference, then via quaternions, but couldn't get the result.

Link to comment
  • Customer

Check the python effector at line 35:
 

speed = (mx[i].off-p_mx[i].off).GetLength()


Here he calculates the weight, mx is current matrix, p_mx is matrix on previous frame, he calculates the difference in position.
I would like to change this to get the difference in the angle between this 2 matrices.

Here I made an example with 1 clone it simply rotates, it should be white at the start, then red when it spins, and white again when it stops. The code is still original.

rotation to weight v1.c4d

Link to comment

Dot product gives you the cos of an angle between two vectors. To get the angle you have to normalize the vectors and use acos on the result of the dot product.

Standard matrices have normalized components if you haven't scaled anything, so normalize is not neccesary in the attached version of your scene

rot_diff_0002.c4d

Link to comment

Wired, it works for me. Due to the animation values on the cube the angle differences between frames are actually pretty small, you need to watch the numeric values to see real differences, the hues of red are nearly identical.

Link to comment
  • Solution

I adjusted the ranges so the angle differences become more pronounced. I also changed the animation values to emphasize what happens. Check especially between frame 49 and 68, where the rotation happens around the axis used to determine the angle resulting in no detected change. If you want to detect every change you need to set this up for all axis and combine the results.

rot_diff_0003.c4d

Here is another version that uses all three axis

rot_diff_0004.c4d

And for good measure, a version that uses all three to create RGB directly. Dark gray, no rotation, white, rotation around all axis.

rot_diff_0005.c4d

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Copyright Core 4D © 2021 Powered by Invision Community