We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › calculating X & Y
Page Index Toggle Pages: 1
calculating X & Y (Read 479 times)
calculating X & Y
Jun 26th, 2008, 1:52pm
 
Hi.
I attached four pressure sensors on the corners of a pane of glass, so that i get four values to processing (one for each sensor).

is it possible to calculate an XY-position out of these values? how do i have to do it?
Re: calculating X & Y
Reply #1 - Jun 26th, 2008, 2:15pm
 
I guess so. Have you tried something like a linear interpolation? Say your pressure sensors are calibrated and returning values from 0.0 to 1.0 :

Code:
float rightPressure = 0.5*(upRightCornerPressure + downRightCornerPressure);
float leftPressure = 0.5*(upLeftCornerPressure + downLeftCornerPressure);
float x = paneWidth*(rightPressure-leftPressure);

and same for y with up/down pressure calculation.
Re: calculating X & Y
Reply #2 - Jun 26th, 2008, 2:19pm
 
that's what i was looking for. thanks alot!
Re: calculating X & Y
Reply #3 - Jun 26th, 2008, 4:27pm
 
i think there has to be a more advanced calculation of the position since there are several problems with this method.

- i want the normal position (no = pressure) to be in the center.

- if i press right in the middle, the values i get are all > 0 but the position has still to be the normal position.

i wrote a skech to help understanding my problem: PressureSimulation.

in this sketch the position is calculated like this:
Code:
float calcX(){
   float rightPressure = 0.5 * (ruler_2.value + ruler_3.value);
   float leftPressure = 0.5 * (ruler_1.value + ruler_4.value);
   float x = width * (rightPressure-leftPressure);
   return x;
}

float calcY(){
   float upPressure = 0.5 * (ruler_1.value + ruler_2.value);
   float downPressure = 0.5 * (ruler_3.value + ruler_4.value);
   float y = height * (downPressure-upPressure);
   return y;
}
Re: calculating X & Y
Reply #4 - Jun 28th, 2008, 10:03pm
 
my mistake, I forgot something in the parenthesis ;-)
Code:
float x = width * (0.5 - rightPressure-leftPressure);
float y = height * (0.5 - downPressure-upPressure);
Page Index Toggle Pages: 1