geom.Matrix3D.interpolate and interpolateTo * possible bug... #3506
Replies: 7 comments 7 replies
-
I confess I'm struggling to follow the logic here to work out exactly what you think is going wrong.. In terms of the normalisation: this is mentioned in the documentation for
In practice, all of the ActionScript calls end up in the same underlying geometry classes doing the same calculations, so there should be the same result whether you call the static or member versions, and whether you pass in an output value or not. One warning: it's possible that the But then .. the maths involved here is basically:
Not sure if any of those stages might be going wrong .. if there's a worked example we can put in some output at each stage to show what's happening. The slerp has some threshold condition but that's not limiting things with the values you have here.. For that Going back to your original example, I think what you are trying to demonstrate is
Looking at it again - there may be an issue with the "to quaternion" method when the normalisation is happening. Essentially we have a quaternion value that we get initially from the "from" matrix, and the slerp is essentially a no-op, but when we set up the matrix using this quaternion value, it's different. If we then calculate the quaternion again, we get the same as before, and this time if we set up the matrix again using this value, it doesn't change i.e. it's different from the original matrix but we've hit a steady state. As I understand it, we should essentially be able to do to:
The original "to quaternion" function matches the code that's here, at least for the case it's hitting (positive 'tr') - it's structured a little differently and optimised to avoid division, but otherwise looks the same. But then the normalisation happens.. and then we set up the new matrix from this. We'll try to dig a bit more into this ...! but if you have any step-by-step or reference code, it would be handy :-) thanks |
Beta Was this translation helpful? Give feedback.
-
correct, with a value zero we must get the inital quaternion from the first matrix... (the quaternion must be identically) i have here a decompose method, which basically should do what flash does...
the problem in interpolate is that it does not do it in this way... i think the interpolate method implements its own decompose logic which goes wrong... |
Beta Was this translation helpful? Give feedback.
-
i've already created a interpolate version which is identical when scale is 1,1,1
|
Beta Was this translation helpful? Give feedback.
-
thats a good question... if you want to bring in scale again and don't want to break existing projects, i would suggest to add an additional optional parameter function interpolate(from : Matrix3D, to : Matrix3D, ratio : Number, corrected = false) : Matrix3D and by the way also in the Utils3D.pointTowards method, which also uses this interpolate method (scale gets removed)
i've created a visual demo in flash cs 5.5 which includes a demo for the interpolate problem... once finished the code would end up in ruffle and openfl (i hope...) demo1 does apply scale
i use Windows 11 |
Beta Was this translation helpful? Give feedback.
-
i think if the routine adds this, the quaternion would be identical to my version... and this wouldn't break much from the compatibility...
you are right, it would be more correct... i've implemented a more cleaned up version here additional last parameter correct by the way... thx for your time... |
Beta Was this translation helpful? Give feedback.
-
Honestly, I don’t have much knowledge about the Flash internals. I was just glad that my rusty ActionScript still worked. Ideally, I would prefer to get rid of this corrected == false entirely and do it the right way. Starting from namespace 51.2, this compatibility is no longer available in this area... I think if someone had used this faulty interpolate, the common workaround at the time would likely have been to set the scaling to 1,1,1 before the interpolation without touching the tx, ty, tz parameters, and then apply the (interpolated) scaling afterward. As you already mentioned, who would even use this method if it’s so flawed? A kind of switch to enforce the old behavior might be useful—perhaps a global variable within ActionScript, for example. I can’t really say much about an XML switch, but that might also be a possibility... |
Beta Was this translation helpful? Give feedback.
-
this might be a solution see public static function get correct() and public static function set correct() |
Beta Was this translation helpful? Give feedback.
-
i have been playing arround now for about several weeks to understand how this feature works...
since it's not possible to check the native flash implemention how flash does it, i rebuild the process in actionscript and came along a weird behaviour...
the most simple testcase to reproduce the main problem...
i'm pretty sure in the meantime that the interpolate or interpolateTo does not remove the scale from the raw matrix (mr)...
the decompose in general does following tasks
a.) remove scale.x from mr[0],mr[1],mr[2]
b.) remove scale.x from mr[4],mr[5],mr[6]
c.) remove scale.x from mr[8],mr[9],mr[10]
a.) calc skew.x, remove it from the mr
b.) calc skew.y, remove it from the mr
c.) calc skew.z, remove it from the mr
to get the scale values the decompose does something like this...
so far so good...
when 3.a 3.b and 3.c are not made like this
you will get at point 5. a near correct looking x,y,z,w
(important to notice this is not a normal vector, its a quaternion)
but without 3.a, 3.b and 3.c it's not right...
the interpolation example demonstrates such a behaviour...
the returned rawData shows that the mr[0][1][2], mr[4][5][6], m[8][9][10]
do not have removed the scale.x, scale.y, scale.z
the interpolate methods need this basic decompose steps for all further calculations,
the method with scale 1,1,1 works as expected, all other scale factors result in an unexpected quaternion
which results in the end in a false calculation for all steps the interpolate does afterwards...
in most cases the effect is minimal, and the animation looks good,
but in other cases the slerp calculation results in a wrong rotation direction...
can someone confirm ?
Beta Was this translation helpful? Give feedback.
All reactions