# Thread: How to multiple imageView rotate to center point of other imageView

1. Member
Join Date
Aug 2014
Posts
1
Rep Power
0

## How to multiple imageView rotate to center point of other imageView

I'm currently creating an android app, and I decided to create multiple imageView and rotate to the center point of other imageView. Such that the Earth always orbit the sun, but in this case we have multiple imageView, so we have multiple planets orbit the sun. The sun would be the center point. I want to add those imageViews and rotate(I cannot say 'rotate' because I want to fix the orientation always vertical) to the center of sun. So far I can rotate the imageView by itself only, but not the center of the sun.

How do I rotate with center point of sun ?
How do I rotate without changing the orientation ?

Codes for Rotate Itself with 45 degree

PHP Code:
```Matrix m = new Matrix();
image.setPivotX(image.getWidth()/2);
image.setPivotY(image.getHeight()/2);
image.setRotation(45);
image.setImageMatrix(m);```

2. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
6,226
Rep Power
14

## Re: How to multiple imageView rotate to center point of other imageView

To rotate any object in place, you rotate it about its center. To rotate an object about another object, you simply
move the orbiting object's center around the center of the stationary object. This is easy to do since all you are doing
is moving a single point in a circle. So x = rcos(t) and y=rsin(t) where r is the orbits diameter and t is the angular change
in orbit. x and y are the new coordinates of the orbiting object's center.

I could tell you how to do this in Swing using the graphics context but I doubt it would be much help in Android.

Regards,
Jim