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

How do arbitrary-precision libraries like mpmath evaluate simple trigonometric functions?
How can I calculate the angle
Finding Shortest Distance Between Two Parallel Lines, With Arbitrary Point [closed]
how to convert depth in Z-cordinate
How can I simplify this expression with trigonometric in Maple?
Require trigonometry assistance with ship/wave movement
Trigonometry - Find where two curves intersect
How to calculate point 'along' unit circle radian [closed]
Issues with bullet entry points for “shoulder mounted” guns
Using the coordinates of two of a triangle's vertices to calculate the coordinates of the third
How to do the trig function Arc Cos (ACOS() in Excel) in MS-Access?
How to get the direction (angle) of rectangle after rotating it from a pivot point
How to calculate points of Chord
Is trigonometry computationally expensive?
draw lines protruding from a circle [closed]
Flipping an angle using radians

Categories

HOME
algorithm
django
wakanda
css3
nunit
jelastic
shiro
nuget
pdfbox
javacc
big-o
pyqt4
limit
nuget-package
pkcs#11
distribution
activecollab
stellar.js
automatic-ref-counting
pybossa
frequency-distribution
symbol
job-scheduling
symbols
jboss6.x
asymptotic-complexity
linked-data
angular-translate
sqlpackage
volatile
paragraph
hibernate-validator
playstation-portable
clickjacking
mailkit
code-snippets
login-script
roblox
raft
jvmti
signals-slots
trigonometry
levenshtein-distance
apriori
softmax
oracle-service-bus
wc
memory-mapping
procfile
openal
netbeans6.8
reindex
qtranslate
boxing
spring-data-couchbase
oracleclient
css-transforms
py2neo
branch-prediction
cronexpression
grails-plugin
redbeard-ios
eigenvector
cfchart
query-by-example
state-restoration
binomial-theorem
doctype
dronekit-android
user-permissions
cross-join
angular-gettext
crowd
metatrader5
malformedurlexception
jquery-slider
sbcl
light
mysql-error-1044
mongohq
cmmi
kaleidoscope
adobe-media-server
agility.js
listactivity
drawtobitmap
qglwidget
timertask
ie-compatibility-mode
filesystemobject
tui

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