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 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
Need help revising a simple formula to make it universal
SWIFT trig functions
Simplifying atan(tan(a+b))
2 Different Radians constant calcuations whats the difference?
Trigonometry & Sunset
Calculating collisions with Radians incrementing
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

Categories

HOME
httparty
eclipse
cobalt
awk
dns
pagination
themes
pclxl
appcelerator
crystal-reports-2013
retrofit2
performancepoint
rcloud
siddhi
mod-security
code-generation
scrolltop
atlassian-stash
firefox-addon
google-container-registry
enterprise-miner
boost-icl
spring-async
easeljs
resourcebundle
itunes
bulletphysics
ms-access-web-app
cppreference
event-flow
dumpbin
hard-drive
sendbird
least-squares
hivemq
xdocreport
congestion-control
stylecop
puredata
dotnet-httpclient
reportservice2010
activeperl
video-conferencing
context-sensitive-grammar
pdf-conversion
gameplay-kit
testrail
rmongo
choice
vorpal.js
observablecollection
jclouds
swizzling
mediametadataretriever
project-organization
nupic
thread-sleep
themoviedb-api
xenomai
forwarding
canalyzer
graphics2d
at-job
filesplitting
metatrader5
nsmenu
reflector
maven-scm
dsym
syndicationfeed
light
unit-of-work
web-farm
xcode3.2
subgraph
urlrewriter
collectionviewsource
cloudfiles
globals
linfu-dynamicproxy
flvplayback
product-management
pnrp

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