Results 1 to 2 of 2
  1. #1
    dark7568 is offline Member
    Join Date
    Aug 2014
    Posts
    1
    Rep Power
    0

    Default 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. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,033
    Rep Power
    6

    Default 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
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Center point of Circle
    By Veronica91 in forum New To Java
    Replies: 7
    Last Post: 04-30-2013, 01:03 AM
  2. ImageView Collision
    By TP-Oreilly in forum Android
    Replies: 1
    Last Post: 01-30-2012, 03:17 AM
  3. ImageView , Image problems
    By yweeeen in forum JavaFX
    Replies: 0
    Last Post: 10-20-2011, 06:47 AM
  4. Replies: 2
    Last Post: 04-01-2010, 05:16 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •