|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#16
|
|||||
|
|||||
|
Re: Angle from X,Y
It was a joke. The prize: Absolutely nothing!
Basically, I'm asking if anyone knows why you would want it on the controller. |
|
#17
|
|||||
|
|||||
|
Here is my Arc Tangent code:
Code:
#define ATAN_COUNT 64
char rom ATAN_ARRAY[64] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16,
17, 18, 19, 21, 22, 23, 25, 26, 27, 29, 30, 32, 34,
36, 37, 39, 41, 43, 46, 48, 50, 53, 56, 59, 62, 66,
69, 74, 78, 83, 88, 95, 101, 109, 118, 128, 140, 154,
171, 192, 218, 253, 299, 367, 473, 663, 1106, 3319};
char atan (char Num)
{
char Index = 0;
char Value = 0;
char IsDone = 0;
LOOP:
if (ATAN_ARRAY[Index] > Num)
Value--;
if (ATAN_ARRAY[Index] >= Num)
IsDone = 255;
else if (Index >= ATAN_COUNT - 1) //was ATAN_COUNT + 1
{
IsDone = 255;
Value = 64;
}
if (IsDone)
goto LOOP_DONE;
else
{ Value++; Index++; }
goto LOOP;
LOOP_DONE:
return Value;
}
[edit]that chould be ATAN_COUNT - 1 not ATAN_COUNT + 1 at line 19[/edit] Last edited by Astronouth7303 : 15-04-2004 at 07:25. |
|
#18
|
|||
|
|||
|
Re: Angle from X,Y
hmmm you can also use vectors, and find the angle with the formula (u * v)/(|u||v|) (the dot product of u and v divided by the product of the magnitudes). This is useful if you are already using vectors, which are probably better suited for motion and such anyways.
|
|
#19
|
||||
|
||||
|
Re: Angle from X,Y
Quote:
The result of that equation gives you the cos of the angle between the vectors. That is cos(x). You would still need to use an inverse trig function to find the angle (x). I'm going to have to go ahead and give you -15 points for that one. o_O -Daniel |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PBASIC ARCTAN function | Greg Ross | Programming | 14 | 11-05-2003 12:28 |
| The angle of going up the Ramp | David Bryan | Programming | 2 | 21-01-2003 20:56 |
| Slotted Angle Aluminum | hinge87 | OCCRA | 1 | 09-10-2002 18:15 |
| Is an angle bracket allowed? | archiver | 2001 | 0 | 24-06-2002 00:58 |
| 45 degree PVC angle fittings: which? | archiver | 2001 | 2 | 23-06-2002 22:53 |