Help with math formula
Blitz3D Forums/Blitz3D Beginners Area/Help with math formula
| ||
Hi I know what all the varibles are in this equation except for angle. could someone help me restructure this formula to find the angle varible. extendedpointx# = centerpointx# + ( Cos#(angle#) * distance# ) extendedpointy# = centerpointy# + ( Sin#(angle#) * distance# ) Thanks |
| ||
The angle should be ATan2( extendedpointy - centerpointy, extendedpointx - centerpointx ) |
| ||
Thanks Floyd This formula gave me a 0 to -180 and 0 to 180. Do you know how to make the output 0 to 360? Thanks for your help! |
| ||
If the result is negative then add 360. |
| ||
Is this the same as Dot product, or is that different? The reason i ask is, I'm looking for a formula to find the angle between 3 points. Sorry to hijack your post Jeeps |
| ||
the angle between 3 vectors There is no angle between 3 vectors, unless two of the vectors point the same way. |
| ||
Sorry, I meant points. |
| ||
That's effectively the same as finding the angle between 2 vectors. Dot product is what your looking for : Angle# = Acos ( ( V1 dot V2 ) / ( Length V1 * Length V2 ) ) Where V1 dot V2 = V1\x * V2\x + V1\y * V2\y Stevie |
| ||
Thanks Stevie. |
| ||
Thanks Floyd I have incorporated the formula into my game and it works great!!!! |
| ||
If the result is negative then add 360. or just use Mod: ATan2( extendedpointy - centerpointy, extendedpointx - centerpointx ) Mod 360 |
| ||
In that case, I think you have to add 360 to the result, before applying the Mod 360... |