"""LCM type definitions
This file automatically generated by lcm.
DO NOT MODIFY BY HAND!!!!
"""


from io import BytesIO
import struct

class lcmt_hydroelastic_quadrature_per_point_data_for_viz(object):

    __slots__ = ["p_WQ", "vt_BqAq_W", "traction_Aq_W"]

    __typenames__ = ["double", "double", "double"]

    __dimensions__ = [[3], [3], [3]]

    def __init__(self):
        self.p_WQ = [ 0.0 for dim0 in range(3) ]
        """
        The quadrature point Q, as an offset vector in the world frame W, at which
        the traction and slip velocities are evaluated.
        LCM Type: double[3]
        """

        self.vt_BqAq_W = [ 0.0 for dim0 in range(3) ]
        """
        Denoting Point Aq as the point of Body A coincident with Q and Point Bq as
        the point of Body B coincident with Q, calculates vr (the velocity
        of Bq relative to Aq) and then calculates the component perpendicular to
        the unit surface normal n̂ as vt = vr - (vr⋅n̂)n̂.
        The resulting vector vt is expressed in the world frame W.
        LCM Type: double[3]
        """

        self.traction_Aq_W = [ 0.0 for dim0 in range(3) ]
        """
        The traction vector, expressed in the world frame and with units of Pa,
        applied to Body A at Point Q (i.e., Frame A is shifted to Aq).
        LCM Type: double[3]
        """


    def encode(self):
        buf = BytesIO()
        buf.write(lcmt_hydroelastic_quadrature_per_point_data_for_viz._get_packed_fingerprint())
        self._encode_one(buf)
        return buf.getvalue()

    def _encode_one(self, buf):
        buf.write(struct.pack('>3d', *self.p_WQ[:3]))
        buf.write(struct.pack('>3d', *self.vt_BqAq_W[:3]))
        buf.write(struct.pack('>3d', *self.traction_Aq_W[:3]))

    @staticmethod
    def decode(data: bytes):
        if hasattr(data, 'read'):
            buf = data
        else:
            buf = BytesIO(data)
        if buf.read(8) != lcmt_hydroelastic_quadrature_per_point_data_for_viz._get_packed_fingerprint():
            raise ValueError("Decode error")
        return lcmt_hydroelastic_quadrature_per_point_data_for_viz._decode_one(buf)

    @staticmethod
    def _decode_one(buf):
        self = lcmt_hydroelastic_quadrature_per_point_data_for_viz()
        self.p_WQ = struct.unpack('>3d', buf.read(24))
        self.vt_BqAq_W = struct.unpack('>3d', buf.read(24))
        self.traction_Aq_W = struct.unpack('>3d', buf.read(24))
        return self

    @staticmethod
    def _get_hash_recursive(parents):
        if lcmt_hydroelastic_quadrature_per_point_data_for_viz in parents: return 0
        tmphash = (0xc093c3933c1ec1d9) & 0xffffffffffffffff
        tmphash  = (((tmphash<<1)&0xffffffffffffffff) + (tmphash>>63)) & 0xffffffffffffffff
        return tmphash
    _packed_fingerprint = None

    @staticmethod
    def _get_packed_fingerprint():
        if lcmt_hydroelastic_quadrature_per_point_data_for_viz._packed_fingerprint is None:
            lcmt_hydroelastic_quadrature_per_point_data_for_viz._packed_fingerprint = struct.pack(">Q", lcmt_hydroelastic_quadrature_per_point_data_for_viz._get_hash_recursive([]))
        return lcmt_hydroelastic_quadrature_per_point_data_for_viz._packed_fingerprint

    def get_hash(self):
        """Get the LCM hash of the struct"""
        return struct.unpack(">Q", lcmt_hydroelastic_quadrature_per_point_data_for_viz._get_packed_fingerprint())[0]

