/* VectorNav HSI Calibration Library v1.0.0.2
 *
 * Copyright (c) 2018 VectorNav Technologies, LLC
 *
 * This source code is proprietary to and copyrighted by VectorNav Technologies, LLC and is
 * available solely under license from VectorNav. All rights reserved. If you do not have a
 * license to use this source code from VectorNav, any use hereof is strictly prohibited by
 * U.S. law and other applicable law. This source code is restricted for use solely with the
 * products of VectorNav and as otherwise set forth in any agreement with VectorNav. Any
 * disclosure of this source code to the public or to any third party is also prohibited.
 */
#include "vnmatrix.h"
#include "vnstring.h"

void
init_m3f_fa(
    union vn_mat3f *m,
    const float *fa)
{
  size_t i;

  for (i = 0; i < 9; i++)
    m->e[i] = fa[i];
}

#if defined(_MSC_VER)
  #pragma warning(push)
  #pragma warning(disable:4701)
#endif

union vn_mat3f
neg_m3f(
    union vn_mat3f m)
{
  union vn_mat3f r;
  size_t i;

  for (i = 0; i < 3 * 3; i++)
    r.e[i] = -m.e[i];

  return r;
}

#if defined(_MSC_VER)
  #pragma warning(pop)
#endif

enum VnError
to_string_mat3f(
    char* out,
    size_t outSize,
    union vn_mat3f m)
{
  return sprintf_x(
    out,
    outSize,
    "[(%f; %f; %f); (%f; %f; %f); (%f; %f; %f)]",
    m.e[0],
    m.e[3],
    m.e[6],
    m.e[1],
    m.e[4],
    m.e[7],
    m.e[2],
    m.e[5],
    m.e[8]);
}
