packages feed

spatial-math 0.1.4 → 0.1.5

raw patch · 3 files changed

+24/−54 lines, 3 files

Files

SpatialMath.hs view
@@ -4,8 +4,8 @@  module SpatialMath ( module Xyz                    , module Quat---                   , Xyz(..)---                   , Quat(..)+                   , Xyz(..)+                   , Quat(..)                    , Euler(..)                    , rotateXyzAboutX                    , rotateXyzAboutY@@ -180,54 +180,3 @@  rotVecByEulerB2A :: (Floating a, Element a, Ord a) => Euler a -> Xyz a -> Xyz a rotVecByEulerB2A = rotVecByDcmB2A . dcmOfEuler321---- void--- get_wind_angles_from_v_bw_b(double * alpha, double * beta, double * airspeed, const xyz_t * const v_bw_b)--- {---   double airspeed_internal_memory;---   double * airspeed_internal = &airspeed_internal_memory;--- ---   if (airspeed != NULL)---     *airspeed = xyz_norm(v_bw_b) + 1e-12;--- ---   if (beta != NULL)---   {---     if (airspeed != NULL)---       airspeed_internal = airspeed;---     else---       *airspeed_internal = xyz_norm(v_bw_b) + 1e-12;--- ---     *beta  =  asin ( v_bw_b->y / *airspeed_internal );---   }--- ---   if (alpha != NULL)---     *alpha =  atan2( v_bw_b->z, v_bw_b->x );--- }--- --- void--- get_wind_angles( double * alpha,---                  double * beta,---                  double * airspeed,---                  xyz_t * v_bw_b_out,---                  const quat_t * const q_n2b,---                  const xyz_t * const v_bn_b,---                  const xyz_t * const v_wn_n)--- {---   xyz_t v_wn_b;---   rot_vec_by_quat_a2b( &v_wn_b, q_n2b, v_wn_n);---   xyz_t v_bw_b;---   xyz_diff( &v_bw_b, v_bn_b, &v_wn_b);--- ---   get_wind_angles_from_v_bw_b( alpha, beta, airspeed, &v_bw_b );--- ---   if (v_bw_b_out != NULL)---     xyz_memcpy( v_bw_b_out, &v_bw_b);--- }--- --- void--- v_bw_b_from_wind_angles( xyz_t * v_bw_b, const double alpha, const double beta, const double airspeed)--- {---   v_bw_b->x = airspeed*cos(alpha)*cos(beta);---   v_bw_b->y = airspeed*sin(beta);---   v_bw_b->z = airspeed*cos(beta)*sin(alpha);--- }
Xyz.hs view
@@ -42,6 +42,27 @@   signum = fmap signum   fromInteger k = fmap fromInteger (Xyz k k k) +instance (Fractional a) => Fractional (Xyz a) where+  fromRational r = fmap fromRational (Xyz r r r)+  (/) = zipWithXyz (/)++instance (Floating a) => Floating (Xyz a) where+  pi = Xyz pi pi pi+  exp   = fmap exp+  log   = fmap log+  sin   = fmap sin+  cos   = fmap cos+  tan   = fmap tan+  asin  = fmap asin+  acos  = fmap acos+  atan  = fmap atan+  sinh  = fmap sinh+  cosh  = fmap cosh+  tanh  = fmap tanh+  asinh = fmap asinh+  acosh = fmap acosh+  atanh = fmap atanh+ -- | c = a (cross) b cross :: Num a => Xyz a -> Xyz a -> Xyz a cross (Xyz ax ay az) (Xyz bx by bz) = Xyz cx cy cz
spatial-math.cabal view
@@ -1,5 +1,5 @@ name:                spatial-math-version:             0.1.4+version:             0.1.5 synopsis:            3d math including quaternions/euler angles/dcms and utility functions description:         This is a port of my 'mathlib' C library: https://github.com/ghorn/mathlib license:             BSD3