Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Polar mass moment of inertia - diagonalize matrix
nicolas_lagas_Sulzer
Member Posts: 5 PRO
Hi
New to FS but not to OnShape.
I tried to write a FS to get the polar MMI of a part, since most of what we design is axisymmetric, the only term in the diagonal matrix not equal to the other two is the polar MMI. However when the part's axis of revolution is not X, Y or Z, then I need to diagonalize the matrix first.
I found the svd function, where matrix.s seems to contain what I need. However I dont understand how to do it and the debug tool is not very helpful... can you help me adjust the code? Thanks
See document https://sulzer.onshape.com/documents/b8a5032af290a31e1e6b7f07/w/3f9461911330a70bea798aa7/e/4e7d51cf481630a9996b4587?renderMode=0&rightPanel=customTablePanel&uiState=65cd90d67996d964c6f5618c
New to FS but not to OnShape.
I tried to write a FS to get the polar MMI of a part, since most of what we design is axisymmetric, the only term in the diagonal matrix not equal to the other two is the polar MMI. However when the part's axis of revolution is not X, Y or Z, then I need to diagonalize the matrix first.
I found the svd function, where matrix.s seems to contain what I need. However I dont understand how to do it and the debug tool is not very helpful... can you help me adjust the code? Thanks
<div><i>FeatureScript 2260;</i></div><div><i>import(path : "onshape/std/common.fs", version : "2260.0");</i></div><div><br></div><div><i>annotation { "Property Function Name" : "computePMMI" }</i></div><div><i>export const computePMMI = defineComputedPartProperty(function(context is Context, part is Query, definition is map) returns ValueWithUnits // (or string or number or boolean)</i></div><div><i> // definition is an empty map and reserved for future use</i></div><div><i> {</i></div><div><i> // Compute and return the property value, using the context and parameters</i></div><div><i> var massProperties = evApproximateMassProperties(context, {</i></div><div><i> "entities" : part,</i></div><div><i> "density" : 7850 * kilogram / meter ^ 3</i></div><div><i> });</i></div><div><br></div><div><i> var MMIArray = [get(massProperties.inertia, 0, 0), get(massProperties.inertia, 1, 1), get(massProperties.inertia, 2, 2)];</i></div><div><i> </i></div><div><i> //set output value to 0 if none of below comparisons is true</i></div><div><i> var MMIOutput = 0*kilogram*meter^2;</i></div><div><i> </i></div><div><i> //If a part is axisymmetric the two MMI will be equal. The one not equal will be the polar MMI. If no equal couple is found, then the part is not axisymmetric</i></div><div><i> if (tolerantEquals(MMIArray[0],MMIArray[1]))</i></div><div><i> {</i></div><div><i> MMIOutput=MMIArray[2];</i></div><div><i> }</i></div><div><i> if (tolerantEquals(MMIArray[0],MMIArray[2]))</i></div><div><i> {</i></div><div><i> MMIOutput=MMIArray[1];</i></div><div><i> }</i></div><div><i> if (tolerantEquals(MMIArray[1],MMIArray[2]))</i></div><div><i> {</i></div><div><i> MMIOutput=MMIArray[0];</i></div><div><i> }</i></div><div><br></div><div><i> return MMIOutput;</i></div><div><i> });</i></div>
See document https://sulzer.onshape.com/documents/b8a5032af290a31e1e6b7f07/w/3f9461911330a70bea798aa7/e/4e7d51cf481630a9996b4587?renderMode=0&rightPanel=customTablePanel&uiState=65cd90d67996d964c6f5618c
0
Answers