![]() |
#1
|
|||
|
|||
Offset Problem
I'm was playing around with my program and I realized that when the bird (i'm using a flock of birds) is at rest, Vizard is registering it as if it were pitching x degrees.
So I was wondering if I could just offset the pitch by "zeroing" it out at the beginning. So I set this up: Code:
offset = 0 # redefined later def DoSample0(): global flock1, flock2, flock3, flock4, MainView, myMaze, offset, data1 #, CurrentLocation #, CheckHeading #Collect sample here data1 = flock1.get() #CurrentLocation = data1 data2 = flock2.get() data3 = flock3.get() data4 = flock4.get() HEADLAT = data1[0] HEADVERT = data1[1] HEADAP = data1[2] HEADYAW = data1[3] HEADPITCH = data1[4] HEADROLL = data1[5] HIPLAT = data2[0] HIPVERT = data2[1] HIPAP = data2[2] HIPYAW = data2[3] HIPPITCH = data2[4] HIPROLL = data2[5] KNEELAT = data3[0] KNEEVERT = data3[1] KNEEAP = data3[2] KNEEYAW = data3[3] KNEEPITCH = data3[4] KNEEROLL = data3[5] ANKLELAT = data4[0] ANKLEVERT = data4[1] ANKLEAP = data4[2] ANKLEYAW = data4[3] ANKLEPITCH = data4[4] ANKLEROLL = data4[5] head_data = str(Subnum) + '\t' + str(Trial) + '\t' + str(HEADAP) + '\t' +str(HEADLAT) + '\t' +str(HEADVERT) + '\t' +str(HEADYAW) + '\t' +str(HEADPITCH) + '\t' +str(HEADROLL) +'\n' tracking_data.write(head_data) hip_data = str(Subnum) + '\t' + str(Trial) + '\t' + str(HIPAP) + '\t' +str(HIPLAT) + '\t' +str(HIPVERT) + '\t' +str(HIPYAW) + '\t' +str(HIPPITCH) + '\t' +str(HIPROLL) +'\n' tracking_data2.write(hip_data) knee_data = str(Subnum) + '\t' + str(Trial) + '\t' + str(KNEEAP) + '\t' +str(KNEELAT) + '\t' +str(KNEEVERT) + '\t' +str(KNEEYAW) + '\t' +str(KNEEPITCH) + '\t' +str(KNEEROLL) +'\n' tracking_data3.write(knee_data) ankle_data = str(Subnum) + '\t' + str(Trial) + '\t' + str(ANKLEAP) + '\t' +str(ANKLELAT) + '\t' +str(ANKLEVERT) + '\t' +str(ANKLEYAW) + '\t' +str(ANKLEPITCH) + '\t' +str(ANKLEROLL) +'\n' tracking_data4.write(ankle_data) MainView.translate(data1[0],data1[1]+1,data1[2]) if myMaze.mazeType == 7: # No distortion for baseline MainView.rotate(data1[3], (data1[4] - offset) ,data1[5]) else: MainView.rotate(-data1[3], -(data1[4] - offset) ,data1[5]) def onkeydown(key): global pressed_S, pressed_Q, maze7, offset, data1 # global StartTime if key == ' ': #Mazetracking.start() #Writeflag( ) offset = data1[4] However, I keep getting an error that says global variable data1 is not defined...and I'm confused because I thought I defined it and I thought I made it available where necessary. Am I missing something? The other option is that my function to calculate the pitch is off. Any suggestions? Here is my pitch function: Code:
def findPitch(self, ptFrom=[0,0,0], ptTo=[0,0,0]): lenHypot = vizmat.Distance(ptFrom, ptTo)#, dimensions=3) # lenRise = ptFrom[1] - ptTo[1] # if (lenRise == 0): return (0) # pitch = zero if two points are at equal height pitch = math.asin(float(abs(lenRise)) / float(lenHypot) ) # Determine magnitude of pitch pitch *= [-1, 1][(lenRise <= 0)] # Determine sign of pitch return ((pitch/math.pi) * 180) #print lenHypot #print lenRise |
Thread Tools | |
Display Modes | Rate This Thread |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Vertex shader performance problem | Joran | Vizard | 2 | 11-17-2008 02:29 AM |
export problem | bazelaisr | Vizard | 2 | 05-28-2008 11:19 AM |
5DT Data Glove 5 Ultra Problem | bjgold | Vizard | 1 | 08-08-2006 05:08 PM |
problem with female animations | vmonkey | Vizard | 1 | 10-07-2005 11:36 AM |
PROBLEM: Picture-in-Picture breaks textures?!? | vcarlson | Vizard | 4 | 10-05-2004 05:22 PM |