trigonometry


How to get the direction (angle) of rectangle after rotating it from a pivot point


I normally just use setRotate(double value) and getRotate() when rotating a rectangle from its center. Suppose a rectangle is facing North if the getRotate() is 0 and I'm trying to get its direction, I simply get the negative of the getRotate() and get its remainder from 360 (if it's negative, I add 360). Which means that an angle of 0 degrees faces North, and rotating it clockwise by a degree makes it 359 degrees (likewise, rotating it counter-clockwise by a degree makes it 1 degree).
public double angle(){
double angle = -rectangle.getRotate();
if(angle<0){ angle += 360; }
return angle%360;
}
However, my problem now is that I need to rotate the rectangle not from its center but from a pivot point. I can't use setRotate(double value) and getRotate() anymore so I have to use getTransforms().add(new Rotate(double angle, double pivotX, double pivotY)).
Now, my problem is that I want to know the angle of the direction where the rectangle faces but I can no longer use getRotate(). And even if I use the getAngle() from the Rotate, I still don't know how to get the direction it faces because it wasn't rotated from the center.
Considering you have only one rotate transform for your rectangle you can just get info from transform:
for (Transform transform : rectangle.getTransforms()) {
if (transform instanceof Rotate) {
return ((Rotate)transform).getAngle();
}
}

Related Links

Replacing trigonometric functions in Sympy
How does atan appear in haversine formula?
Sympy cancelling terms in the Jacobian of polar coordinates transformation
Distance formula between two Lat/Longs Autoit?
Trigonometric Functions in Pseudo Code
Inverse-Kinematics: How to calculate angles for servos of a robotic arm to reach all possible points in a canvas?
How to calculate Heading using Gyro and magnetometer
Integral of a sign function proof
Best way working with trigonometric functions
Calculate place of point C to be equal distance away from points A and B
How to compute sum of angles from sine and cossine?
Counting trig ops as measure() function to fu() in sympy
Find a coordinate along a path
Angle calculation resulting in strange behavior
Shift angle orientation using atan2
estimate angle between two lines y = 1000x and y = 999x

Categories

HOME
android
batch-file
asp.net-web-api
beautifulsoup
scikit-learn
ng-idle
amp-html
css3
composite-primary-key
socket.io
ms-access-2016
switch-statement
telegram-bot
python-multithreading
missing-data
crystal-lang
dkim
emoji
tput
supervisor
cfml
delphi-xe5
google-maps-autocomplete
breadth-first-search
jquery-ias
string-concatenation
joptionpane
definitelytyped
syntax-highlighting
android-sharedpreferences
motion-detection
appirater
soot
wcag
user-defined-functions
gp
carrierwave
sqlpackage
google-earth
dotspatial
xbox
scatter3d
mustache
gojs
contacts
nested-lists
indy10
roblox
playframework-2.1
tex
protein-database
projects-and-solutions
diacritics
c9.io
laravel-elixir
skylink
wmp
naming
apache-spark-dataset
pom.xml
opennms
netbeans6.8
facebook-pixel
headless
template-toolkit
javafx-css
sandcastle
pocketsphinx-android
parfor
i386
udpclient
thread-sleep
httpruntime.cache
concept-insights
atan2
iokit
ess
include-guards
rpart
baasbox
alloy-ui
entity-framework-4.3
zend-currency
android-broadcast
jbake
iiop
primitive-types
addressing-mode
metatrader5
clickbank
getopt
jammer
printdialog
process-explorer
preload
panda3d
mkv
zope.interface
wcf-configuration
iboutlet
jquery-tools
listactivity
exponentiation
tmx
svk
commerceserver2007
resharper-6.0
skype4java
dsl-tools
mathematical-notation
visualj#
sun
software-lifecycle
firefox-3

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App