View Single Post
  #1  
Old 12-20-2011, 01:55 PM
starlingstm starlingstm is offline
Member
 
Join Date: May 2011
Posts: 19
Converting floats

I'm working on a project that instruct students on how to connect a 6 Bar Quick Return using ARtoolkit. So far I'm able to track the marker and receive/print the position. My goal: when the students match the assigned location of a marker, their prompted to move to the next connection. I wrote an 'if' statement with assigned location for the x,y,z coordinates, but I need to know how to equate the x,y,z coordinates with a pre-set number. Below is my coding. I don't get an error message, the code skips down to the else statement. Some how I need to convert the float to integers or vise versa.

import viz
import vizact
import vizshape
viz.go()

ar = viz.add('artoolkit.dle')

camera = ar.addWebCamera()
board = camera.addMatrixMarker(0,width=1000)
camera.setGlobalMarker(board)



box = camera.addMatrixMarker(1,width=1000)


def showData():
for number in range(5):
box_pos = box.getPosition(viz.REL_GLOBAL)
for pos in box_pos:
if box_pos [0] == -2.0 and box_pos[1] == -3.0 and box_pos[2] == 14.0:
print box_pos, 'Box is connected properly; Move to the next connection'

else:
print box_pos



vizact.ontimer(2,showData)
Reply With Quote