da http://portal.tugraz.at/portal/page/portal/i_2720/Projects/diggc |
-------------------------------------------------------------------------------------------
import android, time,math
droid = android.Android()
droid.startSensingTimed(1,1000)
time.sleep(2)
while True:
azimuth = droid.sensorsReadOrientation().result[0]
pitch = droid.sensorsReadOrientation().result[1]
roll = droid.sensorsReadOrientation().result[2]
pimezzi = math.pi/2
cosalfa = math.cos(roll-pimezzi)
cosbeta = math.cos(pitch-pimezzi)
dir_maxpendenza = math.degrees(math.atan(cosalfa/cosbeta))
if (pitch < 0):
dir_maxpendenza = dir_maxpendenza + 180
if ((pitch > 0) and (roll < 0)):
dir_maxpendenza = dir_maxpendenza + 360
dir_maxpendenza = (math.degrees(azimuth)+dir_maxpendenza)% 360
print "Strike : " + str(dir_maxpendenza)
ang_maxpendenza = 90-math.degrees(math.acos(math.sqrt((cosalfa*cosalfa)+(cosbeta*cosbeta))))
print "Dip: "+ str(ang_maxpendenza)
droid.stopSensing()
-------------------------------------------------------------------------------------------
Nessun commento:
Posta un commento