Skip to content

Commit

Permalink
Merge branch 'master' into test-with-ams-8.0.5rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
melund authored Jul 23, 2024
2 parents 3d8ec60 + f7d321c commit 2361b06
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
(ammr-3.0.5-changelog)=
## AMMR 3.0.5 (2024-??-??)

### ➕ Added:
* Added a small class template, [`CreateCoMRefNode`](#Utilities.center-of-mass.createcomrefnode.createcomrefnode),
that can be used to create a reference node at the center of mass of a segment with its axes aligned with
the principal axes of inertia of the segment.

### 🩹 Fixed:
* Fixed an issue that prevented switching off drawing of marker arrows in CreateMarkerDriverClass in MoCap models. Updated the search string
used in `Main.ModelSetup.Views.All_MarkerArrows.Objects` to correctly pick up the arrow drawing objects.
Expand Down
60 changes: 60 additions & 0 deletions Tools/ModelUtilities/SegmentCoM/CreateCoMRefNode.any
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
---
group: Utilities
topic: Center of mass
descr: |
Class template to create a reference node at the center of mass of a segment
with its axis aligned with the principal axes of inertia.
---

To use the class template import the file:
#include "<ANYBODY_PATH_MODELUTILS>/SegmentCoM/CreateCoMRefNode.any"

*/


// Creates a reference node at the center of mass of the segment. The orientation of the reference
// node is determined from the principal axes of inertia, which are determined from the Jmatrix of
// the segment. This class template must be used inside the scope of AnySegment.
//
// In the example below a reference node is created inside a segment.
//
// :::{rubric} Example
// :::
//
// :::{code-block} AnyScriptDoc
// AnySeg MySegment = {
// CreateCoMRefNode CoMNode () = {
// viewRefFrame.Visible = On;
// };
// };
//:::
//
#class_template CreateCoMRefNode (__CLASS__ = AnyRefNode){
/// Jmatrix about the center of mass
AnyMat33 JMatrixCoM = .Jmatrix + .Mass*skewmat3d(.sCoM)*skewmat3d(.sCoM);
/// Matrix with eigen vectors and eigen values from the Jmatrix about center of mass
AnyMatrix JMatrixEV = LAPACK_syevd(JMatrixCoM,"V","V");
/// Eigen vectors of the Jmatrix about the center of mass
AnyFloat EigenVectors = {JMatrixEV[0],JMatrixEV[1],JMatrixEV[2]};

// sRel
/// Relative position of the reference node in the segmental frame. This defaults to
/// segment sCoM.
#var sRel = .sCoM;
// ARel
/// Relative orientation of the reference node in the segmental frame. This defaults to
/// be aligned with the principal axes of inertia.
#var ARel = {EigenVectors[0],EigenVectors[1],cross(EigenVectors[0],EigenVectors[1])}';
viewRefFrame = {
//viewRefFrame.Visible = Off;
/// Switch to view the reference node.
#var Visible = Off;
//viewRefFrame.ScaleXYZ = 0.5*{1,1,1};
/// Size of the drawing of the reference node.
#var ScaleXYZ = 0.5*{1,1,1};
// viewRefFrame.RGB = {0.8,0.2,0.2};
/// Color of the drawing of the reference node.
#var RGB = {0.8,0.2,0.2};
};
};

0 comments on commit 2361b06

Please sign in to comment.