在Bash中使用三角函数

我试图编写一个计算风校正角度的bash脚本,但是每当运行脚本的Trig部分时,我都会遇到错误。

line 32: sin(-14): syntax error in expression (error token is "(-14)"

我知道还没有关于WCA的完整公式,但是我想解决这个问题,然后再继续。该脚本发布在下面。如果需要其他详细信息,我们将竭诚为您服务。干杯

#!/bin/bash

# This script is to be used in Cross Country calculations

echo 'What is True Course?'

read true_course

echo 'What is True Airspeed?'

read true_airspeed

echo 'What is Wind Direction?'

read wind_direction

echo 'What is Wind Speed?'

read wind_speed

# Formula for WCA is below
# WCA = sin-1 (sin(WD-TC)*WV/TAS)

course_adjustment=$(($wind_direction-$true_course))

course_adjustment2=$(($course_adjustment*$wind_speed/$true_airspeed))

wca=$((sin($course_adjustment2)))

echo 'Course adjustment is' $course_adjustment
echo 'Course adjustment2 is' $course_adjustment2

# Formula for GS
# GS = SqRt(TAS2 + WV2 - 2*TAS*WV*cos(WD-TC-WCA))

echo 'Calculations complete!'

echo 'True Course is' $true_course

echo 'True Airspeed is' $true_airspeed

echo 'Wind Direction is' $wind_direction

echo 'Wind Speed is' $wind_speed
评论