I'm not following what you have done. The diagram has four points and three lines. But you have six coordinates (which should give five direction codes) but only four codes.
Your compass shows measurements clockwise from the positive x axis, but I cannot tell which point is which on your diagram.
You still haven't said what you want to do about angles that fall exactly on a compass line.
Suggestion:
Let's test this with one pair of points at a time. What happens if you have
(1) A = (2.01. 1.01) and B = (6.01,1.01)
(2) C = (1.43, 1.59) and D = (5,34, 3.44)
(3) E = (-2.01, 2.01) and F = (-6.01, 6.01)
Run the code three times using the data from (1) the first time, then (2) then (3).
Bob
]]>Hope you are good.
This time i tested 8 direction codes on above given points
My direction code result is shown in the below image.
The points are
105 66
114 92
104 11
99 131
71 144
37 168
And the 8 direction codes are as follows
2
7
6
6
My method of calculating the direction code is same like you directed me for 16 direction codes.
I used the following steps for calculating the direction Codes
1. take angle
2. divide by 40
3. add 0.5 to round up or down correctly
4. take the integer part
5. subtract from 8 to get the correct rotational direction
6. use mod 8 division to get the numbers in range.
The 8 direction code image is shown below
In the image, numbers are assigned to each direction.
=-----------------------------
But my direction codes seems not correct.
hi pari_alf
So you wish to convert those angles into numbers from 0 to 15 according to the diagram below.
Step 1. Take the calculated angles
result
70 .9...
-97.0....
92.3....
155.0...
144.7....step 2. Divide each by 22.5
result
3.15..
-4.31..
4.10..
6.89..
6.43..step 3. Add 0.5 so that when I use INT I will round up or down correctly
result
3.65..
-3.81..
4.60..
7.39..
6.93..step 4. take the integer part of (note that the negative goes to -4 with my software)
result
3
-4
4
7
6step5. Subtract from 16 to get the correct rotational direction
result
13
20
12
9
10step6. use mod 16 division to get the numbers in range
result
13
4
12
9
10And there you have it. I suggest you check boundary cases such as angle = 90 in case these misbehave.
Bob
From post #44:
I copied your text into an Excel spreadsheet to save having to re-type everything. If you post data again, it would help if you left out all unneeded text and just gave me the numbers.
eg.
x values are
126
172
209etc
then I can copy these straight in rather than having to "MID" out the unwanted characters. Thanks.
Word has a feature that could help with that if the required text is in a vertical block.
Copy the whole text (needed and unneeded) into Word, hold down the Alt key and select the needed text as a vertical block by dragging the cursor down (or up) over it. Like so:
Then copy the selected text into Excel.
Btw, some time back I discovered on another forum a way of entering multiple points into Geogebra's Input bar instead of just one at a time like I did early on with pari_alf's coordinates. However, it's rather cumbersome:
Execute[{"A_0 = (165, -454)","A_1=(238, -321)","A_2= (287, -307)","A_3= (328, -324)","A_4= (337, -378)","A_5= (303, -431)","A_6= (234, -463)","A_7= (315, -427)","A_8= (435, -441)"}]
Using a text editor helps with that, but hopefully Geogebra will simplify multiple-point input one day.
Note: I had to change pari_alf's y-axis coordinates to negative to suit Geogebra.
]]>Yes sorry, i could not give time to it.
Hope you understand.
I will reply to all questions one by one.
Hope it would be ok.
Thanks
hi pari_alf
We have now reached post 53. Your last post was number 45 on April 11th. Since then phrontister has done a lot of work for you which you haven't acknowledged.
On 9th May phrontister asked you several questions about the way you want this to work. You haven't answered him.
The people who give up time to help others on the forum, do not get paid for it. They just do it because they want to be helpful. But it is very hard and discouraging, if the person wanting help doesn't even say whether the help has been understood and appreciated.
Please look back at the last 8 posts and say whether it has made sense. Then answer the questions you have been asked.
Thanks,
Bob
hi pari_alf
I still am unable to answer that without knowing how you computed the angles.
Are you using a calculator? In which case, which one?
Or some software? In which case what software?
How have you determined dy and dx? Please post the actual calculation you did.
Bob
Hi Bob, sorry i did not notice about the questions.
I think i mentioned before that i am computing angle using atan2 (dy / dx)
And i computed dy, dx as follows dx = abs (p2.x - p1.x) , dy = abs (p2.y - p1.y);
I did programming in c++.
]]>We have now reached post 53. Your last post was number 45 on April 11th. Since then phrontister has done a lot of work for you which you haven't acknowledged.
On 9th May phrontister asked you several questions about the way you want this to work. You haven't answered him.
The people who give up time to help others on the forum, do not get paid for it. They just do it because they want to be helpful. But it is very hard and discouraging, if the person wanting help doesn't even say whether the help has been understood and appreciated.
Please look back at the last 8 posts and say whether it has made sense. Then answer the questions you have been asked.
Thanks,
Bob
]]>From post #43:
I am not satisfy with my direction numbers to each angle.
Anyone help me to check it. thanks
Why are you not satisfied with them?
Anyway, the direction codes can't be checked accurately without knowing the angle ranges of the 16 sectors...see the following, from post #44:
You haven't said how you converted these to direction codes, so I went back to my post 31 and applied those steps. For values up to direction code 7, we have the same results. Thereafter, my answers are 1 less than yours. And I get 15 not zero for 32.7.... I'd need to see the code to explain that. It may be something to do with the way the numbers are rounded.
Please also give the exact start and end angles for the sectors ; then I can modify the steps to account for the differences.
eg.
sector 0: 0 ≤ angle < 22.5
To enable me to give you the correct direction codes I need to know:
1. the angle ranges of the sectors (as per Bob's post), and
2. which sector applies to an angle that falls exactly on a sector boundary: eg, is it the sector that is clockwise or anticlockwise to that boundary?
Do you agree with the angle ranges I gave in the image of post #46?
ie,
DC0 = 11.25 to -11.25
DC1 = -11.25 to -33.75
DC2 = - 33.75 to -56.25
etc...
In my recent posts (#46 & since) I'd assumed that the compass format is as per your image (see below) in post #39, where E(0°) seems to fall exactly in the middle of the Direction Code 0 sector. However, I'm not so sure now that my assumption is correct, which is why I need the answers to the above questions.
If E falls exactly in the middle of the Direction Code 0 sector then my calculations in those posts are right (I think), but if E falls anywhere else then my calcs are wrong (but easily fixed).
The circular-sector angles in that image are 45° because the compass has 8 equal sectors, whereas your angles for 16 sectors are 22.5°. Therefore I reckoned that, dividing 45° by 2 because E=0° and E is (seemingly) in the middle of the Direction Code 0 sector, the first sector boundary in that image in an anticlockwise direction from E is 22.5°...which for your puzzle would be -11.25° (including the negative notation for the upward angle).
]]>Notes: 1. The upward angles display as positive values in Geogebra and not negative (unlike with ATan2).
2. You may need to zoom out in your browser to see the whole image (this happened with the forum upgrade).
Geogebra gave the necessary graphical accuracy I needed (and quite quickly, too), as three of the angles (@ 4, @ 23 and @ 26) are extremely close to the Direction Code boundaries and would be difficult to locate correctly by superimposition on a less accurate drawing.
]]>Just let me say that is a beautiful use of geogebra. Wunderbar!
]]>Yes i used the same steps that you gave in post 31.
Using those steps of Bob's on your coordinates from post #43 I got the following direction codes ("DC"), which I've written alongside yours for comparison:
Line your DC my DC
@ 0 1 1
@ 1 1 1
@ 2 1 1
@ 3 1 1
@ 4 12 11
@ 5 12 11
@ 6 10 9
@ 7 10 9
@ 8 10 9
@ 9 15 14
@ 10 0 0
@ 11 1 1
@ 12 2 2
@ 13 2 2
@ 14 2 2
@ 15 7 7
@ 16 1 1
@ 17 1 1
@ 18 0 0
@ 19 0 0
@ 20 13 12
@ 21 13 12
@ 22 12 11
@ 23 12 11
@ 24 12 11
@ 25 13 12
@ 26 14 13
@ 27 0 15
@ 28 2 2
@ 29 2 2
@ 30 2 2
@ 31 1 1
@ 32 0 0
There are 14 differences between your results and mine, so there's a coding error somewhere...
To verify my results I used a different method to check my DCs and got exactly the same answers as with Bob's formula.
My method calculates the actual line directions based on an anticlockwise 360° compass with origin E=0° (as per your post #30). This also gives me a clearer idea of each line's bearing than I was getting from just knowing a line's angle (ie, the angle measured from (a) the horizontal axis of a line's starting point to (b) the next point: this is what the angles listed in your post #43 actually represent). Your angles are correct, btw...according to Geogebra and ATan2 in Excel.
those direction Codes are not matched with the direction of lines of the points of character drawn on the image. So i am still not satisfied.
I've drawn a compass (see image) in Geogebra with angle markings and DCs that follow your method (see post #30). Upward angles are negative (and run anticlockwise), and downward angles are positive (and run clockwise). There are 16 sectors, all with an angle range of 22.5°. They run anticlockwise, with the first one (DC=0) straddling E=0°.
With this image I can easily determine a line's DC from seeing where the line lies on the compass. I did that with all the lines, and got identical DCs to what I got with Bob's formula.
Lines placed on the compass should originate at the crosshair in the centre and from there radiate out to their angle locations at the compass perimeter. The sectors on which the lines lie display the respective DCs in the white-on-blue rectangles.
If you'll use the compass to check the direction of the lines where our DCs differ you'll see that your lines lie in the wrong DC sector...as follows:
Line angle DC sector angle range correct DC your DC
@ 4 101.411 101.25 to 123.75 11 12
@ 5 120.964 101.25 to 123.75 11 12
@ 6 158.199 146.25 to 168.75 9 10
@ 7 158.477 146.25 to 168.75 9 10
@ 8 154.231 146.25 to 168.75 9 10
@ 9 38.6598 33.75 to 56.25 14 15
@ 20 94.9697 78.75 to 101.25 12 13
@ 21 97.3524 78.75 to 101.25 12 13
@ 22 110.136 101.25 to 123.75 11 12
@ 23 123.275 101.25 to 123.75 11 12
@ 24 115.821 101.25 to 123.75 11 12
@ 25 97.7652 78.75 to 101.25 12 13
@ 26 78.6901 56.25 to 78.75 13 14
@ 27 32.7352 11.25 to 33.75 15 0
Btw, you haven't yet cleared up the question of 'boundary cases' that Bob mentioned in post #31. Which DC should be given to a line that falls exactly on a DC boundary?
EDIT: I've just noticed that all those errors (which are out by +1) are for downward lines (ie, those with a positive angle), and the only downward lines for which you got correct DCs are lines @18 and @19. The DCs for all your upward lines (ie, those with a negative angle) are correct.
Note: You may need to zoom out in your browser to see the whole image (this happened with the forum upgrade).
]]>hmm frankly speaking, those direction Codes are not matched with the direction of lines of the points of character drawn on the image. So i am still not satisfied.
Yes i used the same steps that you gave in post 31.
I copied your text into an Excel spreadsheet to save having to re-type everything. If you post data again, it would help if you left out all unneeded text and just gave me the numbers.
eg.
x values are
126
172
209
etc
then I can copy these straight in rather than having to "MID" out the unwanted characters. Thanks.
Excel's atan works slightly differently to your program language so I got some different angles. In the screen shot below I have highlighted these in yellow.
I applied the correction 180 - yellow value and in all but one case that corrected the error. That's probably not something to worry about; it is just the way the software writers have implemented the function.
The one remaining difference is with - 159.281 I don't know why that one is still different. But our direction codes are the same!
You haven't said how you converted these to direction codes, so I went back to my post 31 and applied those steps. For values up to direction code 7, we have the same results. Thereafter, my answers are 1 less than yours. And I get 15 not zero for 32.7.... I'd need to see the code to explain that. It may be something to do with the way the numbers are rounded.
Please also give the exact start and end angles for the sectors ; then I can modify the steps to account for the differences.
eg.
sector 0: 0 ≤ angle < 22.5
Bob
]]>I have these points of the above drawn character
x: 126, y: 279
x: 172, y: 257
x: 209, y: 238
x: 247, y: 230
x: 271, y: 225
x: 249, y: 334
x: 228, y: 369
x: 193, y: 383
x: 122, y: 411
x: 64, y: 439
x: 79, y: 451
x: 128, y: 449
x: 191, y: 416
x: 240, y: 376
x: 264, y: 358
x: 279, y: 343
x: 86, y: 270
x: 110, y: 256
x: 133, y: 246
x: 169, y: 248
x: 199, y: 250
x: 197, y: 273
x: 193, y: 304
x: 182, y: 334
x: 161, y: 366
x: 146, y: 397
x: 143, y: 419
x: 146, y: 434
x: 160, y: 443
x: 185, y: 420
x: 219, y: 390
x: 247, y: 366
x: 289, y: 343
x: 327, y: 340
-----------
and these are the angles computed by atan2 in degree form
@ 0 , Angle: -25.56
@ 1 , Angle: -27.1811
@ 2 , Angle: -11.8887
@ 3 , Angle: -11.7683
@ 4 , Angle: 101.411
@ 5 , Angle: 120.964
@ 6 , Angle: 158.199
@ 7 , Angle: 158.477
@ 8 , Angle: 154.231
@ 9 , Angle: 38.6598
@ 10 , Angle: -2.33731
@ 11 , Angle: -27.646
@ 12 , Angle: -39.2257
@ 13 , Angle: -36.8699
@ 14 , Angle: -45
@ 15 , Angle: -159.281
@ 16 , Angle: -30.2564
@ 17 , Angle: -23.4986
@ 18 , Angle: 3.17983
@ 19 , Angle: 3.81407
@ 20 , Angle: 94.9697
@ 21 , Angle: 97.3524
@ 22 , Angle: 110.136
@ 23 , Angle: 123.275
@ 24 , Angle: 115.821
@ 25 , Angle: 97.7652
@ 26 , Angle: 78.6901
@ 27 , Angle: 32.7352
@ 28 , Angle: -42.6141
@ 29 , Angle: -41.4237
@ 30 , Angle: -40.6013
@ 31 , Angle: -28.706
@ 32 , Angle: -4.51399
---------------
and these are the direction codes.
@ 0 : 1
@ 1 : 1
@ 2 : 1
@ 3 : 1
@ 4 : 12
@ 5 : 12
@ 6 : 10
@ 7 : 10
@ 8 : 10
@ 9 : 15
@ 10 : 0
@ 11 : 1
@ 12 : 2
@ 13 : 2
@ 14 : 2
@ 15 : 7
@ 16 : 1
@ 17 : 1
@ 18 : 0
@ 19 : 0
@ 20 : 13
@ 21 : 13
@ 22 : 12
@ 23 : 12
@ 24 : 12
@ 25 : 13
@ 26 : 14
@ 27 : 0
@ 28 : 2
@ 29 : 2
@ 30 : 2
@ 31 : 1
@ 32 : 0
----------------
I am not satisfy with my direction numbers to each angle.
Anyone help me to check it. thanks
]]>