Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: is my subject looking at the target?

Subject: is my subject looking at the target?

From: Dave Rowland

Date: 28 Jan, 2008 03:34:01

Message: 1 of 3

I am trying to write a bit of code that will allow me to
determine when a subject is gazing at an object in space.
Here is what I have to work with:
1. Position of the subject (X and Y coordinates, we ignore Z)
2. The angle of the head
3. The position of the object (again X and Y)
What I need to do is first create a target around the object
position (a circle centered at the object position with some
user defined radius) and then determine if the subject is
gazing at the target (a simple yes or no).
This should be straightforward, but I am new to Matlab and
am having a hard time coming up with a solution. If anyone
can help, that would be great. Thanks!

Subject: Re: is my subject looking at the target?

From: Roger Stafford

Date: 28 Jan, 2008 13:09:02

Message: 2 of 3

"Dave Rowland" <rowland@uoneuro.uoregon.edu> wrote in message <fnjif9
$59p$1@fred.mathworks.com>...
> I am trying to write a bit of code that will allow me to
> determine when a subject is gazing at an object in space.
> Here is what I have to work with:
> 1. Position of the subject (X and Y coordinates, we ignore Z)
> 2. The angle of the head
> 3. The position of the object (again X and Y)
> What I need to do is first create a target around the object
> position (a circle centered at the object position with some
> user defined radius) and then determine if the subject is
> gazing at the target (a simple yes or no).
> This should be straightforward, but I am new to Matlab and
> am having a hard time coming up with a solution. If anyone
> can help, that would be great. Thanks!
--------
  Let (xs,ys) be coordinates of the subject's position [1.] and (xt,yt) be those
of the target [3.]. Let 'as' be the angle of the subject's head [2.]. Finally, let r
be the user-defined radius.

 d2 = (xt-xs)^2+(yt-ys)^2-r^2; % Square of dist. to tangent pt.
 if d2 >= 0
  ah = atan2(r,sqrt(d2)); % Half of target's projected arc
  at = atan2(yt-ys,xt-xs); % Angle from subject to target
  df = mod(at-as+pi,2*pi)-pi; % Difference in angles
  if abs(df) <= ah
   fprintf('Subject is gazing at object.\n')
  else
   fprintf('Subject is not gazing at object.\n')
  end
 else
  fprintf('Subject is inside circle.\n')
 end

Roger Stafford

Subject: Re: is my subject looking at the target?

From: Dave Rowland

Date: 05 Feb, 2008 01:19:02

Message: 3 of 3

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
wrote in message <fnkk5e$o5g$1@fred.mathworks.com>...
> "Dave Rowland" <rowland@uoneuro.uoregon.edu> wrote in
message <fnjif9
> $59p$1@fred.mathworks.com>...
> > I am trying to write a bit of code that will allow me to
> > determine when a subject is gazing at an object in space.
> > Here is what I have to work with:
> > 1. Position of the subject (X and Y coordinates, we
ignore Z)
> > 2. The angle of the head
> > 3. The position of the object (again X and Y)
> > What I need to do is first create a target around the object
> > position (a circle centered at the object position with some
> > user defined radius) and then determine if the subject is
> > gazing at the target (a simple yes or no).
> > This should be straightforward, but I am new to Matlab and
> > am having a hard time coming up with a solution. If anyone
> > can help, that would be great. Thanks!
> --------
> Let (xs,ys) be coordinates of the subject's position
[1.] and (xt,yt) be those
> of the target [3.]. Let 'as' be the angle of the
subject's head [2.]. Finally, let r
> be the user-defined radius.
>
> d2 = (xt-xs)^2+(yt-ys)^2-r^2; % Square of dist. to
tangent pt.
> if d2 >= 0
> ah = atan2(r,sqrt(d2)); % Half of target's projected arc
> at = atan2(yt-ys,xt-xs); % Angle from subject to target
> df = mod(at-as+pi,2*pi)-pi; % Difference in angles
> if abs(df) <= ah
> fprintf('Subject is gazing at object.\n')
> else
> fprintf('Subject is not gazing at object.\n')
> end
> else
> fprintf('Subject is inside circle.\n')
> end
>
> Roger Stafford
>
thanks! it's working well.

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics