Math Is Fun Forum

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

You are not logged in.

#1 2014-12-01 15:04:42

pari_alf
Member
Registered: 2013-12-01
Posts: 85

8 numbers of angle direction

i have these points.. x,y coordinates

250 466
257 464
250 466
256 453
270 408
295 347
370 270
463 266
465 297
464 282
455 287
450 289
447 294

I wanna represent each angle of point in 8 numbers
Previously i tried to work with 16 numbers of directions but this time .. i wanna give try with 8 numbers of angle direction..
Could any one help me how can i do it,
thanks

Offline

#2 2014-12-01 17:25:13

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: 8 numbers of angle direction

This is what those points look like when graphed. What is supposed to happen now?

avA1O7r.png


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#3 2014-12-01 17:52:13

pari_alf
Member
Registered: 2013-12-01
Posts: 85

Re: 8 numbers of angle direction

bobbym wrote:

This is what those points look like when graphed. What is supposed to happen now?

http://i.imgur.com/avA1O7r.png

Well, what i wanna is .. assign the 8 direction codes to each angle of line segment.

the 8 direction code is given below.
8_direction_code.jpg

Offline

#4 2014-12-01 20:49:04

pari_alf
Member
Registered: 2013-12-01
Posts: 85

Re: 8 numbers of angle direction

Let me consider a good example of shape round.

the x,y points of the round shape is given below.
@ 0: [260, 308]
@ 1: [209, 324]
@ 2: [201, 375]
@ 3: [242, 438]
@ 4: [275, 445]
@ 5: [337, 397]
@ 6: [343, 365]
@ 7: [302, 318]
@ 8: [235, 312]

and these points are graphysically shown below.
simplifiy_Line1.jpg

Now.. In order to assign the 8 numbers to each line segment based on its angle..
i performed the following steps

1. compute angle
2. angle divide by 45 and add 0.5
3. take the integer part
4. subtract from 8
5. use mod 8, to get the number in range.

This method is actually someone answered me on my post of assigning 16 numbers to segments .

But since i now working on 8 numbers of direction of each segment based on angle . so instead of 16, i am using 8..

Ok.. the result i got is as follows...

features_DC0.jpg

Is it correct? I think my 8 number to direction of each segment is not correct.

need suggestion.. and correction.. thanks

Offline

#5 2014-12-01 21:46:19

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

Re: 8 numbers of angle direction

hi pari_alf

The image is too small for me to make out the direction codes.

I suggest you post the calculations for each stage of the algorithm:

x, y, dx, dy, unmodified atan value, corrected angle, calculated direction code.

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

#6 2014-12-01 22:36:28

pari_alf
Member
Registered: 2013-12-01
Posts: 85

Re: 8 numbers of angle direction

The image is attached again in the below fig

8_direct_result.jpg

The x,y coordinates are as follows

@ 0 : [260,308]
@ 1 : [209,324]
@ 2 : [201,375]
@ 3 : [242,438]
@ 4 : [275,445]
@ 5 : [337,397]
@ 6 : [343,365]
@ 7 : [302,318]
@ 8 : [235,312]

... the following are the dx, dy and its angle in radian and degree//
dx , dy : -51 16

angle in radian : 2.83759

angle in degree : 162.582

dx , dy : -8 51

angle in radian : 1.72639

angle in degree : 98.9149

dx , dy : 41 63

angle in radian : 0.993863

angle in degree : 56.9442

dx , dy : 33 7

angle in radian : 0.209023

angle in degree : 11.9761

dx , dy : 62 -48

angle in radian : -0.658806

angle in degree : -37.7468

dx , dy : 6 -32

angle in radian : -1.38545

angle in degree : -79.3803

dx , dy : -41 -47

angle in radian : -2.28812

angle in degree : -131.1

dx , dy : -67 -6

angle in radian : -3.05228

angle in degree : -174.883

Next , below are the direction codes
Calculated direction Codes
4 6 7 0 0 1 2 3

Offline

#7 2014-12-02 01:28:07

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

Re: 8 numbers of angle direction

OK.  My dy/dx values are the same as yours.  But I've got different angles and codes.  I seem to remember that you have different directions for your + y axis so that probably explains the difference.  Here's what I am using:

OsBjnWI.gif

So my + y is up and my angles are measured anticlockwise from the +x axis.

I'll change this so I'm the same as you, if you say what you'd like.  Then I can check the rest of your results.  smile

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

#8 2014-12-02 02:12:34

pari_alf
Member
Registered: 2013-12-01
Posts: 85

Re: 8 numbers of angle direction

I think you please change it so that you will get same like mine.
Than we can go further easily .. smile

Offline

#9 2014-12-02 05:44:35

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

Re: 8 numbers of angle direction

I will;  but you have not said what yours is.  dizzy

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

#10 2014-12-02 14:33:16

pari_alf
Member
Registered: 2013-12-01
Posts: 85

Re: 8 numbers of angle direction

I think my coordinates are window screen coordinates like shown below

screen_window_coordinates.jpg

Offline

#11 2014-12-02 17:19:53

pari_alf
Member
Registered: 2013-12-01
Posts: 85

Re: 8 numbers of angle direction

bob bundy wrote:

I will;  but you have not said what yours is.  dizzy

Bob

Can you reply me quickly.. i need to fix the problems..

Offline

#12 2014-12-02 19:58:54

pari_alf
Member
Registered: 2013-12-01
Posts: 85

Re: 8 numbers of angle direction

anyone can help me to get the 8 numbers of directions based on its angle?

Offline

#13 2014-12-02 20:10:08

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

Re: 8 numbers of angle direction

Please also say where you want the angles to be measured from, in what direction.

B


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

#14 2014-12-02 20:27:28

pari_alf
Member
Registered: 2013-12-01
Posts: 85

Re: 8 numbers of angle direction

Well..  if you see the figure.. Figure already show the start point in green color and end point in the red color. So i think, it is easy to say where would be direction.

these are the points

@ 0 : [260,308]
@ 1 : [209,324]
@ 2 : [201,375]
@ 3 : [242,438]
@ 4 : [275,445]
@ 5 : [337,397]
@ 6 : [343,365]
@ 7 : [302,318]
@ 8 : [235,312]

point at index 0 and 8 are the start and end point.
so i think it is easy to say .. where would be the direction of angle.

Offline

#15 2014-12-03 00:53:17

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,818

Re: 8 numbers of angle direction

Hi Bob,

Please also say where you want the angles to be measured from, in what direction.

From this post of mine on the thread that pari_alf referred to above:

...a line's angle (ie, the angle measured from (a) the horizontal axis of a line's starting point to (b) the next point...)

The below Geogebra image shows those horizontal axes, and the green angle images identify what is measured.

Also, as per pari_alf's drawing, the circular direction of this shape is anti-clockwise, starting from the green point and ending with the red.

All my angles agree with pari_alf's, the difference being that for upward-pointing lines mine show as positive instead of negative.

Because of the difference between Geogebra and pari_alf's method/software, my y coordinates are negative in order to obtain the same shape, which is drawn in the fourth (south-eastern) quadrant (as pari_alf's is...see post #10 above).

iBtitFE.png

Here is an Excel chart of ATan2 calcs...which angles agree with the above.

Yw2l0Qs.png

Last edited by phrontister (2017-02-25 22:22:02)


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#16 2014-12-03 02:17:12

pari_alf
Member
Registered: 2013-12-01
Posts: 85

Re: 8 numbers of angle direction

you are exactly Right @phrontister
Thank you for explaing well. smile

Yes this time,,i am interested in assigning 8 numbers to each direction based on its angle.
Previously, i had come cross with 16 direction code. but now i need to work on 8 direction code. I had already calculated and mention in my reply #6 and method of this is given in reply #5 .

but i am not satisfy with my calculated 8 direction codes.



phrontister wrote:

Hi Bob,

Please also say where you want the angles to be measured from, in what direction.

From this post of mine on the thread that pari_alf referred to above:

...a line's angle (ie, the angle measured from (a) the horizontal axis of a line's starting point to (b) the next point...)

The below Geogebra image shows those horizontal axes, and the green angle images identify what is measured.

Also, as per pari_alf's drawing, the circular direction of this shape is anti-clockwise, starting from the green point and ending with the red.

All my angles agree with pari_alf's, the difference being that for upward-pointing lines mine show as positive instead of negative.

Because of the difference between Geogebra and pari_alf's method/software, my y coordinates are negative in order to obtain the same shape, which is drawn in the fourth (south-eastern) quadrant (as pari_alf's is...see post #10 above).

http://k003.kiwi6.com/hotlink/yr6iz4ugar/Angle_directions.png

Here is an Excel chart of ATan2 calcs...which angles agree with the above.

http://k003.kiwi6.com/hotlink/knuosgxxzd/Angle_directions-Excel.png

Offline

#17 2014-12-03 02:41:47

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,818

Re: 8 numbers of angle direction

So, this means that we are now at exactly the same stage that we reached in the other thread.

There, we'd progressed to the point of working out how to get the angles right, but we couldn't give you a definitive answer on the direction codes because we needed to know ALL the rules by which to determine exactly which code number should be applied in all scenarios that might arise.

See, in particular, my post #51 in that thread.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#18 2014-12-03 04:55:32

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,818

Re: 8 numbers of angle direction

Hi pari_alf,

I adapted the compass in post #46 of the other thread to suit 8 sectors:

3FVyeHe.png

A line's direction code is easily found by checking the compass to ascertain which 45° sector the line's angle falls into. eg, the direction code for the red line with angle -131.0995° would be 3, as it lies between -112.5° and -157.5°.

The following Excel chart shows this too:

4vPOPYy.png

Bob's formula for the direction code of the -131.0995° angle is =MOD(ABS(INT(G9/45+0.5)-8),8), where G9 = -131.0995. Answer = 3.

Your direction code for that angle is 2, which I think is incorrect.

If you agree with what I've done, then I think that the only unanswered question would be about which code should be given to a line that falls exactly on a sector boundary.

Last edited by phrontister (2017-02-25 22:20:18)


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#19 2014-12-03 15:11:36

pari_alf
Member
Registered: 2013-12-01
Posts: 85

Re: 8 numbers of angle direction

hi phrontister,

Thanks for the reply.
If you see my reply #4 and #6, i used the same formula that you used.
that formula gave me same direction codes

Direction Codes
4 6 7 0 0 1 2 3

where 0 should be 1 and last code should be 4, compare to your result.

I used exactly this formula in c++

correct_directCoode =   abs(int( angle/45  + 0.5) - 8 ) % 8

Is there some logical reason for being not correct?

Note: my angles and direction codes are same like yours

phrontister wrote:

Hi pari_alf,

I adapted the compass in post #46 of the other thread to suit 8 sectors:

http://k003.kiwi6.com/hotlink/5t2vndi0jw/Angle_directions_compass_example.png

A line's direction code is easily found by checking the compass to ascertain which 45° sector the line's angle falls into. eg, the direction code for the red line with angle -131.0995° would be 3, as it lies between -112.5° and -157.5°.

The following Excel chart shows this too:

http://k003.kiwi6.com/hotlink/pgz46equ1i/Direction_codes-Excel.png

Bob's formula for the direction code of the -131.0995° angle is =MOD(ABS(INT(G9/45+0.5)-8),8), where G9 = -131.0995. Answer = 3.

Your direction code for that angle is 2, which I think is incorrect.

If you agree with what I've done, then I think that the only unanswered question would be about which code should be given to a line that falls exactly on a sector boundary.

Last edited by pari_alf (2014-12-03 16:48:30)

Offline

#20 2014-12-03 16:59:14

pari_alf
Member
Registered: 2013-12-01
Posts: 85

Re: 8 numbers of angle direction

Why at angle -37.7468, you got direction code 1, and i get 0.

Is that some logical reason orwhat.
I do not get it .




pari_alf wrote:

hi phrontister,

Thanks for the reply.
If you see my reply #4 and #6, i used the same formula that you used.
that formula gave me same direction codes

Direction Codes
4 6 7 0 0 1 2 3

where 0 should be 1 and last code should be 4, compare to your result.

I used exactly this formula in c++

correct_directCoode =   abs(int( angle/45  + 0.5) - 8 ) % 8

Is there some logical reason for being not correct?

Note: my angles and direction codes are same like yours

phrontister wrote:

Hi pari_alf,

I adapted the compass in post #46 of the other thread to suit 8 sectors:

http://k003.kiwi6.com/hotlink/5t2vndi0jw/Angle_directions_compass_example.png

A line's direction code is easily found by checking the compass to ascertain which 45° sector the line's angle falls into. eg, the direction code for the red line with angle -131.0995° would be 3, as it lies between -112.5° and -157.5°.

The following Excel chart shows this too:

http://k003.kiwi6.com/hotlink/pgz46equ1i/Direction_codes-Excel.png

Bob's formula for the direction code of the -131.0995° angle is =MOD(ABS(INT(G9/45+0.5)-8),8), where G9 = -131.0995. Answer = 3.

Your direction code for that angle is 2, which I think is incorrect.

If you agree with what I've done, then I think that the only unanswered question would be about which code should be given to a line that falls exactly on a sector boundary.

Offline

#21 2014-12-03 18:22:19

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,818

Re: 8 numbers of angle direction

Hi pari_alf],

I used exactly this formula in c++

correct_directCoode =   abs(int( angle/45  + 0.5) - 8 ) % 8

Is there some logical reason for being not correct?

I don't know c++, but it looks like your int function doesn't round-down the integer part of the number.

In my previous post I used -131.0995° for the example.

Bob's formula (the one I use in Excel) is =MOD(ABS(INT(-131.0995/45+0.5)-8),8), which evaluates according to the following steps:
-131.0995/45+0.5 = -2.413322'
INT(-2.413322') = -3
-3-8 = -11
ABS(-11) = 11
MOD(11,8) = 3

I think yours is doing this:
-131.0995/45+0.5 = -2.413322'
INT(-2.413322') = -2
-2-8 = -10
ABS(-10) = 10
MOD(10,8) = 2

Btw, Bob gave an alert about this kind of behaviour in his post #31 in the other thread.

The problem seems to arise only with negative angles, so maybe the answer could be to tweak your code: eg, instead of the int function use floor, which rounds down to the next integer as my INT does. That should fix the discrepancies with the negative angles.

Does your code deal with the situation where (using the compass for ease of illustration) a line falls exactly on a sector boundary (eg, if the line angle is 22.5°)? If so, which direction code does it choose?

My code gives the following:
22.5° = 7
67.5° = 6
112.5° = 5
157.5° = 4
-157.5° = 3
-112.5° = 2
-67.5° = 1
-22.5° = 0

The other option, if you were to choose the direction code on the other side of the sector line, is:
22.5° = 0
67.5° = 7
112.5° = 6
157.5° = 5
-157.5° = 4
-112.5° = 3
-67.5° = 2
-22.5° = 1

Here, for your enjoyment, is a little video showing the relationship between my compass (post #18) and the shape (post #15). smile

Last edited by phrontister (2014-12-04 00:11:52)


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#22 2014-12-03 20:42:54

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

Re: 8 numbers of angle direction

hi Phro,

Excellent analysis and video.  smile

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

#23 2014-12-03 21:03:39

pari_alf
Member
Registered: 2013-12-01
Posts: 85

Re: 8 numbers of angle direction

Hi once again,

This time i have confusion.
we got direction in 8 numbers. Well if we consider the below example

direc_Code_exma.jpg

but at first codes do not exactly similar to the codes in circle
i wanna codes like this ...

0 ~ 1 ---> reoresent to 0
1 ~ 2 --> represent to 1
2 ~ 3 --> represent to 2
3 ~ 4 ---> represent to 3
4 to 5 ---> represent to 4
5 to 6 ---> represent 5
6 to 7 reoresent code 4
7 ~ 0 represent code 7.

The coordinate of that image are as follows
@ 0: [251, 141]
@ 1: [286, 78]
@ 2: [367, 92]
@ 3: [402, 146]
@ 4: [372, 234]
@ 5: [309, 258]
@ 6: [248, 242]
@ 7: [232, 205]
@ 8: [258, 129]

Direction Numbers are :
1 0 7 6 4 4 3 2

Last edited by pari_alf (2014-12-03 21:06:20)

Offline

#24 2014-12-04 01:11:06

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,818

Re: 8 numbers of angle direction

pari_alf wrote:

...but at first codes do not exactly similar to the codes in circle
i wanna codes like this ...

0 ~ 1 ---> reoresent to 0
1 ~ 2 --> represent to 1
2 ~ 3 --> represent to 2
3 ~ 4 ---> represent to 3
4 to 5 ---> represent to 4
5 to 6 ---> represent 5
6 to 7 reoresent code 4
7 ~ 0 represent code 7.

I'm sorry, but I don't understand what you're trying to do there. Could you please rephrase what you said?

Also, is all the information in that list correct? There appear to be several inconsistencies in it.

Btw, my direction codes are the same as yours this time, and my drawing too. smile

Last edited by phrontister (2014-12-04 01:11:58)


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#25 2014-12-04 01:14:44

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: 8 numbers of angle direction

Hi pari_alf;

I am sorry that I can not communicate with you by a private means. I could do as you ask but there are other posters in this thread who have done serious work. I will see if they will agree.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

Board footer

Powered by FluxBB