Angle between the horizontal and the line define by mouseDown and mouseUp
I was triing to use ATAN, but i realise i allways get a number between 0 and 90 . Then somebody told me i should use ATAN2, but i’m getting very weird results.
[IConfig,3.0]
[VarDef, a ]
[VarDef, b ]
[VarDef, angle]
[RoutineDef, ZMarkingMenu,
// Get X and Y for mouseDown position
[Loop, 999999, // loop until left mouse button is clicked
[If, ([MouseLButton ] == 1),
[VarSet, Cx1, INT([MouseHPos]+.5) ]
[VarSet, Cy1, INT([MouseVPos]+.5) ]
[LoopExit ]
]
]
// Get X and Y for mouseUp position
[Loop,999999, // loop until left mouse button is released
[If, ([MouseLButton ] == 0),
[VarSet, Cx2, INT([MouseHPos ]+.5) ]
[VarSet, Cy2, INT([MouseVPos ]+.5) ]
[LoopExit ]
]
]
// Return comand
[VarSet, a , Cx2 - Cx1 ]
[VarSet, b , Cy2 - Cy1 ]
[VarSet, angle , ATAN2(b/a) ]
// Display result
[Note, [StrMerge, "
The angle is :",angle ] ]
,Cx1, Cy1, Cx2, Cy2 //, ButtonLink
]
[ISubPalette,Zplugin:CTScripts]
//*------------------------------------------------------------------------------------------
[IButton, "Zplugin:CTScripts:TEST ", "Test",
[Routinecall, ZMarkingMenu, x1, y1, x2, y2 ]// ,"ZSCRIPT:Select"
,,76,126,,]