mirror of
https://github.com/raeleus/Hashtag-DnD.git
synced 2025-07-05 21:20:27 -04:00
Allow #goto to travel partially toward a target.
This commit is contained in:
parent
650483ae7a
commit
711d7ea8ca
4 changed files with 33 additions and 3 deletions
13
Library.js
13
Library.js
|
@ -25,6 +25,19 @@ function pointDistance(x1, y1, x2, y2) {
|
|||
return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2))
|
||||
}
|
||||
|
||||
function pointDirection(x1, y1, x2, y2) {
|
||||
Math.atn2
|
||||
var a = Math.atan2(y2 - y1, x2 - x1);
|
||||
if (a < 0) a += 2 * Math.PI;
|
||||
|
||||
if (a < 0) a += 2 * Math.PI;
|
||||
if (a < 0) a += 2 * Math.PI;
|
||||
a = Math.abs((Math.PI * 2) - a);
|
||||
a *= 180 / Math.PI;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
function rotate(cx, cy, x, y, angle) {
|
||||
var radians = (Math.PI / 180) * angle
|
||||
var cos = Math.cos(radians)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue