Home Game Development arithmetic – How to detect if object is transferring in clockwise- or counterclockwise route?

arithmetic – How to detect if object is transferring in clockwise- or counterclockwise route?

0
arithmetic – How to detect if object is transferring in clockwise- or counterclockwise route?

[ad_1]

Given the factors Source, Destination and Centre, the place a transfer has occurred from Source to Destination first compute the vectors:

CentreSource = Source - Centre
CentreDestination = Destination - Centre

Compute the dot product of the tværvector of CentreSource and CentreDestination:

RorL = CentreSourceX * CentreDestinationY - CentreSourceY * CentreDestinationX

Now RorL must be constructive if the purpose is transferring counterclockwise across the centre, unfavorable in case of clockwise, and 0 if the transfer was both 0 or 180 levels.

You can additional verify if the transfer was above or under 90 levels by computing the dot product of CentreSource and CentreDestination:

AorB = CentreSourceX * CentreSourceY + CentreDestinationX * CentreDestinationY

If AorB is constructive then the transfer was under 90 levels, whether it is unfavorable the transfer was above 90 levels, and whether it is 0 then the transfer was both precisely 90 levels or it both began or ended within the level Centre.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here