function i3dmgx2_DrawSensor(Packet)
%Makes a 3D plot of the sensor relative to the earth
%
%Arguments: Packet - Data packet from sensor

OrientationMatrix = [convert2float32bin(Packet(2:5)) convert2float32bin(Packet(6:9)) convert2float32bin(Packet(10:13));
                     convert2float32bin(Packet(14:17)) convert2float32bin(Packet(18:21)) convert2float32bin(Packet(22:25));
                     convert2float32bin(Packet(26:29)) convert2float32bin(Packet(30:33)) convert2float32bin(Packet(34:37))]; %Construct orientation matrix
Vertices = [-1.8 2 1;
            -1.8 -2 1;
            1.8 -2 1;
            1.8 2 1;
            1.8 2 -1;
            -1.8 2 -1;
            -1 2.8 -1;
            1 2.8 -1;
            1 2.8 -1.2;
            -1 2.8 -1.2;
            -1 -2.8 -1.2;
            1 -2.8 -1.2;
            1 -2.8 -1;
            -1 -2.8 -1;
            -1.8 -2 -1;
            1.8 -2 -1;
            1.8 -2 -1.2;
            1.8 2 -1.2;
            -1.8 2 -1.2;
            -1.8 -2 -1.2]; %Define vertices
Faces = [1 2 3 4;
         1 4 5 6;
         4 3 16 5;
         2 3 16 15;
         1 2 15 6;
         6 19 20 15;
         7 8 9 10;
         5 16 17 18;
         11 12 13 14;
         13 14 15 16;
         5 6 7 8;
         17 18 19 20;
         5 8 9 18;
         6 7 10 19;
         14 15 20 11;
         12 13 16 17;
         11 12 17 20;
         9 10 19 18]; %Define faces
TransformedVerticies = zeros(20,3);
for VertexNum = 1:20
    Vertex = (Vertices(VertexNum,:));
    TransformedVertex = inv(OrientationMatrix)*Vertex'; %Transform using orientation matrix
    TransformedVerticies(VertexNum,1)=TransformedVertex(2);
    TransformedVerticies(VertexNum,2)=TransformedVertex(1);
    TransformedVerticies(VertexNum,3)=TransformedVertex(3);
end
clf
patch('Vertices',TransformedVerticies,'Faces',Faces,'EdgeColor','k','FaceColor',[.5,.5,.5]) %Draw sensor
axis equal
axis([-4 4 -4 4 -4 4])
grid on