WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 05-08-2012, 08:29 AM
victorqx victorqx is offline
Join Date: Apr 2012
Posts: 15
viz.plane() intersect function parameters

Hi all,

A quick question that has me stumped for the entire afternoon. I'm using a Kinect for head tracking and am experimenting with gesture control for moving about. I have a small CAVE (3mx3m) defined where the Kinect is at point (0, 1.6, 2).

I want to find out where a user is pointing to, so that I can move the caveorigin towards that point. My idea was to draw a line from a users hand along the direction of their underarm (using the LEFTHAND and LEFTELBOW markers from the Kinect to get the direction) and find out where it intersects with the x,y plane on z=2.

So, I create a plane(), call setNormal([0, 0, -1]) and setPos([0, 0, 2]). Then I wanted to call the .intersect() method, but that doesn't seem to give me the results I'm looking for. The error message mentions that I need to supply 6 parameters. I've tried supplying [x1,y1,z1,x2,y2,z2] (in various combinations) and [x1,y1,z1,x2-x1,y2-y1,z2-z1] (in various combinations), but the resulting intersection point don't seem to have anything to do with the position of my arm.

Could anyone give me the precise parameters I would have to enter for the .intersect() method of a Plane()? Unfortunately the function specification only mentions 'line' and the actual implementation is in a .dll, so not that easy to get to.


Reply With Quote
Old 05-08-2012, 11:26 AM
Jeff Jeff is offline
WorldViz Team Member
Join Date: Aug 2008
Posts: 2,466
It looks for two lists:

[x,y,z] position of begin point of intersection line.

[x,y,z] position of end point of intersection line.

In the following example code a ball is placed at the intersection point on the quad in the direction the user is looking:
import viz
import vizact
import vizmat

dojo = viz.addChild('dojo.osgb')

import vizshape
quad = vizshape.addQuad(pos=[0,1.5,2],color=viz.SKYBLUE)
ball = vizshape.addSphere(radius=0.02,color=viz.ORANGE)

def showIntersection():
	lineBegin = viz.MainView.getPosition()
	vector = viz.MainView.getMatrix().getForward()
	lineEnd = vizmat.MoveAlongVector(lineBegin,vector,10)
	i = quad.intersect(lineBegin,lineEnd)
	point = i.point
vizact.onkeydown(' ',showIntersection)
Reply With Quote
Old 05-11-2012, 05:34 AM
victorqx victorqx is offline
Join Date: Apr 2012
Posts: 15
Hi Jeff,

Thanks, I got it working. It helps to know that the intersect function expects two points. Also, using the MoveAlongVector function means that there is always an intersect between the lineBegin, lineEnd and the object that is to be intersected.

What didn't help was that I had forgot to use the calibration for the Kinect that was in place for headtracking also for the calibration of limbs. After adding that calibration information it now works fantastic!

Thanks for the help!

Reply With Quote

intersect, plane

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about using function hankiwan Vizard 1 02-15-2010 10:50 AM
return variable from keypress function starbug Vizard 2 01-07-2010 11:14 AM
About intersect function omidbrb Vizard 5 02-24-2009 02:57 AM
Do you know how to send a value for 'pool' to the onActionEnd function? ghazanfar Vizard 1 03-22-2007 10:25 AM

All times are GMT -7. The time now is 11:07 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC