law_cosines.html


001| ####################################################################################################
002| from sys import argv
003| from os import path
004| from math import sqrt, cos, radians
005| from goodies import KWARG, typename, divisions
006| ####################################################################################################
007| BasePath = r'C:\CJS\prj\Python\ws'
008| 
009| 
010| ##================================================================================================##
011| def test_law_of_cosines ():
012|     '''Test the law of cosines.'''
013| 
014|     def lawofcosine (va, vb):
015|         r1,a1 = va
016|         r2,a2 = vb
017|         return sqrt(pow(r1,2) + pow(r2,2) + (2 * r1 * r2 * cos(radians(a2-a1))))
018| 
019|     v1 = [1, 0]
020|     v2 = [1, 90]
021|     v3 = [5, 0]
022| 
023|     print(f'|v1+v2| = {lawofcosine(v1,v2)}')
024|     print(f'|v3+v2| = {lawofcosine(v3,v2)}')
025|     print(f'')
026|     print()
027| 
028|     return (v1, v2, v3)
029| 
030| 
031| ##================================================================================================##
032| def main (*args):
033|     rv = ()
034|     #rv = test_law_of_cosines()
035|     return rv
036| ####################################################################################################
037| if __name__ == '__main__':
038|     print(argv[0])
039|     print()
040|     rv = main(*argv[1:])
041|     print()
042| ####################################################################################################
043| '''eof'''
044|