-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into test-with-ams-8.0.5rc1
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}; | ||
}; | ||
}; |