Determine direction in which square was drawn

by Shadox   Last Updated January 14, 2018 10:13 AM

Sorry for the silly question, but I'm out of ideas and not sure how to search for this. :/

I'm trying to determine the direction in which a square was drawn, by using the start and end position. Problem is that I only need one of the directions (X or Y) as the answer and not a combination of the 2.

To illustrate:

enter image description here

Clicking Mouse cursor at Origin, moving it to Destination creates a square. The expected direction I want to get is downwards like the arrow on the side is pointing. (Y direction down)

Meaning I can't use the largest distance on X or Y as in this case X would be larger, but Y is the one I'm after.

Origin and Destination can be anywhere and go in any direction, same for the Squares size.

Any ideas / suggestions? :S

Tags : direction

Related Questions

cocos2d-x Label Set Custom Direction manually

Updated April 17, 2016 08:05 AM

Circular motion - change direction

Updated May 31, 2017 11:13 AM

Movement based on direction of car?

Updated March 21, 2017 21:13 PM