Exemplo n.º 1
0
Arquivo: props.py Projeto: trelau/AFEM
class ShapeProps(object):
    """
    Base class for shape properties.
    """

    def __init__(self):
        self._props = GProp_GProps()

    @property
    def mass(self):
        """
        :return: The mass of the shape. This corresponds to total length for
            linear properties, total area for surface properties, or total
            volume for volume properties.
        :rtype: float
        """
        return self._props.Mass()

    @property
    def cg(self):
        """
        :return: The center of gravity.
        :rtype: afem.geometry.entities.Point
        """
        gp_pnt = self._props.CentreOfMass()
        return Point(gp_pnt.X(), gp_pnt.Y(), gp_pnt.Z())

    @property
    def static_moments(self):
        """
        :return: The static moments of inertia Ix, Iy, and Iz.
        :rtype: tuple(float)
        """
        return self._props.StaticMoments(0., 0., 0.)

    @property
    def matrix_of_inertia(self):
        """
        :return: The 3 x 3 matrix of inertia.
        :rtype: numpy.ndarray
        """
        gp_mat = self._props.MatrixOfInertia()
        matrix = []
        for j in range(1, 4):
            row = []
            for i in range(1, 4):
                row.append(gp_mat.Value(i, j))
            matrix.append(row)
        return array(matrix, dtype=float)

    def moment_of_inertia(self, axis):
        """
        Compute the moment of inertia about the axis.

        :param afem.geometry.entities.Axis1 axis: The axis.

        :return: The moment of inertia.
        :rtype: float
        """
        return self._props.MomentOfInertia(axis)
Exemplo n.º 2
0
class PropsBase(object):
    """
    Base class for shape properties.
    """

    def __init__(self):
        self._props = GProp_GProps()

    @property
    def mass(self):
        """
        :return: The mass of the shape. This corresponds to total length for
            linear properties, total area for surface properties, or total
            volume for volume properties.
        :rtype: float
        """
        return self._props.Mass()

    @property
    def cg(self):
        """
        :return: The center of gravity.
        :rtype: OCCT.gp.gp_Pnt
        """
        return self._props.CentreOfMass()

    @property
    def static_moments(self):
        """
        :return: The static moments of inertia Ix, Iy, and Iz.
        :rtype: tuple(float)
        """
        return self._props.StaticMoments(0., 0., 0.)

    def moment_of_inertia(self, axis):
        """
        Compute the moment of inertia about the axis.

        :param OCCT.gp.gp_Ax1 axis: The axis.

        :return: The moment of inertia.
        :rtype: float
        """
        return self._props.MomentOfInertia(axis)