Can you adjust the "strength" of a transformation?
-
Say that you have a method that accepts a
Transformation
object. The type of transformation is unknown, it could be move, scale, rotate etc.Can you adjust the "strength" or magnitude of the transformation's effect? So if the given transformation was a scaling transformation of 200% in the Y axis you could make it n% of the input transformation? Can you weaken or strengthen an arbitrary transformation without knowing if it's scaling, rotating, translating or a combination?
-
Hardly... unless you already know the transformation type/factors ?
Then 'interpolate' ??You can perhaps extract the rotation, scaling etc and make a 'new' transformation based on it ?
If you make a scaling transformation 'trs' at say 1% then trstrs is 2%
Or A rotation 'trr' at 1 degree, then trrtrr is 2 degrees etc...
or
tr0=Geom::Transformation.new()
trn=Geom::Transformation.interpolate(tr0, trs, 0.5)
should return a scaling transformation 'half' of the original 'trs' ?
BUT I don't think
trn=Geom::Transformation.interpolate(tr0, trs, 2.0)
will work for 'twice'... -
Shouldn't it be possible by interpolating the transformation with an identity transformation?
I did a quick test, but the API method Transformation.interpolate didn't work for me, so I wrote my own
**```
def interpolate(t1,t2,percent);a=t1.to_a;b=t2.to_a;c=[];16.times{|i| c[i]=percent*a[i]+(100-percent)*b[i]};return Geom;;Transformation.new(c);end
-
This is a clever way to interpolate all values but if you just want to interpolate the rotation it will also scale etc ?
If the base tr is un-scaled 1,1,1 and the second tr is scaled in the X -1,1,1 - then won't it try to use an invalid scaling factor of 0,1,1 for the interpolation of '50%' ? -
I´m writing a small utility to visualize transformations to aid me understand what is going on. I can´t manage to visualize what will happen because I don´t have enough understanding of the matrix.
-
@tig said:
You can perhaps extract the rotation, scaling etc and make a 'new' transformation based on it ?
You mean extract the rotation, scaling and translation to separate transformation - apply the wanted "strength" and then combine them?
-
Just to clarify, all transformations are either move, scale, rotate - but I do not know what it is. And the transformation all have a custom origin - so rotation is around a given 3d point and axis and scale is around a 3d point.
-
The object's 'position' is relatively easy to find - it's just the
t=object.transformation.to_a
for the xyx point as an array of the last few elements thus:point=[t[-4],t[-3],t[-2]]
... ORtransformation.origin
!
The transformation's scale and rotation interact with each other, so they are much more complex to extract from the transformation array... but not impossible - there are already some earlier post discussing this...
Advertisement