/*
 * Automatically Generated from Mathematica.
 * Thu 4 Nov 2021 17:00:18 GMT-04:00
 */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include "R_left_tarsus.h"

#ifdef _MSC_VER
  #define INLINE __forceinline /* use __forceinline (VC++ specific) */
#else
  #define INLINE static inline        /* use standard inline */
#endif

/**
 * Copied from Wolfram Mathematica C Definitions file mdefs.hpp
 * Changed marcos to inline functions (Eric Cousineau)
 */
INLINE double Power(double x, double y) { return pow(x, y); }
INLINE double Sqrt(double x) { return sqrt(x); }

INLINE double Abs(double x) { return fabs(x); }

INLINE double Exp(double x) { return exp(x); }
INLINE double Log(double x) { return log(x); }

INLINE double Sin(double x) { return sin(x); }
INLINE double Cos(double x) { return cos(x); }
INLINE double Tan(double x) { return tan(x); }

INLINE double Csc(double x) { return 1.0/sin(x); }
INLINE double Sec(double x) { return 1.0/cos(x); }

INLINE double ArcSin(double x) { return asin(x); }
INLINE double ArcCos(double x) { return acos(x); }


/* update ArcTan function to use atan2 instead. */
INLINE double ArcTan(double x, double y) { return atan2(y,x); }

INLINE double Sinh(double x) { return sinh(x); }
INLINE double Cosh(double x) { return cosh(x); }
INLINE double Tanh(double x) { return tanh(x); }

#define E 2.71828182845904523536029
#define Pi 3.14159265358979323846264
#define Degree 0.01745329251994329576924

/*
 * Sub functions
 */
static void output1(Eigen::Matrix<double,3,3> &p_output1, const Eigen::Matrix<double,36,1> &var1)
{
  double t4492;
  double t7534;
  double t2315;
  double t2438;
  double t2942;
  double t4226;
  double t4507;
  double t4701;
  double t4722;
  double t5408;
  double t7538;
  double t2055;
  double t8498;
  double t8519;
  double t8523;
  double t5782;
  double t7587;
  double t7930;
  double t8718;
  double t1079;
  double t11222;
  double t11269;
  double t11273;
  double t7932;
  double t8719;
  double t11211;
  double t11275;
  double t11331;
  double t11221;
  double t11321;
  double t11329;
  double t753;
  double t11332;
  double t11333;
  double t11337;
  double t11343;
  double t11330;
  double t11339;
  double t11341;
  double t433;
  double t11344;
  double t11347;
  double t11348;
  double t410;
  double t11362;
  double t11364;
  double t11365;
  double t11374;
  double t11375;
  double t11377;
  double t11367;
  double t11368;
  double t11370;
  double t11382;
  double t11384;
  double t11385;
  double t11373;
  double t11378;
  double t11379;
  double t11380;
  double t11386;
  double t11387;
  double t11395;
  double t11396;
  double t11397;
  double t11353;
  double t11392;
  double t11398;
  double t11399;
  double t11402;
  double t11403;
  double t11406;
  double t11440;
  double t11444;
  double t11445;
  double t11430;
  double t11431;
  double t11436;
  double t11454;
  double t11459;
  double t11462;
  double t11437;
  double t11450;
  double t11451;
  double t11453;
  double t11467;
  double t11472;
  double t11479;
  double t11481;
  double t11487;
  double t11478;
  double t11491;
  double t11492;
  double t11495;
  double t11496;
  double t11497;
  double t11342;
  double t11349;
  double t11351;
  double t11355;
  double t11356;
  double t11357;
  double t11401;
  double t11408;
  double t11409;
  double t11412;
  double t11423;
  double t11425;
  double t11493;
  double t11499;
  double t11500;
  double t11503;
  double t11505;
  double t11506;
  t4492 = Cos(var1[3]);
  t7534 = Cos(var1[4]);
  t2315 = Cos(var1[6]);
  t2438 = Cos(var1[5]);
  t2942 = Sin(var1[3]);
  t4226 = -1.*t2438*t2942;
  t4507 = Sin(var1[4]);
  t4701 = Sin(var1[5]);
  t4722 = t4492*t4507*t4701;
  t5408 = t4226 + t4722;
  t7538 = Sin(var1[6]);
  t2055 = Cos(var1[7]);
  t8498 = t4492*t7534*t2315;
  t8519 = t5408*t7538;
  t8523 = t8498 + t8519;
  t5782 = t2315*t5408;
  t7587 = -1.*t4492*t7534*t7538;
  t7930 = t5782 + t7587;
  t8718 = Sin(var1[7]);
  t1079 = Cos(var1[8]);
  t11222 = t2055*t8523;
  t11269 = t7930*t8718;
  t11273 = t11222 + t11269;
  t7932 = t2055*t7930;
  t8719 = -1.*t8523*t8718;
  t11211 = t7932 + t8719;
  t11275 = Sin(var1[8]);
  t11331 = Cos(var1[9]);
  t11221 = t1079*t11211;
  t11321 = t11273*t11275;
  t11329 = t11221 + t11321;
  t753 = Sin(var1[9]);
  t11332 = t1079*t11273;
  t11333 = -1.*t11211*t11275;
  t11337 = t11332 + t11333;
  t11343 = Cos(var1[10]);
  t11330 = t753*t11329;
  t11339 = t11331*t11337;
  t11341 = t11330 + t11339;
  t433 = Sin(var1[10]);
  t11344 = t11331*t11329;
  t11347 = -1.*t753*t11337;
  t11348 = t11344 + t11347;
  t410 = Sin(var1[11]);
  t11362 = t4492*t2438;
  t11364 = t2942*t4507*t4701;
  t11365 = t11362 + t11364;
  t11374 = t7534*t2315*t2942;
  t11375 = t11365*t7538;
  t11377 = t11374 + t11375;
  t11367 = t2315*t11365;
  t11368 = -1.*t7534*t2942*t7538;
  t11370 = t11367 + t11368;
  t11382 = t2055*t11377;
  t11384 = t11370*t8718;
  t11385 = t11382 + t11384;
  t11373 = t2055*t11370;
  t11378 = -1.*t11377*t8718;
  t11379 = t11373 + t11378;
  t11380 = t1079*t11379;
  t11386 = t11385*t11275;
  t11387 = t11380 + t11386;
  t11395 = t1079*t11385;
  t11396 = -1.*t11379*t11275;
  t11397 = t11395 + t11396;
  t11353 = Cos(var1[11]);
  t11392 = t753*t11387;
  t11398 = t11331*t11397;
  t11399 = t11392 + t11398;
  t11402 = t11331*t11387;
  t11403 = -1.*t753*t11397;
  t11406 = t11402 + t11403;
  t11440 = -1.*t2315*t4507;
  t11444 = t7534*t4701*t7538;
  t11445 = t11440 + t11444;
  t11430 = t7534*t2315*t4701;
  t11431 = t4507*t7538;
  t11436 = t11430 + t11431;
  t11454 = t2055*t11445;
  t11459 = t11436*t8718;
  t11462 = t11454 + t11459;
  t11437 = t2055*t11436;
  t11450 = -1.*t11445*t8718;
  t11451 = t11437 + t11450;
  t11453 = t1079*t11451;
  t11467 = t11462*t11275;
  t11472 = t11453 + t11467;
  t11479 = t1079*t11462;
  t11481 = -1.*t11451*t11275;
  t11487 = t11479 + t11481;
  t11478 = t753*t11472;
  t11491 = t11331*t11487;
  t11492 = t11478 + t11491;
  t11495 = t11331*t11472;
  t11496 = -1.*t753*t11487;
  t11497 = t11495 + t11496;
  t11342 = -1.*t433*t11341;
  t11349 = t11343*t11348;
  t11351 = t11342 + t11349;
  t11355 = t11343*t11341;
  t11356 = t433*t11348;
  t11357 = t11355 + t11356;
  t11401 = -1.*t433*t11399;
  t11408 = t11343*t11406;
  t11409 = t11401 + t11408;
  t11412 = t11343*t11399;
  t11423 = t433*t11406;
  t11425 = t11412 + t11423;
  t11493 = -1.*t433*t11492;
  t11499 = t11343*t11497;
  t11500 = t11493 + t11499;
  t11503 = t11343*t11492;
  t11505 = t433*t11497;
  t11506 = t11503 + t11505;

  p_output1(0)=t11353*t11357 + t11351*t410;
  p_output1(1)=t11353*t11425 + t11409*t410;
  p_output1(2)=t11353*t11506 + t11500*t410;
  p_output1(3)=t11351*t11353 - 1.*t11357*t410;
  p_output1(4)=t11353*t11409 - 1.*t11425*t410;
  p_output1(5)=t11353*t11500 - 1.*t11506*t410;
  p_output1(6)=t2438*t4492*t4507 + t2942*t4701;
  p_output1(7)=t2438*t2942*t4507 - 1.*t4492*t4701;
  p_output1(8)=t2438*t7534;
}


       
Eigen::Matrix<double,3,3> R_left_tarsus(const Eigen::Matrix<double,36,1> &var1)
//void R_left_tarsus(Eigen::Matrix<double,3,3> &p_output1, const Eigen::Matrix<double,36,1> &var1)
{
  /* Call Subroutines */
  Eigen::Matrix<double,3,3>  p_output1;
  
  output1(p_output1, var1);

  return p_output1;
}



