千家信息网

UFUN和NXOPEN中的变换矩阵区别有哪些

发表于:2025-01-16 作者:千家信息网编辑
千家信息网最后更新 2025年01月16日,这篇文章主要介绍UFUN和NXOPEN中的变换矩阵区别有哪些,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!UFUN中用于实体变换矩阵的函数为:UF_MODL_transform
千家信息网最后更新 2025年01月16日UFUN和NXOPEN中的变换矩阵区别有哪些

这篇文章主要介绍UFUN和NXOPEN中的变换矩阵区别有哪些,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

UFUN中用于实体变换矩阵的函数为:
UF_MODL_transform_entities
NXOPEN中用于装配组件变换矩阵的类为:
ComponentNetwork
它们的变换矩阵方式是不同的,前者为动态变换,后者为静态变换。
动态变换求法:

            var invert = Current.Inverse();            var trans = invert.Multiply(position);

静态变换求法(先旋转后平移):

            var cur = Current;            cur.Transpose();//转置            var pos = position;            pos.Transpose();//转置            var trans = cur.Inverse().Multiply(pos);            var rotation = trans.UpperLeft.ToMatrix3x3();            trans.Transpose();            var translation = trans.Translation.ToVector3d();

分享下我的两个移动相关的类(部分相关类没有提供):

public class MoveComponentBuilder    {        #region Constructors        protected MoveComponentBuilder()        {            var workPart = theSession.Parts.Work;            _positioner = workPart.ComponentAssembly.Positioner;            _netWork = (ComponentNetwork)_positioner.EstablishNetwork();        }        public static MoveComponentBuilder Create(List components, Matrix44 matrix)        {            var mCompBuilder = new MoveComponentBuilder();            mCompBuilder.Current = matrix;            mCompBuilder.HomePosition = matrix;            mCompBuilder.Components.AddRange(components);            mCompBuilder._netWork.SetMovingGroup(components.ToArray());            mCompBuilder._netWork.MoveObjectsState = true;            return mCompBuilder;        }        public static MoveComponentBuilder Create(List components,SpecifyOrientation manip)        {            var mCompBuilder = Create(components, manip.GetPosition());            mCompBuilder.Manip = manip;            return mCompBuilder;        }        #endregion        #region Fields        private Positioner _positioner;        private ComponentNetwork _netWork;        private Session theSession = Session.GetSession();        #endregion        #region Properties        public Matrix44 Current { get; protected set; }        public Matrix44 HomePosition { get; protected set; }        public List Components { get; protected set; } = new List();        public SpecifyOrientation Manip { get; protected set; }        #endregion        #region Methods        public void Move(Matrix44 position)        {            var cur = Current;            cur.Transpose();//转置            var pos = position;            pos.Transpose();//转置            var trans = cur.Inverse().Multiply(pos);            var rotation = trans.UpperLeft.ToMatrix3x3();            trans.Transpose();            var translation = trans.Translation.ToVector3d();            _netWork.BeginDrag();            _netWork.DragByTransform(translation,rotation);            _netWork.EndDrag();            Current = position;        }        public void BackHome()        {            Move(HomePosition);        }        public bool Update()        {            if (Manip==null)            {                return false;            }            Move(Manip.GetPosition());            return true;        }        public bool UpdateManipOnly()        {            if (Manip==null)            {                return false;            }            Current = Manip.GetPosition();            return true;        }        public void Apply()        {            _netWork.Solve();        }        #endregion    }
public class MoveObjectBuilder    {        #region Conductor        protected MoveObjectBuilder() { }        public static MoveObjectBuilder Create(List objs, Matrix44 matrix)        {            var mObj = new MoveObjectBuilder();            mObj.Current = matrix;            mObj.HomePosition = matrix;            mObj.Objects.AddRange(objs);            return mObj;        }        public static MoveObjectBuilder Create(List objs, SpecifyOrientation manip)        {            var mObj = Create(objs, manip.GetPosition());            mObj.Manip = manip;            return mObj;        }        #endregion        #region Fields        private static UFSession theUfSession = UFSession.GetUFSession();        private static Session theSession = Session.GetSession();        #endregion        #region Properties        public List Objects { get; protected set; } = new List();        public Matrix44 Current { get; protected set; }        public Matrix44 HomePosition { get; protected set; }        public SpecifyOrientation Manip { get; protected set; }        #endregion        #region Methods        public void Move(Matrix44 position)        {            var invert = Current.Inverse();            var trans = invert.Multiply(position);            theUfSession.Modl.TransformEntities(                Objects.Count, Objects.ToArray(), trans.ToArray());            Current = position;            theUfSession.Modl.Update();        }        public void BackHome()        {            Move(HomePosition);        }        public bool Update()        {            if (Manip == null)            {                return false;            }            Move(Manip.GetPosition());            return true;        }        public bool UpdateManipOnly()        {            if (Manip==null)            {                return false;            }            Current = Manip.GetPosition();            return true;        }        #endregion    }

演示:

以上是"UFUN和NXOPEN中的变换矩阵区别有哪些"这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注行业资讯频道!

0