mirror of
https://github.com/vrld/hump.git
synced 2024-11-23 12:24:19 +00:00
Add vector.angleTo(x,y, u,v)
This commit is contained in:
parent
1f9a7f1f52
commit
015ff8a23a
@ -24,7 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
]]--
|
||||
|
||||
local sqrt, cos, sin = math.sqrt, math.cos, math.sin
|
||||
local sqrt, cos, sin, atan2 = math.sqrt, math.cos, math.sin, math.atan2
|
||||
|
||||
local function str(x,y)
|
||||
return "("..tonumber(x)..","..tonumber(y)..")"
|
||||
@ -120,6 +120,10 @@ local function trim(maxLen, x, y)
|
||||
return x * s, y * s
|
||||
end
|
||||
|
||||
local function angleTo(x,y, u,v)
|
||||
return atan2(y - (v or 0), x - (u or 0))
|
||||
end
|
||||
|
||||
-- the module
|
||||
return {
|
||||
str = str,
|
||||
@ -149,5 +153,6 @@ return {
|
||||
perpendicular = perpendicular,
|
||||
project = project,
|
||||
mirror = mirror,
|
||||
trim = trim
|
||||
trim = trim,
|
||||
angleTo = angleTo,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user