Results 1 to 1 of 1

Math Help - Keeping same X & Y when size has changed.

  1. #1
    Newbie
    Joined
    Jun 2009
    Posts
    1

    Keeping same X & Y when size has changed.

    Hi,

    I am trying to replace one object with another object of a different size. If there is no rotation everything works fine. As soon as rotation is added the new object is shifted. Rotation is performed around the centre of the object. Height and width are calculated before rotation.

    I can easly calculated the rotated X, Y, height and width.

    double radians = firstObject.Degree * Math.PI / 180;

    new1H = (int)Math.Round(Math.Abs(firstObject.Height * Math.Cos(radians)) + Math.Abs(firstObject.Width * Math.Sin(radians)) + .5);

    new1W = (int)Math.Round(Math.Abs(firstObject.Width * Math.Cos(radians)) + Math.Abs(firstObject.Height * Math.Sin(radians)) + .5);

    new1X = firstObject.X - (new1W - firstObject.Width) / 2;

    new1Y = firstObject.Y - (new1H - firstObject.Height) / 2;

    Below is what I'm starting with.



    This is what I get when I do a replace. Please note how the top left corner of the new object does not match where the top left of the old object was.



    Below is what I want. Please note the way the top left corner of the new object is at the same X, Y coordinates as the old object.



    Any help appreciated!
    Attached Thumbnails Attached Thumbnails Keeping same X & Y when size has changed.-keep.original.001.jpeg   Keeping same X & Y when size has changed.-keep.original.current.jpeg   Keeping same X & Y when size has changed.-keep.original.wanted.jpeg  
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Width when axis is changed
    Posted in the Geometry Forum
    Replies: 4
    Last Post: August 19th 2011, 08:29 PM
  2. Elementary Book-keeping question!
    Posted in the Business Math Forum
    Replies: 0
    Last Post: October 25th 2010, 07:36 AM
  3. Keeping line insede a rectangle
    Posted in the Trigonometry Forum
    Replies: 1
    Last Post: October 13th 2009, 02:04 PM
  4. How to find the Changed Base
    Posted in the Pre-Calculus Forum
    Replies: 3
    Last Post: June 18th 2009, 03:45 AM

Search Tags


/mathhelpforum @mathhelpforum