13 years
edited 8 years
Description
This library provides a set of functions to get distance and angles between widgets (units, destructibles, items). Here you can get any of these measures no matter the type of the widget, like measuring the distance between unit-unit, unit-destructable, unit-item, item-unit, etc.
Requirements
- /******************************************************************2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
This library provides a set of functions to get distance and angles between widgets (units, destructibles, items). Here you can get any of these measures no matter the type of the widget, like measuring the distance between unit-unit, unit-destructable, unit-item, item-unit, etc.
Requirements
- /******************************************************************
* GEOMETRY MEASURES V1.1 ** By moyack ** 2012 ** =================================== ** Exclusive resource from wc3jass.com ** =================================== *******************************************************************/library GetWidgetMeasures requires GeometryLibBase
/*This is the first of a set of libraries focused in the usage ofproper geometry functions.Here we'll aim to make the code as modular as possible so we canreduce the code amount in map but offering the neccesary tools for moddersHere we offer some basic functions realated to widgets (units,destructables and items):GetWidgetsDistance: allows to calculate the distance between 2 widgets. Here you can have any combination: unit-unit, unit- destructable, item unit, etc. GetWidgetsAngle: Gets the angle between 2 widgets. Like the previus function, it allows to compare between units, unit-item, unit-destructable, etc. GetUnitsDistanceZ: Get the distance between 2 units, taking into account their respectives locations and flyheights.GetUnitsZAngle: Returns the elevation angle between unit a and unit b.IMPORTANT NOTE: GetWidgetsAngle and GetUnitsZAngle returns angles in RADIANS.*/function GetWidgetsDistance takes widget a, widget b returns real
return GetDistance(GetWidgetX(a), GetWidgetY(a), GetWidgetX(b), GetWidgetY(b))
endfunctionfunction GetWidgetsAngle takes widget a, widget b returns real
return Atan3(GetWidgetX(a), GetWidgetY(a), GetWidgetX(b), GetWidgetY(b))
endfunctionfunction GetUnitsDistanceZ takes unit a, unit b returns real
local real z = GetUnitZ(b) - GetUnitZ(a)
local real d = GetWidgetsDistance(a, b)
return SquareRoot(d * d + z * z)
endfunctionfunction GetUnitsZAngle takes unit a, unit b returns real
return Acos(GetWidgetsDistance(a, b) / GetUnitsDistanceZ(a, b))
endfunctionendlibrary