Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2011-09-16 17:16:48

model
Member
Registered: 2011-08-10
Posts: 142

Problem : Angle from current location to previous location

I have detected my hand from center point of pal m.

I maintained current and previous location of my hand w.r.t  center point  .

I need to find angle of center point of palm . and then apply the condition for hand moved to left side or right side .
...
Problem is angle. I have tested two ways or method for finding an angle of center point of palm .

1. firstly , I tested angle using concept " change in y - axies w.r.t distance between current and previous location . " .
formula for that : SIN (angle) = abs(p1.y-p2.y)/sqrt(
(p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y))

but this method give me angle near to 0.0144454 or some thng like that which is almost near to 0 . either my hand move to left side or right side .

2. Secondl method :

If i consider the unit circle .then i tested angle using atan( y /x ) which give me result also -0.0545454 some thing like that .

So i am confus regarding angle .. for finding the hand direction ..

But i am thinking if i consider a reference point O ( 0 , 0) and then using vector concept , apply dot or cross product and get angle .

I am not sure . Can some one please guide me thanks

Please help me urgently thanks


Maths is Doctor that make our life easy .. smile smile

https://www.facebook.com/groups/Maths.GIS/

Offline

#2 2011-09-16 19:54:48

Bob
Administrator
Registered: 2010-06-20
Posts: 10,583

Re: Problem : Angle from current location to previous location

hi model,

Could it be you've got an answer in radians rather than degrees?

For P1 = (2,2) and P2 = (3,3) you should be getting 45.  In radians this is 0.785398

If so, multiply by 180 and divide by pi.

Bob


Children are not defined by school ...........The Fonz
You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you!  …………….Bob smile

Offline

#3 2011-09-17 18:22:46

model
Member
Registered: 2011-08-10
Posts: 142

Re: Problem : Angle from current location to previous location

Well i got an angle .,but some times my angle come -ve . .


Say , x and y can be -ve and +ve
but angle
ok for example
i have -x and -y
what could be angle
It should be in 3rd quadrent
Does it mean angle here is -ve
or more then 180 and less then 270 , comes in 3rd quadrentand make angle -ve
is ti ?

I need 1st and 3rd quadrant so say  angle is in between 180 and 270 , that mean 3rd quadrant ,.
Does ti mean angle in 3rd  quadrant is -ve ?
if angle can't be -ve then how can i make it +ve ?


Maths is Doctor that make our life easy .. smile smile

https://www.facebook.com/groups/Maths.GIS/

Offline

#4 2011-09-17 18:24:07

model
Member
Registered: 2011-08-10
Posts: 142

Re: Problem : Angle from current location to previous location

also  if i consider periodic function  then

and if angle comes -ve and add 360 in that .. can angle then make +ve ?


Maths is Doctor that make our life easy .. smile smile

https://www.facebook.com/groups/Maths.GIS/

Offline

#5 2011-09-17 18:26:39

model
Member
Registered: 2011-08-10
Posts: 142

Re: Problem : Angle from current location to previous location

bob bundy :  I want to add you on face book .

I maked a maths community . i need mathematician like  you  in our community.

Can i please add you  if you  do't mind . Please  thanks


Maths is Doctor that make our life easy .. smile smile

https://www.facebook.com/groups/Maths.GIS/

Offline

#6 2011-09-17 20:22:56

Bob
Administrator
Registered: 2010-06-20
Posts: 10,583

Re: Problem : Angle from current location to previous location

hi model,

I think I said this before.  When you use arcsin the algorithm returns a value between -90 and + 90.  There is no way for that calculation to 'know' which quantrant the points are in.  But you can add code to work it out;  is p1x > 0 or < 0 for example.

SIN (angle) = abs(p1.y-p2.y)/sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y))

The abs will make all values positive.  If you leave it out you'll sometimes get negative values for the angle.  I think I've got this the right way round in my diagram. 

I would prefer (p2.y - p1.y) in the calculation.  This will reverse the + and - but will then be consistent with the way mathematicians normally describe angles in a coordinate diagram.

I suggest you make up some test data and check.

SIN is periodic but I'm not sure how that arises in your project.

I want to add you on face book

Please don't.  I don't do facebook.  You can, of course, point people to Math Is Fun.

Bob

Last edited by Bob (2011-09-17 20:34:18)


Children are not defined by school ...........The Fonz
You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you!  …………….Bob smile

Offline

#7 2011-09-17 23:54:38

model
Member
Registered: 2011-08-10
Posts: 142

Re: Problem : Angle from current location to previous location

Hi bob bundy,

Well, i used like this

double deltaX =  curntBar_x - prevBar_x;
double  deltaY = curntBar_y - prevBar_y;

double x = pow( deltaX , 2 );
double y = pow( deltaY ,2 );

double distance =  sqrt( x + y );

cout<< " Distance :  " << distance << endl;
cout<< endl;

cout<<" deltaX : " << deltaX <<endl;
cout<<" deltaY : " << deltaY <<endl;

//double angle = curntBar_x - prevBar_x / distance ;

double angle = atan2 ( deltaY , deltaX );

angle =   angle *  ( 180 /PI ) ; //angle in degree

//angle = angle - 90;

cout<< " Angle: " << angle <<endl;

       
if ( ( (-5 < deltaX ) && ( deltaX < 5 ) ) &&  ( ( -5 < deltaY ) && ( deltaY < 5 ) ) )
{
                
    cout<<" Hand not move .. "<<endl;

}
else if( ( ( deltaX > 5 ) || ( deltaX  < -5 ) ) &&  ( ( deltaY > 5 ) || ( deltaY < -5 ) ) )
{
    if( ( 135  > angle ) && ( angle > 0 )  )
     {
        move  right
     }

    else if( ( 315  >  angle ) && ( angle > 135 ) )
    {
         move left
    }
}

just problem is the angle comes -ve ..  what should i do if angle come -ve .

I  ignored angle -ve problem .

Last edited by model (2011-09-17 23:56:11)


Maths is Doctor that make our life easy .. smile smile

https://www.facebook.com/groups/Maths.GIS/

Offline

#8 2011-09-18 03:35:19

Bob
Administrator
Registered: 2010-06-20
Posts: 10,583

Re: Problem : Angle from current location to previous location

hi model,

I've revised my diagram for tangent.  see below.

Last time you posted about this problem I asked you to give more detail about where this fits into the grand project.  I'm still not getting it.

Let me try and be clearer.  Suppose I'm using Pythagoras' theorem.  Then I could show this like so:

Given. Two shorter sides in a right angled triangle.

Process.  Use Pythagoras' theorem

Aim. To find the hypotenuse.

Or to give another example, suppose I'm trying to calculate my speed.

Given.  The distance I've travelled.  The time I've taken.

Process Compute distance / time

Aim. To find my average speed.

My problem with your questions is this.

I know this

Given.  Previous coordinates and current coordinates

Process.  Use asin.  Use atan.  Test whether the point has moved left or right. Think about quadrants.  Think about periodic angles .... the list is long but .........

Aim.  I don't know this at all.  What do you want to output at the end?

Once I'm completely clear about this, I'll know where we are heading.

Bob

Last edited by Bob (2011-09-18 03:36:57)


Children are not defined by school ...........The Fonz
You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you!  …………….Bob smile

Offline

#9 2011-09-18 04:00:46

model
Member
Registered: 2011-08-10
Posts: 142

Re: Problem : Angle from current location to previous location

Hi ,

Output :

program should print your direction of  your particles according to quadrant where it  leads  .
like particles  are at right side or left side .  or  Program should print  particle  location in a quadrant.s.


Maths is Doctor that make our life easy .. smile smile

https://www.facebook.com/groups/Maths.GIS/

Offline

#10 2011-09-18 04:03:54

Bob
Administrator
Registered: 2010-06-20
Posts: 10,583

Re: Problem : Angle from current location to previous location

hi model,

Let's stay on line while we sort this.

Bob


Children are not defined by school ...........The Fonz
You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you!  …………….Bob smile

Offline

#11 2011-09-18 04:05:41

Bob
Administrator
Registered: 2010-06-20
Posts: 10,583

Re: Problem : Angle from current location to previous location

If you want to know which quadrant a particle is in, then no angle needed.  You can test like this:

if x > 0 and y > 0 then "Particle is in 1st quadrant"

If x > 0 and y < 0 then "Particle is in 4th quadrant"

etc etc

Bob


Children are not defined by school ...........The Fonz
You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you!  …………….Bob smile

Offline

#12 2011-09-18 04:07:35

Bob
Administrator
Registered: 2010-06-20
Posts: 10,583

Re: Problem : Angle from current location to previous location

For where is a particle headed you could do

if curntX > prevX then "Particle has moved right"

if curntY > prevY then "Particle has moved up"

etc etc

But why have you gone off line?

Bob

Last edited by Bob (2011-09-18 04:08:26)


Children are not defined by school ...........The Fonz
You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you!  …………….Bob smile

Offline

#13 2011-09-18 04:13:57

model
Member
Registered: 2011-08-10
Posts: 142

Re: Problem : Angle from current location to previous location

ahh i see . ,,

Actually i want to apply angle because that may  help me in future regarding this project ,.

That's  way  i am preferring angle..

I am online ., infact you  appeared  offline . .:( sad

Last edited by model (2011-09-18 04:16:15)


Maths is Doctor that make our life easy .. smile smile

https://www.facebook.com/groups/Maths.GIS/

Offline

#14 2011-09-18 04:17:49

model
Member
Registered: 2011-08-10
Posts: 142

Re: Problem : Angle from current location to previous location

ok tell  me about -ve  angle ..  Does -ve angle not good ?
or There is  not any -ve  exist . i am not sure about that .
if so   and i get -ve angle how can we make it +ve ???


Maths is Doctor that make our life easy .. smile smile

https://www.facebook.com/groups/Maths.GIS/

Offline

#15 2011-09-18 04:48:41

Bob
Administrator
Registered: 2010-06-20
Posts: 10,583

Re: Problem : Angle from current location to previous location

help me in future regarding this project

Tell me how you will use the angle.

Bob

Last edited by Bob (2011-09-18 04:49:06)


Children are not defined by school ...........The Fonz
You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you!  …………….Bob smile

Offline

#16 2011-09-18 04:49:03

model
Member
Registered: 2011-08-10
Posts: 142

Re: Problem : Angle from current location to previous location

ohh now you  are online ./. smile  smile

I am not sure  how  angle can help me in future project , but i am really interested to find  object position in quadrant using angle concept s/

Last edited by model (2011-09-18 04:50:13)


Maths is Doctor that make our life easy .. smile smile

https://www.facebook.com/groups/Maths.GIS/

Offline

#17 2011-09-18 04:55:46

Bob
Administrator
Registered: 2010-06-20
Posts: 10,583

Re: Problem : Angle from current location to previous location

I am not sure  how  angle can help me in future project

??  Cannot help until I know this  ??

I suggest you work with the ideas from posts #11 and #12 for now.

Get that working satisfactorily.

Later , when you realise you have a reason for wanting to use angles, post again telling me the reason.  I'll keep subscribed to this thread so I can pick it up in a few days or weeks.

Bob

Last edited by Bob (2011-09-18 04:56:49)


Children are not defined by school ...........The Fonz
You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you!  …………….Bob smile

Offline

Board footer

Powered by FluxBB