Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

vecmath.sh 1.8 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  1. #!/usr/bin/env bash
  2. # Test the gmt vector application
  3. cat << EOF > vec2d.txt
  4. 2.5 1
  5. 1.5 1
  6. 1 1
  7. 0.5 1
  8. -1.5 1
  9. EOF
  10. cat << EOF > vec3d.txt
  11. 2.5 1 0.5
  12. 1.5 1 1.2
  13. 1 1 -0.5
  14. 0.5 1 2.0
  15. -1.5 1 0.0
  16. EOF
  17. cat << EOF > vecg.txt
  18. 0 0
  19. 0 90
  20. 135 45
  21. -30 -60
  22. EOF
  23. # Use fixed format floats (number of digits of default %lg is unpredictable)
  24. gmt set FORMAT_FLOAT_OUT "%.6e"
  25. # Normalize the 2-D vectors
  26. echo "# gmtvector vec2d.txt -C -N" > result
  27. gmt vector vec2d.txt -C -N >> result
  28. # Normalize the 3-D vectors
  29. echo "# gmtvector vec3d.txt -C -N" >> result
  30. gmt vector vec3d.txt -C -N >> result
  31. # Angles between 2-D vectors and (1,0)
  32. echo "# gmtvector vec3d.txt -C -TD -S1/0" >> result
  33. gmt vector vec3d.txt -C -TD -S1/0 >> result
  34. # Angles between 3-D vectors and (0,0,1)
  35. echo "# gmtvector vec3d.txt -C -TD -S0/0/1" >> result
  36. gmt vector vec3d.txt -C -TD -S0/0/1 >> result
  37. # Angles between geographic vectors and (0,0)
  38. echo "# gmtvector vecg.txt -TD -S0/0 -fg" >> result
  39. gmt vector vecg.txt -TD -S0/0 -fg >> result
  40. # Mean 2-D vectors
  41. echo "# gmtvector vec2d.txt -Am -C" >> result
  42. gmt vector vec2d.txt -Am -C >> result
  43. # Mean 3-D vectors
  44. echo "# gmtvector vec3d.txt -Am -C" >> result
  45. gmt vector vec3d.txt -Am -C >> result
  46. # Mean geo vectors
  47. echo "# gmtvector vecg.txt -Am -fg -E" >> result
  48. gmt vector vecg.txt -Am -fg -E >> result
  49. # Convert 2-D Cartesian to polar r/theta
  50. echo "# gmtvector -A1/1 -Ci" >> result
  51. gmt vector -A1/1 -Ci >> result
  52. # Convert 3-D Cartesian to geographic
  53. echo "# gmtvector -A0.61237/0.61237/0.5 -Ci -fg" >> result
  54. gmt vector -A0.612372436/0.612372436/0.5 -Ci -fg >> result
  55. # 3-D cross product
  56. echo "# gmtvector -A1/1/0 -S0/0/1 -Tx -C" >> result
  57. gmt vector -A1/1/0 -S0/0/1 -Tx -C >> result
  58. # Bisector pole
  59. echo "# gmtvector -A30/30 -S-30/-30 -Tb -fg" >> result
  60. gmt vector -A30/30 -S-30/-30 -Tb -fg >> result
  61. diff -q --strip-trailing-cr result "${src:-.}"/result > fail
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...