You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have this code and trying to change the transformation of the c2 object but I cant succeed with it.
Am I doing something wrong here, or there is a something wrong in apply_transform?
from vedo import Cube, show, settings,LinearTransform
settings.use_parallel_projection = True
import numpy as np
c1 = Cube().rotate_z(25).pos(2,1).mirror().alpha(0.5)
c1.transform.print()
T = c1.transform
c2 = Cube().c('red4').wireframe().lw(10).lighting('off')
c2.apply_transform(T) ### this one works
new_transform = LinearTransform() ## or c2.transform
np_identity = np.eye(4)
np_identity[0][3] = 0.1
new_transform.matrix = np_identity
c2.apply_transform(new_transform, concatenate=False)
show(c2, "The c2 should be close to identity!", axes=1).close()
In the code above, I have changed the np_identity little bit, otherwise apply transform skip the transormation and return itself.
Also how can I reset the object's transformation and apply a matrix to an object
Many thanks in advance
The text was updated successfully, but these errors were encountered:
Thanks @smoothumut I have removed the concatenate kw in the master version.
fromvedoimportCube, show, settings, LinearTransformimportnumpyasnpsettings.use_parallel_projection=Truec1=Cube().rotate_z(25).pos(2,1).mirror().alpha(0.5)
c1.transform.print()
T=c1.transformc2=Cube().c('red4').wireframe().lw(10).lighting('off')
c2.apply_transform(T) ### this one works# new_transform = LinearTransform() ## or c2.transformnp_identity=np.eye(4)
np_identity[0][3] =0.0001# new_transform.matrix = np_identityc2.apply_transform(T.compute_inverse()).apply_transform(np_identity)
show(c2, "The c2 should be close to identity!", axes=1).close()
the best way to undo a transformation is to make a copy of the original object. Otherwise you may invert the transformation and apply this inverse.
Hi Marco,
I have this code and trying to change the transformation of the c2 object but I cant succeed with it.
Am I doing something wrong here, or there is a something wrong in apply_transform?
In the code above, I have changed the np_identity little bit, otherwise apply transform skip the transormation and return itself.
Also how can I reset the object's transformation and apply a matrix to an object
Many thanks in advance
The text was updated successfully, but these errors were encountered: