atan2


Limiting atan2 to specific angle ranges


I want my Player sprite to rotate following the position of the mouse cursor.
I'm using atan2 to set up a 360 degree rotation action script for my Player sprite.
atan2(XMouse-XPlayer,YMouse-YPlayer) - 90
Using this, 90 degrees is straight up, 0 is direct right, 270 degrees is straight down. I need the Player sprite to sit on the Left side of the screen and only face the Right side of the screen when it rotates (meaning it can't look backwards).
I need to limit my angles to both conditions; less than 90 degrees OR greater than 270 degrees.
Ideally, I'd like to set 0 degrees to straight up, then I only have to set my conditions to Angles less than 180 degrees (one conditional rather than two).
Can that be done?
Yes. Use min() and max() (although you haven't said what language you're working in...)
If you use radians, then the condition to check for is that abs(theta) < PI/2 is always true. Here's an image from Wikipedia, just to show you what I mean.

Related Links

considering the second quadrant ( where x<0 and y>0) as the first quadrant how will i use the function atan2(y,x) to calculate the directions
Determine the coordinates of a segment
Limiting atan2 to specific angle ranges

Categories

HOME
httparty
design-patterns
forms
nvd3.js
alexa-skills-kit
object
rsa
mstest
vscode-extensions
ms-access-2016
static-site
yandex
jetty
code-coverage
azure-container-service
odoo-8
openbugs
azure-iot-hub
digital-signature
user-experience
r-mice
qliksense
tosca
roundup
perlbrew
siri
calculation
dotspatial
utorrent
cart
testbed
git-squash
autolisp
spring-security4
code-snippets
sammy.js
joomla2.5
video-capture
bc
wmp
show-hide
stylecop
double-click
filehandle
mouseleave
shinobi
renaming
node-request
redistributable
hadoop-2.7.2
jparsec
libvlc
directdraw
dynamics-nav-2016
rewrite
coda
doctype
ember-cli-rails
rdflib
airbrake
avahi
git-ftp
apache-spark-1.3
dbaccess
rapidsvn
post-commit-hook
cocos3d
human-computer-interface
trdion2011
rcaller
radiant
dsym
hibernate-entitymanager
kaleidoscope
jquery-1.9
server-administration
cardreader
curb
qi4j
pstack
subgraph
screen-size
jquery-tools
update-statement
automationelement
rmdir
timthumb
inline-formset
django-paypal
ruby-1.8
lxr
todos
wcf-proxy
pbcopy

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App