32
|
1 |
#======================================================================
|
35
|
2 |
# L I B A L E C . P L
|
32
|
3 |
# doc: Wed Jun 1 20:38:19 2011
|
35
|
4 |
# dlm: Mon Dec 18 10:29:08 2017
|
32
|
5 |
# (c) 2011 A.M. Thurnherr
|
35
|
6 |
# uE-Info: 71 31 NIL 0 0 70 2 2 4 NIL ofnI
|
32
|
7 |
#======================================================================
|
|
8 |
|
|
9 |
# HISTORY:
|
|
10 |
# Nov 15, 2017: - created
|
35
|
11 |
# Dec 18, 2017: - turned vel output into m/s
|
32
|
12 |
|
|
13 |
require "$ANTS/libvec.pl";
|
|
14 |
require "$ANTS/libfuns.pl";
|
|
15 |
|
|
16 |
#----------------------------------------------------------------------
|
|
17 |
# User Routines
|
35
|
18 |
# - from manual
|
|
19 |
# - also transform velocities to m/s
|
32
|
20 |
#----------------------------------------------------------------------
|
|
21 |
|
|
22 |
sub ALEC_u($$$$$$$)
|
|
23 |
{
|
|
24 |
my($vx,$vy,$alpha,$compA,$compB,$beta,$magdec) =
|
|
25 |
&antsFunUsage(7,'fffffff','<vx[cm/s]> <vy[cm/s]> <alpha> <compA> <compB> <beta>',@_);
|
|
26 |
|
|
27 |
my($c) = ALEC_vel_speed($vx,$vy,$alpha);
|
|
28 |
my($d) = ALEC_vel_dir($compA,$compB,$beta,$vx,$vy);
|
|
29 |
return vel_u($c,$d-$magdec);
|
|
30 |
}
|
|
31 |
|
|
32 |
sub ALEC_v($$$$$$$)
|
|
33 |
{
|
|
34 |
my($vx,$vy,$alpha,$compA,$compB,$beta,$magdec) =
|
|
35 |
&antsFunUsage(7,'fffffff','<vx[cm/s]> <vy[cm/s]> <alpha> <compA> <compB> <beta>',@_);
|
|
36 |
|
|
37 |
my($c) = ALEC_vel_speed($vx,$vy,$alpha);
|
|
38 |
my($d) = ALEC_vel_dir($compA,$compB,$beta,$vx,$vy);
|
|
39 |
return vel_v($c,$d-$magdec);
|
|
40 |
}
|
|
41 |
|
|
42 |
#------------------------------------------------------------------------------
|
|
43 |
# Routines mostly as per ALEC manual
|
35
|
44 |
# - weird atan corrections in manual cause data discontinuities
|
32
|
45 |
# => removed
|
|
46 |
# - routines verified with first PITTA time series
|
|
47 |
# ALEC_vel_speed(vx,vy,alpha)
|
|
48 |
# ALEC_heading(compA,compB,beta)
|
|
49 |
# ALEC_vel_instrument_dir(vx,vy)
|
|
50 |
# ALEC_vel_dir(compA,compB,beta,vx,vy)
|
|
51 |
#------------------------------------------------------------------------------
|
|
52 |
|
|
53 |
sub ALEC_vel_speed(@)
|
|
54 |
{
|
|
55 |
my($vx,$vy,$alpha) = &antsFunUsage(3,'fff','<vx[cm/s]> <vy[cm/s]> <alpha>',@_);
|
|
56 |
my($ssq) = ($vx**2 + $vy**2);
|
|
57 |
return inf unless ($ssq > 1e-6);
|
35
|
58 |
return (1 + $alpha*(4*$vx**2*$vy**2)/($ssq**2)) * sqrt($ssq) / 100;
|
32
|
59 |
}
|
|
60 |
|
|
61 |
sub ALEC_heading(@)
|
|
62 |
{
|
|
63 |
my($compA,$compB,$beta) =
|
|
64 |
&antsFunUsage(3,'fff','<compass output A> <compass output B> <beta>',@_);
|
|
65 |
return angle_pos(deg(atan2($compA,$compB)) + $beta);
|
|
66 |
}
|
|
67 |
|
|
68 |
sub ALEC_vel_instrument_dir($$)
|
|
69 |
{
|
|
70 |
my($vx,$vy) = &antsFunUsage(2,'ff','<vx[cm/s]> <vy[cm/s]>',@_);
|
|
71 |
return deg(atan2($vx,$vy));
|
|
72 |
}
|
|
73 |
|
|
74 |
sub ALEC_vel_dir($$$$$)
|
|
75 |
{
|
|
76 |
my($compA,$compB,$beta,$vx,$vy) =
|
|
77 |
&antsFunUsage(5,'fffff','<compass output A> <compass output B> <beta> <vx[cm/s]> <vy[cm/s]>',@_);
|
|
78 |
return ALEC_heading($compA,$compB,$beta) + ALEC_vel_instrument_dir($vx,$vy);
|
|
79 |
}
|
|
80 |
|
|
81 |
1;
|