You are not logged in.
ok The formula is as shown below
I am using the same points which i used to solve my first problem i posted in this post.
In my this post, i posted these points and angle using atan2 (dy ,dx) method
@ 0(105, 66)
@ 1(114, 92)
@ 2(104, 11)
@ 3(99, 131)
@ 4(71, 144)
@ 5(37, 168)
angle : 70.9065
angle : -97.0379
angle : 92.3859
angle : 155.095
angle : 144.782
But now i am just testing the angle calculating formula taken from one paper, attached in this post.
And i got these angles
Angle : 5.0469
Angle : 1.6949
Angle : 4.67201
Angle : 3.57753
Angle : 3.75752
I also don't understand the angle with those points.
Hi again,
This time i came here with a formula for calculating angle (which i found in one paper)
The formula is as shown below.
I tested that on the following points
@ 0(105, 66)
@ 1(114, 92)
@ 2(104, 11)
@ 3(99, 131)
@ 4(71, 144)
@ 5(37, 168)
These points are down on the image like this ..
and these are the angles
Angle : 5.0469
Angle : 1.6949
Angle : 4.67201
Angle : 3.57753
Angle : 3.75752
Then i assigned the 8 directional code to each angle using this formula
d = (( (int) ( (8 * angle) / pi) + 1) mod 16 ) /2 ------------- (found in paper)
0
4
5
5
2
The 8 direction Code is shown in the attached file (found in paper)
I do't understand these angles and 8 directional code.
It seems not correct,.
or I am not implementing correctly.
If anyone can verify me then it would be easy for me to understand the paper.
Thanks
ahhan .. ok ..
but Can you suggest me any method to verify the Code of each line segment?
thanks
Sorry, blue points are the turn or bend points.
This character is "A" .
Hi,
This time i am gonna talk about interpolation.
Kindly see the attached character "A" in the image.
Where the start point of written character is green color , the end point is in red color.. and all the mid points are in blue color.
My question is that ... if you see that during writing the character some line can be miss (you can see in the image.)
How can i estimate the points and link the point t\of segment with the other point of the segment? (that part is encircled in the image. )
Which interpolation technique would be useful?
any idea?
How can i fix it mathematically?
ahhhan ok..
you meant there would be a problem in the code.. so i should check execution using breakpoints.
ok ok.. i will come back soon with good report
Hi bob,
I wanna show one example.. and its directional code for 0 direction is not appropriate..
The example is shown in the attached image.
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
ahhan .. i see .. thank you a lot Bob and phrontister..
Hi all,
ok As we have seen that angle is correct of all points.
Well the purpose of computing angle is to assign the 16 direction code for each line direction.
Since a circle circle is made up with 360 angles.
To get the 16 direction code for angles or direction of line, what we are doing is something like this ...
directionCode = ( angle / 22.5 ) - 16 , if angle is positive
else directionCode = (angle / 22.5) + 16, if angle is negative.
Since we need to get 16 direction Codes of angles.
so total angles 360 / 16 = 22.5 .
ok.. The problem i have with angle of Point B to C is that i got direction code 11, that meant the direction of line is downward. while the image attached in my post #6 shows that the line direction is from B to C that is upward direction .. therefore according to my figure in #6, direction code should 4 or 3.
A figure of direction code in circles are shown like this.
you can assign direction like this .. .
E = 0
between E and N, we have direction code 1 , 2 , 3
N = 4
between N to W, we have direction code 5 ,6 , 7
W = 8
between W to S, we have direction Code 9, 10, 11
S = 12
between S to E , we have direction code 13, 14 , 15
and finally east = 16.
So, the angle from point B to C, gives me direction code 11.
which is wrong. because the line shows its direction to upward in my attached figure of post #6.
That'sy i am not satisfy with the angle of B to C. that's y, I am saying that my angle is inverted.
One more thing, that an image don't have negative x or y values. then how can i put the y values as negative to make the angle of point B to C to the upward direction.
or i should change my method of angle computation?
waiting for reply
I need to fix this issue..
Hi pari_alf,
Note: These points are exactly correct. these points are drawn on an image window. where the index of an image is started 0,0 at the top left corner of the image.. and going down diagonally bottom right of the image is the highest index value of the image.
Aha! Ok, that answers the question of whose drawing is the inverted one...it's mine, although I was following what I believe is the standard convention.
Sorry, but I'm home for lunch and just saw your post, but can't answer fully because I have to go out again shortly and I'll be gone for a few hours. I'll have a closer look at your post when I return and I'll reply then...and I think I can now see the answer through the fog.
Ahhhan.. Thanks .. hope to see you soon.
It appears that in your drawing all six y-axis values have been incorrectly signed. I wonder if this could be the reason that you think the line from index 1 to index 2 should be upward instead of downward, and that the corresponding angle is inverted.
Well if you see in my posted figure,
1. the start point is shown in green circle that is index 0. then point of index 0 is going down diagonally probably in 3rd quadrant.
2. then index point 1 is going upward probably in 2nd or 1st quadrant.
3. point of index 2 is going down to index point 3 in 3rd quadrant.
4. then index point 3 is going diagonally in 3rd quadrant.
that meant that our points of line are going in anti clockwise direction because our start point is green and end point is red in the figure post 6.
Then how are you saying that it is going clockwise direction?
Note: These points are exactly correct. these points are drawn on an image window. where the index of an image is started 0,0 at the top left corner of the image.. and going down diagonally bottom right of the image is the highest index value of the image.
So I have problem in only direction of line of points index 1 to index 2.
It is shown that the line from index 1 to index 2 , is going upward direction that meant angle should be positive and around 97,..
because our points are shown in anti-clockwise direction.
I don't know that is the issue. because these points are correct and we know the start and end point as we can see in the image attached in post 6. Which clearly shows that lines are going in anti clockwise direction.
Actually, i am trying to find the direction of each line using angle computed by atan2 (dy, dx).
To find the direction of each line, i did something like this..
if ( angleInDegree > 0 )
directionCode = abs ((angleInDegree / 22.5) - 16 );
print --> directionCode
else
directionCode = abs ((angleInDegree / 22.5) + 16);
print --> directionCode
-------------------------------------------
My Result with angle and direction codes are like this
Original Points:
@ 0(105, 66)
@ 1(114, 92)
@ 2(104, 11)
@ 3(99, 131)
@ 4(71, 144)
@ 5(37, 168)
angle : 70.9065
angle : -97.0379
angle : 92.3859
angle : 155.095
angle : 144.782
Print the directional codes..
@ - 0:12
@ - 1:11
@ - 2:11
@ - 3:9
@ - 4:9
you guys can note the the angle of 1st index to the 2nd index point is -97 that meant in downward direction.
It should be at upward direction i meant angle should be arround 90.
and direction code should be 3 or 4.
Why my angle of point index 1 to index2, is inverted.
hi pari_alf
I tried your code in excel and got these values:
70.906508
82.96205924
-87.61405597
-24.90476881
-35.21759297This is what I would expect because these are the principle values for the function atan.
I can convert my answers into yours by adding or subtracting 180 as necessary.
According to
http://www.cplusplus.com/reference/cmath/atan/
Principal arc tangent of x, in the interval [-pi/2,+pi/2] radians.
One radian is equivalent to 180/PI degrees.But curiously on this page
http://www.cplusplus.com/reference/cmath/atan2/
Principal arc tangent of y/x, in the interval [-pi,+pi] radians.
One radian is equivalent to 180/PI degrees.This must be an error as atan has two possible values in this range. ???
To use atan you have to compute the division (dy/dx) and then apply the function to the result.
It would be interesting to see what answers you get if you try this.
Bob
Yes these are my angle using atan(dy/dx)
70.9065
82.9621
-87.6141
-24.9048
-35.2176
but the angle from index 1 to index 2, the angle is wrong using atan2 () method
I calculated the angle by making a program in c++.
The peusdo code is something like this
for: i 1 to n-1 //n is the size of vector points
dx = points [i-1].x - points[i].x
dy = pointsp[i-1].y - points[i].y
angle = atan2 (dy , dx ) * 180/pi
This is the way i am coding to compute the angle
Hi guys, thanks for replying.
Kindly see my points shown on image below, where the green and red circles are the start and end point and all other other intermediate points are in black circle.
http://i.imgur.com/XLB0JH6.png
I computed angle using atan2 (dy,dx),
Problem is that the direction from 1st index point to the 2nd index point is shown vertically in the attached image. but my computed angle shows the direction in downward direction.Computed angles are shown below..
Original Points:
@ 0(105, 66)
@ 1(114, 92)
@ 2(104, 11)
@ 3(99, 131)
@ 4(71, 144)
@ 5(37, 168)angle : 70.9065
angle : -97.0379
angle : 92.3859
angle : 155.095
angle : 144.782Why my angle vertical angle is inverted to downward direction using atan2(dy,dx) ?
Hi, @phrontister
I saw your last figure that seems ok. fine .
but if you see my figure, the angle from 1st index to 2nd index point is -97 which meant that my line is going in downward direction. but my line is actually going upward.
How can i make my angle correct?
Hi guys, thanks for replying.
Kindly see my points shown on image below, where the green and red circles are the start and end point and all other other intermediate points are in black circle.
I computed angle using atan2 (dy,dx),
Problem is that the direction from 1st index point to the 2nd index point is shown vertically in the attached image. but my computed angle shows the direction in downward direction.
Computed angles are shown below..
Original Points:
@ 0(105, 66)
@ 1(114, 92)
@ 2(104, 11)
@ 3(99, 131)
@ 4(71, 144)
@ 5(37, 168)
angle : 70.9065
angle : -97.0379
angle : 92.3859
angle : 155.095
angle : 144.782
Why my angle vertical angle is inverted to downward direction using atan2(dy,dx) ?
Hi all,
I have some points as shown below.
@ 0(105, 66)
@ 1(114, 92)
@ 2(104, 11)
@ 3(99, 131)
@ 4(71, 144)
@ 5(37, 168)
Problem statement:
I have to find angle between points of line.
Note: The 0th index and the 5th index point are the start and end point of string.
I calculated angle using atan2 (dy, dx) and my angles are show as below..
angle : 70.9065
angle : -97.0379
angle : 92.3859
angle : 155.095
angle : 144.782
The issue is that the direction of 1st index point to the 2nd index point is upward (down to going up), but my angle is computed in downward direction .. why?
The upward direction is inverted ..why?
Pls guide me to fix this issue .
thanks
Anyother method to normalize the datasets?
yes right..
how can we get the equal interval points along the line direction?>
Which resampling method would be better to use .
Thanks
Hi,
If we have set of points, how can we normalize the size using linear normalization method which will normalize the data points.
thanks
hi pari_alf
Welcome to the forum.
You can use that formula but you need vectors that give the directions of the lines; eg
But, if all you want is to see if the points are co-linear, you could just work out the gradient of AB and the gradient of BC, to see if they are the same.
Bob
Thanks bob
Hi,
I need a maths software, which i could use for drawing
the points on grid and get set of x,y values.
Can anyone tell me a good setup for this purpose.
thanks
yes, what i wanna do is.. if angel of segment ab is same as angle of bc
that meant points a ,b ,c are in the same direction.
then delete point b.. so we will consider line from point A to C.
so finally we should have a line AC with direction.
In other words we can say that point A , B , C are coplanar.
so to get the direction of segments, we need to get angle.
to get angle, i used this method
theta = acos ( (u.v) / |u| * |v| )
but this give angle of point with origin.
i don't need in that way.