# automatically generated by the FlatBuffers compiler, do not modify

# namespace: foxglove

import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()

# A [quaternion](https://eater.net/quaternions) representing a rotation in 3D space
class Quaternion(object):
    __slots__ = ['_tab']

    @classmethod
    def GetRootAs(cls, buf, offset=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = Quaternion()
        x.Init(buf, n + offset)
        return x

    @classmethod
    def GetRootAsQuaternion(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)
    # Quaternion
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # x value
    # Quaternion
    def X(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Float64Flags, o + self._tab.Pos)
        return 0.0

    # y value
    # Quaternion
    def Y(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Float64Flags, o + self._tab.Pos)
        return 0.0

    # z value
    # Quaternion
    def Z(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Float64Flags, o + self._tab.Pos)
        return 0.0

    # w value
    # Quaternion
    def W(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Float64Flags, o + self._tab.Pos)
        return 1.0

def QuaternionStart(builder): builder.StartObject(4)
def Start(builder):
    return QuaternionStart(builder)
def QuaternionAddX(builder, x): builder.PrependFloat64Slot(0, x, 0.0)
def AddX(builder, x):
    return QuaternionAddX(builder, x)
def QuaternionAddY(builder, y): builder.PrependFloat64Slot(1, y, 0.0)
def AddY(builder, y):
    return QuaternionAddY(builder, y)
def QuaternionAddZ(builder, z): builder.PrependFloat64Slot(2, z, 0.0)
def AddZ(builder, z):
    return QuaternionAddZ(builder, z)
def QuaternionAddW(builder, w): builder.PrependFloat64Slot(3, w, 1.0)
def AddW(builder, w):
    return QuaternionAddW(builder, w)
def QuaternionEnd(builder): return builder.EndObject()
def End(builder):
    return QuaternionEnd(builder)