Utility Functions¶
import utilities
-
utilities.
calcMomentOfAreaRectangular
(b, h, dx=0.0, dy=0.0)¶ Calculate the second and polar moment of area of rectangulars
\(I_x = \frac{bh^3}{12} + Ad_x^2\)
Parameters: - b (float) – Width of the rectangular
- h (float) – Height of the rectangular
- dx (float) – Distance between parallel x axes
- dy (float) – Distance between parallel y axes
Returns: Second moments of area and polar moment of area
Return type: dictionary
-
utilities.
calcMomentOfAreaAnnulus
(ro, ri, ts, te, dx=0.0, dy=0.0)¶ Calculate the second and polar moment of area of annulus
Parameters: - ro (float) – Radius of the outer circle
- ri (float) – Radius of the inner circle
- ts (float) – Start angle in degrees
- te (float) – End angle in degrees
- dx (float) – Distance between parallel x axes
- dy (float) – Distance between parallel y axes
Returns: Second moments of area and polar moment of area
Return type: dictionary
-
utilities.
calcGeneralRotation3D
(angles, order=[1, 2, 3])¶ Calculate the general rotation matrix
Parameters: - angles (list) – Three rotation angles in radians
- order (list) – The order of axis of the rotation operation
Returns: The general rotation matrix
Return type: numpy.array
-
utilities.
calcCab
(a, b)¶ Calculate the direction cosine matrix between frame a and b
\(C_{ij} = a_i\ \cdot\ b_j\)
Parameters: - a (list) – list of three a basis (a_1, a_2, a_3)
- b (list) – list of three b basis (b_1, b_2, b_3)
Returns: 3x3 matrix of the direction cosine
Return type: numpy.array
Example: >>> a = [ ... [1., 0., 0.], ... [0., 1., 0.], ... [0., 0., 1.] ... ] >>> b = [ ... [], ... [], ... [] ... ] >>> utilities.calcCab(a, b)
-
utilities.
textToMatrix
(textList)¶ Convert the text of a block of numbers into a matrix
Parameters: textList (list) – The block of text representing a matrix Returns: A matrix of numbers Return type: numpy.array Example: >>> lines = ['1 2 3', '4 5 6', '7 8 9'] >>> utilities.textToMatrix(lines) array([[1., 2., 3.], [4., 5., 6.], [7., 8., 9.]])
-
utilities.
writeFormatIntegers
(file, numbers, fmt='8d', newline=True)¶ Write a list of integers into a file
Parameters: - file (file) – The file object for writing
- numbers (list) – The list of numbers that is going to be written
- fmt (string) – The desired format for each number
- newline (bool) – If append the character
\n
after writting all numbers or not
-
utilities.
writeFormatFloats
(file, numbers, fmt='16.7e', newline=True)¶ Write a list of floats into a file
Parameters: - file (file) – The file object for writing
- numbers (list) – The list of numbers that is going to be written
- fmt (string) – The desired format for each number
- newline (bool) – If append the character
\n
after writting all numbers or not
-
utilities.
updateXMLElement
(parent, tag, value)¶ Update/Create an element with given tag and value.
Parameters: - parent (xml.etree.ElementTree.Element) – Parent element
- tag (string) – Tag of the element
- value (string) – Value of the element