Thread: Mapping Points/Vectors

  1. #1
    Unregistered
    Guest

    Mapping Points/Vectors

    I am tyring to map the location of a POINT from its postion in a source RECTto a new realitve postion in a destination RECT of another size and /or position.

    Nothing I have tried even comes close. Does anynone know a simple mapping alogrithim?

    Liz

  2. #2
    Unregistered
    Guest
    I am appending my post with my most recent try. Seems to work if the source rect is greater than the destination rect, but not in any other case:

    void MapPt(POINT *pt,RECT src,RECT dst)
    {
    float w1 = src.right - src.left,
    h1 = src.bottom - src.top,
    w2 = dst.right - dst.left,
    h2 = dst.bottom - dst.top,
    x = pt->x,
    y = pt->y,
    xr,yr,xx,yy;

    //the ratios
    xr = w2/w1;
    yr = h2/h1;

    //scale the point
    x = x*xr;
    y = y*yr;

    //Zeroed pos
    xx = ((dst.left - src.left)*xr) + x;
    yy = ((dst.top - src.top)*yr) + y;

    pt->x = xx + dst.left;
    pt->y = yy + dst.top;
    }

    Are there any suggestions?

    Liz

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL texture mapping with texCoordArray
    By nempo in forum Game Programming
    Replies: 1
    Last Post: 08-24-2008, 04:00 AM
  2. MapServer and other mapping tools
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 12-29-2007, 02:27 AM
  3. OpenGL Shadow Mapping Issues
    By animeaholic in forum Game Programming
    Replies: 0
    Last Post: 06-05-2007, 09:49 AM
  4. ??Character Mapping??
    By devour89 in forum C++ Programming
    Replies: 10
    Last Post: 12-14-2002, 11:52 PM
  5. Terrain mapping problem
    By DavidP in forum Windows Programming
    Replies: 1
    Last Post: 11-26-2001, 10:08 PM