IPB Style© Fisana

Jump to content


Where to share/upload random map generators


  • Please log in to reply
21 replies to this topic

#21 FeXoR

FeXoR

  • Community Members
    PipPipPipPipPip

  • Centurio
    (659 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.

Posted Image Im Übrigen bin ich der Meinung, dass 0A.D. Auslöser braucht. (IMO 0A.D. needs triggers ASAP.)

#22 FeXoR

FeXoR

  • Community Members
    PipPipPipPipPip

  • Centurio
    (659 posts)

Posted 29 February 2012 - 05:18 PM

Opened a new topic:
getDistance(point1, point2) and getDirection(point1, point2) from one point to another
Posted Image Im Übrigen bin ich der Meinung, dass 0A.D. Auslöser braucht. (IMO 0A.D. needs triggers ASAP.)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users