Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Navigation
- Solid Edge
- Forums
- Blogs
- Knowledge Bases

- Siemens PLM Community
- Solid Edge
- Solid Edge Developer Forum
- Matrix methods

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Matrix methods

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-03-2014 02:55 PM

The occurrence class has a method GetMatrix() which gives a matrix for converting from part coordinates to assembly coordinates and back. But this yields a 16 array, and I see no methods for using this matrix. Given there are different ways it could be encoded, I hope somewhere there are methods for multiplying these matrices together, and transforming points. Anyone?

------------------

Alan Baljeu

Owner, Cornerstone Intelligent Software

Developer of custom CAD software

Alan Baljeu

Owner, Cornerstone Intelligent Software

Developer of custom CAD software

6 REPLIES

Re: Matrix methods

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-08-2014 05:23 AM

Alan,

I am by no means a matrix expert but I do know there are plenty of 3rd party libraries for handling matrices. Solid Edge leaves it up to you to choose the library of your choice or roll your own. I've worked with math gurus in the past who totally got Solid Edge matrices and had no issue working with them. They knew what they were doing though and I don't...

I threw together a small demo of 2 free libraries that I'm familar with. OpenTK & SharpGL. Again, I don't for a second pretend that I know how to use them. Just sharing what I do know.

using SolidEdgeCommunity; using SolidEdgeCommunity.Extensions; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MatrixDemo { class Program { [STAThread] static void Main(string[] args) { OleMessageFilter.Register(); var application = SolidEdgeUtils.Connect(); var assembly = application.GetActiveDocument<SolidEdgeAssembly.AssemblyDocument>(); var occurrences = assembly.Occurrences; foreach (var occurrence in occurrences.OfType<SolidEdgeAssembly.Occurrence>()) { // Allocate array. Array matrix = Array.CreateInstance(typeof(double), 16); // Get the occurrence matrix. occurrence.GetMatrix(ref matrix); // Convert Array to double[] for ease of use. double[] m = matrix.OfType<double>().ToArray(); // NuGet package id: OpenTK DemoOpenTK(m); // NuGet package id: SharpGLCore DemoSharpGL(m); } OleMessageFilter.Unregister(); } static void DemoOpenTK(double[] m) { var matrix4d = new OpenTK.Matrix4d( m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7], m[8], m[9], m[10], m[11], m[12], m[13], m[14], m[15]); matrix4d.ClearProjection(); matrix4d.ClearRotation(); matrix4d.ClearScale(); matrix4d.ClearTranslation(); // Demo of multiplying matrices. *Static method* // OpenTK.Matrix4d.Mult(left, right); } static void DemoSharpGL(double[] m) { // Convert array to multidimensional array. double[,] ma = { { m[0], m[1], m[2], m[3] }, { m[4], m[5], m[6], m[7] }, { m[8], m[9], m[10], m[11] }, { m[12], m[13], m[14], m[15] } }; var matrix = new SharpGL.SceneGraph.Matrix(ma); // Demo of multiplying matrices. *Static method* // SharpGL.SceneGraph.Matrix.Multiply(left, right); } } }

If it were me, once I settled on a solution, I would simply write extension methods over the Solid Edge API to make working with the matrices easier. There are plenty of examples of how to write Solid Edge API extension methods on GitHub (SolidEdge.Community).

Re: Matrix methods

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-08-2014 07:07 AM

Pinging @AdityaG and @jay_carlton to see if their group can offer any guidance or sample code.

Re: Matrix methods

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-08-2014 11:13 AM

Since asking the question, I elected to download and wrap a public C# maths library. I have no difficulty working with matrices, except that there are a lot of methods and I preferred to start with something rather than start with nothing.

About these extension methods, my impression is there's nothing magic about them and they are simply useful methods that use the SolidEdge API.

------------------

Alan Baljeu

Owner, Cornerstone Intelligent Software

Developer of custom CAD software

Alan Baljeu

Owner, Cornerstone Intelligent Software

Developer of custom CAD software

Re: Matrix methods

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-08-2014 07:44 PM

Solid Edge uses the computer graphics row major matrix ordering, as opposed to the math's textbook's column major. That means the 16 values are

xx xy xz 0

yx yy yz 0

xz zy zz 0

tx ty tz 1

consisting of a 3x3 rotation matrix and a translation vector.

Given a 3D vector (vx, vy, vz) in the 'local' coordinate system, or *space* as I like to call it, then the premultiplication

(vx vy vz 1) X [xx xy xz 0]

[yx yy yz 0]

[zx zy zz 0]

[tx ty tz 1]

produces the transformed vector. The applies the rotation followed by the translation.

The inverse transformation is formed by multiplying the reverse translation, a negation, followed by the reverse rotation, a transpose.

[ 1 0 0 0] X [xx yx zx 0]

[ 0 1 0 0] [xy yy zy 0]

[ 0 0 1 0] [xz yz zz 0]

[tx ty tz 1] [ 0 0 0 1]

The appropriate methods should be in the maths library.

There is a very brief summary on homogeneous math at the beginning of my article on codeproject at

www.codeproject.com/Articles/68243/Heresy-II-Why-D-Homogeneous-Transform-Clip-Projec

Re: Matrix methods

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-09-2014 10:06 AM

"The appropriate methods should be in the maths library."

I grabbed a library and it has appropriate methods. Did you have something in mind when you said "the maths library"?

------------------

Alan Baljeu

Owner, Cornerstone Intelligent Software

Developer of custom CAD software

Alan Baljeu

Owner, Cornerstone Intelligent Software

Developer of custom CAD software

Re: Matrix methods

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-10-2014 08:50 AM

No, I had nothing in mind.

Download the **latest maintenance pack** from GTAC.

Follow Siemens PLM Software

© 2019 Siemens Product Lifecycle Management Software Inc