Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Averages-Mean-angle/Jq/averages-mean-angle-1.jq
Normal file
19
Task/Averages-Mean-angle/Jq/averages-mean-angle-1.jq
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
def pi: 4 * (1|atan);
|
||||
|
||||
def deg2rad: . * pi / 180;
|
||||
|
||||
def rad2deg: if . == null then null else . * 180 / pi end;
|
||||
|
||||
# Input: [x,y] (special handling of x==0)
|
||||
# Output: [r, theta] where theta may be null
|
||||
def to_polar:
|
||||
if .[0] == 0
|
||||
then [1, if .[1] > 5e-14 then pi/2 elif .[1] < -5e-14 then -pi/2 else null end]
|
||||
else [1, ((.[1]/.[0]) | atan)]
|
||||
end;
|
||||
|
||||
def from_polar: .[1] | [ cos, sin];
|
||||
|
||||
def abs: if . < 0 then - . else . end;
|
||||
|
||||
def summation(f): map(f) | add;
|
||||
15
Task/Averages-Mean-angle/Jq/averages-mean-angle-2.jq
Normal file
15
Task/Averages-Mean-angle/Jq/averages-mean-angle-2.jq
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# input: degrees
|
||||
def mean_angle:
|
||||
def round:
|
||||
if . == null then null
|
||||
elif . < 0 then -1 * ((- .) | round) | if . == -0 then 0 else . end
|
||||
else ((. + 3e-14) | floor) as $x
|
||||
| if ($x - .) | abs < 3e-14 then $x else . end
|
||||
end;
|
||||
|
||||
map( [1, deg2rad] | from_polar)
|
||||
| [ summation(.[0]), summation(.[1]) ]
|
||||
| to_polar
|
||||
| .[1]
|
||||
| rad2deg
|
||||
| round;
|
||||
2
Task/Averages-Mean-angle/Jq/averages-mean-angle-3.jq
Normal file
2
Task/Averages-Mean-angle/Jq/averages-mean-angle-3.jq
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
([350, 10], [90, 180, 270, 360], [10, 20, 30])
|
||||
| "The mean angle of \(.) is: \(mean_angle)"
|
||||
4
Task/Averages-Mean-angle/Jq/averages-mean-angle-4.jq
Normal file
4
Task/Averages-Mean-angle/Jq/averages-mean-angle-4.jq
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
jq -r -n -f Mean_angle.jq
|
||||
The mean angle of [350,10] is: 0
|
||||
The mean angle of [90,180,270,360] is: null
|
||||
The mean angle of [10,20,30] is: 20
|
||||
Loading…
Add table
Add a link
Reference in a new issue