  Object Size by Triangulation (Python 3.x)   Determines a remote body size and height from three geological compass inclination measurements and one base distance This code solves a classic triangulation task. Elevations above the horizon are positive, below - negative. 1. Use the compass clinometer to measure elevation $$\alpha$$ to the object’s top; 2. Use the compass clinometer to measure elevation $$\beta$$ to the object’s bottom; 3. Move towards the object by distance Base; 4. Measure elevation $$\gamma$$ to the object’s bottom; 5. Don't forget to add your "eye-height" h.   Download source code: Triangulation_Size.py   import numpy as np class TriangulationSize: def __init__( self, base = 1.0, a = [5.0,4.0,8.0]): self.__angleNames__ = ['alpha', 'beta', 'gamma'] self.Base = base self.angles = np.array( a) self.Verbose = False self.Solve() return def Solve( self): tangents = np.pi * self.angles / 180.0 tangents = np.tan( tangents) dt1 = tangents - tangents try: if dt1 <= 0.0: if self.Verbose: print( "Incorrect input data") self.Distance = -999.25 self.Height = -999.25 self.Size = -999.25 return self.Distance = self.Base * tangents / dt1 self.Height = self.Distance * tangents self.Size = (self.Distance+self.Base) * tangents self.Size -= self.Height except: if self.Verbose: print( "Incorrect input data") self.Distance = -999.25 self.Height = -999.25 self.Size = -999.25 return def Print( self): if self.Verbose: print( "Base = {:.3f}".format( self.Base)) print( "Angles = {:.1f} {:.1f} {:.1f}".format( self.angles, self.angles, self.angles)) print( "Solution:") print( "Distance = {:.3f}".format( self.Distance)) print( "Height = {:.3f}".format( self.Height)) print( "Size = {:.3f}".format( self.Size)) return def SolveInteractive( self): self.Base, self.angles = self.__getInput__( "Base {:s} {:s} {:s}".format( self.__angleNames__, self.__angleNames__, self.__angleNames__)) self.Solve() self.Print() return def __getInput__(self, question): i = 0 s = str( input( question + " = ")) ss = s.split(" ") try: a = float( ss) except: a = 1.0 try: b = float( ss) except: b = 0.0 try: c = float( ss) except: c = 0.0 try: d = float( ss) except: d = 0.0 return a, np.array( [b,c,d]) ## ## Uncomment for testing ## ##print( "Test complete data") ##T = TriangulationSize(30.0, [12.0,10.0,17.0]) ##T.Print() ## ##print( "\nTest incomplete data") ##T.angles = np.array([8.0,8.0,8.0]) ##T.Solve() ##T.Print() ## print( "Triangulation for object height.\nUse positive angles above horizon and neqative below.\nSend Control-C to stop.\n") T = TriangulationSize() T.Verbose = True while True: T.SolveInteractive() print("") (C) M.Yakimov, 2006 