# Where to share/upload random map generators

21 replies to this topic

### #21 FeXoR

FeXoR

Primus Pilus

• WFG Programming Team
• 1,013 posts

Posted 29 February 2012 - 04:58 PM

Of cause I mixed it up...
And forgot the area of definition that is only PI not 2*PI...

A function working and consistent to the unit placement orientation for getting the angle of a vector from one point towards another is for example (perhaps not the best):

```// Function to get the direction from one point to another
function getDirection(point1, point2)
{
var vector = [point2[0] - point1[0], point2[1] - point1[1]];
var output = Math.acos(vector[0]/getDistance(point1, point2));
if (vector[1] > 0) {output = PI + (PI - Math.acos(vector[0]/getDistance(point1, point2)))};
return (output + PI/2) % (2*PI);
};
```

The other functions are correct...

Edited by FeXoR, 29 February 2012 - 05:03 PM.

• 0

Florian Finke [aka FeXoR]

Wildfire Games Random Maps

### #22 FeXoR

FeXoR

Primus Pilus

• WFG Programming Team
• 1,013 posts

Posted 29 February 2012 - 05:18 PM

• 0

Florian Finke [aka FeXoR]

Wildfire Games Random Maps