"Hang glider generator"
Note: these program only runs in GNU/Linux, BSD or UNIX
computers. Sorry, I don't work on windows ;-)
The bash script "hgg.sh" reads data from file data.txt and generates
output .dxf viewed in qcad program.

Phoenix6b example (aproximation)
###################################################
#
# HANG
GLIDER DESIGNER
#
Laboratori d'envol (3-07-2004)
# bash
code runs in GNU/Linux
#
copyleft
#
###################################################
#!/bin/bash
clear
# Lectura de
dades de data.txt
na=$(grep
"050:" data.txt | awk '{print $2}')
pc=$(grep
"051:" data.txt | awk '{print $2}')
le=$(grep
"052:" data.txt | awk '{print $2}')
dt=$(grep
"053:" data.txt | awk '{print $2}')
cc=$(grep
"054:" data.txt | awk '{print $2}')
pt=$(grep
"055:" data.txt | awk '{print $2}')
pa=$(grep
"056:" data.txt | awk '{print $2}')
pv=$(grep
"057:" data.txt | awk '{print $2}')
pa=$(grep
"058:" data.txt | awk '{print $2}')
pq=$(grep
"059:" data.txt | awk '{print $2}')
#
Definició de punts estructura
pi=$(echo
"scale=6; 4*a(1.0)" | bc -l)
na2=$(echo
"scale=6; 0.5*$na*$pi/180" | bc)
na3=$(echo
"scale=6; (90-0.5*$na)*$pi/180" | bc)
echo "nose
angle / 2 = " $na2 $na $pi
x1=0 ; y1=0
x2=$(echo
"scale=4; $pc*s($na2)" | bc -l)
y2=$(echo
"scale=4; $pc*c($na2)" | bc -l)
echo "x2="
$x2 "y2=" $y2 "dt=" $dt
x3=$(echo
"scale=4; $le*s($na2)" | bc -l)
y3=$(echo
"scale=4; $le*c($na2)" | bc -l)
x3p=$(echo
"scale=6; $x3-$dt*s($na3)" | bc -l)
y3p=$(echo
"scale=6; $y3+$dt*c($na3)" | bc -l)
x4=0 ; y4=$cc
x5=0 ; y5=$pt
x6=0 ; y6=$pa
x7=0 ; y7=$pv
x8=0 ; y8=$pa
x9=0 ; y9=$pq
# Calcula
subdivisió 2-3'
segment=$(echo
"scale=4; 0.25*($le-$pc)" | bc -l)
x50=$(echo
"scale=4; $x2+$segment*s($na2)" | bc -l)
y50=$(echo
"scale=4; $y2+$segment*c($na2)" | bc -l)
x50p=$(echo
"scale=4; $x50-0.1*$dt*s($na3)" | bc -l)
y50p=$(echo
"scale=4; $y50+0.1*$dt*c($na3)" | bc -l)
x51=$(echo
"scale=4; $x2+2*$segment*s($na2)" | bc -l)
y51=$(echo
"scale=4; $y2+2*$segment*c($na2)" | bc -l)
x51p=$(echo
"scale=4; $x51-0.3*$dt*s($na3)" | bc -l)
y51p=$(echo
"scale=4; $y51+0.3*$dt*c($na3)" | bc -l)
x52=$(echo
"scale=4; $x2+3*$segment*s($na2)" | bc -l)
y52=$(echo
"scale=4; $y2+3*$segment*c($na2)" | bc -l)
x52p=$(echo
"scale=4; $x52-0.58*$dt*s($na3)" | bc -l)
y52p=$(echo
"scale=4; $y52+0.58*$dt*c($na3)" | bc -l)
# Function
line A to B in .dxf format
function line
{
echo 0
>> 1.dxf
echo LINE
>> 1.dxf
echo 8
>> 1.dxf
echo default
>> 1.dxf
echo 6
>> 1.dxf
echo
CONTINOUS >> 1.dxf
echo 10
>> 1.dxf ; echo $xa >> 1.dxf
echo 20
>> 1.dxf ; echo $ya >> 1.dxf
echo 11
>> 1.dxf ; echo $xb >> 1.dxf
echo 21
>> 1.dxf ; echo $yb >> 1.dxf
echo 39
>> 1.dxf ; echo 0 >> 1.dxf
echo 62
>> 1.dxf ; echo $color >> 1.dxf
}
> 1.dxf
# Dibuixa
l'estructura
# Line 1-2
xa=$x1 ;
ya=-$y1 ; xb=$x2 ; yb=-$y2
color=12
line
xa=-$x1 ;
ya=-$y1 ; xb=-$x2 ; yb=-$y2
color=12
line
# Line 2-3
xa=$x2 ;
ya=-$y2 ; xb=$x3 ; yb=-$y3
color=12
line
xa=-$x2 ;
ya=-$y2 ; xb=-$x3 ; yb=-$y3
color=12
line
# Linies 2-3'
xa=$x2 ;
ya=-$y2 ; xb=$x50p ; yb=-$y50p ; color=9 ; line
xa=$x50p ;
ya=-$y50p ; xb=$x51p ; yb=-$y51p ; color=10 ; line
xa=$x51p ;
ya=-$y51p ; xb=$x52p ; yb=-$y52p ; color=13 ; line
xa=$x52p ;
ya=-$y52p ; xb=$x3p ; yb=-$y3p ; color=8 ; line
xa=-$x2 ;
ya=-$y2 ; xb=-$x50p ; yb=-$y50p ; color=9 ; line
xa=-$x50p ;
ya=-$y50p ; xb=-$x51p ; yb=-$y51p ; color=10 ; line
xa=-$x51p ;
ya=-$y51p ; xb=-$x52p ; yb=-$y52p ; color=13 ; line
xa=-$x52p ;
ya=-$y52p ; xb=-$x3p ; yb=-$y3p ; color=8 ; line
# Line 1-9
xa=$x1 ;
ya=-$y1 ; xb=$x9 ; yb=-$y9
color=12
line
# Line 2-4
(crossbar)
xa=$x2 ;
ya=-$y2 ; xb=$x4 ; yb=-$y4
color=12
line
xa=-$x2 ;
ya=-$y2 ; xb=-$x4 ; yb=-$y4
color=12
line
# Llegeix
punts de vora de fuga i els dibuixa
npvf=$(grep
"080:" data.txt | awk '{print $5}')
awk '/Vora de
fuga/,/Fi vora/' data.txt > tmp.tmp
x=1 ; #
contador
npvf1=$(echo
"$npvf+1" | bc)
while [ $x
-le $npvf1 ]
do
st1=": " ;
st2=$x ; st3=$st1$st2
xvfb=$(grep
"$st3" tmp.tmp | awk '{print $3}')
yvfb=$(grep
"$st3" tmp.tmp | awk '{print $4}')
if [ $x = 1
]; then
echo
"atenció1" $x
xvfa=$x7 ;
yvfa=$y7
fi
if [ $x =
$npvf1 ]; then
xvfb=$x3p ;
yvfb=$y3p
fi
echo $x
echo $xvfa
$yvfa
echo $xvfb
$yvfb
xa=$xvfa ;
ya=-$yvfa ; xb=$xvfb ; yb=-$yvfb ; color=9 ; line
xa=-$xvfa ;
ya=-$yvfa ; xb=-$xvfb ; yb=-$yvfb ; color=9 ; line
xvfa=$xvfb ;
yvfa=$yvfb
x=$(echo
"$x+1" | bc)
done
x=1
> tmp.tmp
; rm tmp.tmp
# Dibuixa
deflexors
df=$(grep
"011:" data.txt | awk '{print $2}')
if [ $df = 1
]; then
dfini=$(grep
"151:" data.txt | awk '{print $2}')
dfsit=$(grep
"152:" data.txt | awk '{print $2}')
dflon=$(grep
"152:" data.txt | awk '{print $3}')
dffin=$(grep
"153:" data.txt | awk '{print $2}')
xa=$(echo
"scale=4; $dfsit*s($na2)" | bc -l)
ya=$(echo
"scale=4; $dfsit*c($na2)" | bc -l)
xb=$(echo
"scale=4; $xa+$dflon*s($na3)" | bc -l)
yb=$(echo
"scale=4; $ya-$dflon*c($na3)" | bc -l)
color=9
xa=$xa ;
ya=-$ya ; xb=$xb ; yb=-$yb ; line
xa=-$xa ;
ya=$ya ; xb=-$xb ; yb=$yb ; line
fi
# Llegeix
dades de sables i els dibuixa
nps=$(grep
"120:" data.txt | awk '{print $5}')
awk '/Nombre
de sables/,/Fi sables/' data.txt > tmp.tmp
x=1 ; #
contador
while [ $x
-le $nps ]
do
st1=": " ;
st2=$x ; st3=$st1$st2
xsa=$(grep
"$st3" tmp.tmp | awk '{print $3}')
ysa=$(grep
"$st3" tmp.tmp | awk '{print $4}')
sangle=$(grep
"$st3" tmp.tmp | awk '{print $5}')
sllarg=$(grep
"$st3" tmp.tmp | awk '{print $6}')
xsb=$(echo
"scale=4; $xsa-$sllarg*s($sangle*$pi/180)" | bc -l)
ysb=$(echo
"scale=4; $ysa-$sllarg*c($sangle*$pi/180)" | bc -l)
xa=$xsa ;
ya=-$ysa ; xb=$xsb ; yb=-$ysb ; color=7 ; line
xa=-$xsa ;
ya=-$ysa ; xb=-$xsb ; yb=-$ysb ; color=7 ; line
x=$(echo
"$x+1" | bc)
done
# Dibuix
antipicats
atd=$(grep
"141:" data.txt | awk '{print $2}')
atl=$(grep
"141:" data.txt | awk '{print $3}')
ata=$(grep
"141:" data.txt | awk '{print $4}')
if [ $atd -le
100 ]; then
xxa=$x3p ;
yya=$y3p ; xxb=$x52 ; yyb=$y52
alpha=$(echo
"scale=6; a(($yyb-$yya)/($xxb-$xxa))" | bc -l)
gam=$(echo
"scale=4; $ata*($pi/180)-(0.5*$pi-$alpha)" | bc -l)
xxp=$(echo
"scale=4; $x3p-$atd*c($alpha)" | bc -l)
yyp=$(echo
"scale=4; $y3p-$atd*s($alpha)" | bc -l)
xxq=$(echo
"scale=4; $xxp-$atl*s($gam)" | bc -l)
yyq=$(echo
"scale=4; $y3p+$atl*c($gam)" | bc -l)
# xa=$xxp ;
ya=-$yyp ; xb=$xxq ; yb=-$yyq ; color=12 ; line
fi
echo END
>> 1.dxf
# qcad 1.dxf
Data file
example:
000: HANG
GLIDER DATA
001: Bennett
001: Phoenix
6b
010: 0 Tips
011: 0
Deflexors
012: 1 Sables
049:
Paràmetres bàsics
050: 100
angle de morro
051: 330 punt
crossbar
052: 625
llarg vora d'atac
053:
(-12.0) deflexió vora d'atac
054: 200
centre crossbar
055: 210 punt
triangle
056: 215 punt
antena
057: 340
màxima corda
058: 375 punt
cable
059: 426 punt
quilla
060: 150
antena
061: 155
barra control
062: 160
montant
063:
7 sobremontant
070:
2 billow angle
079: Vora de
fuga
080: Nombre
de punts 7
081:
1 50 330
082: 2
100 325
083:
3 200 340
084:
4 300 370
085:
5 380 395
086:
6 435 410
087:
7 475 410
090: Fi vora
119: Sables
120: Nombre
de sables 6
121:
1 100 325
0 236
122:
2 200 340
0 170
123:
3 300 370
0 120
124:
4 380 395
12 93
125:
5 435 410
12 50
126:
6 475 410
18 30
130: Fi sables
140:
Antipicats
141:
40 50 130
150: Deflexors
151: 100 Inici
152: 325
15 Situació i llarg
153: 600 final
return to Laboratori d'envol