Convert 3D point from 1 coordinate system to other

Discussion in 'iOS Programming' started by namanhams, Jul 26, 2012.

  1. namanhams macrumors regular

    Joined:
    Jun 3, 2009
    #1
    Let say i have 2 CALayer objects with same parent layer, same frame value. Each of them has their own 'transform' value. So basically we have 2 3D spaces.
    Let say i hava point, with coordinate (x, y, z) in first space.
    How do i find out its coordinate in the second space ?

    Thanks.
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    1. Apply inverse transform of first space.
    2. Apply transform of second space.

    If you understand what a transform is and what it does, you'll understand why this works. If you don't, you won't, and you should study transforms more.
     
  3. namanhams thread starter macrumors regular

    Joined:
    Jun 3, 2009
    #3

    Can you be more specific ? Eg, what's the transform that is applied to 2nd space ?
     
  4. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #4
    It's exactly what I wrote: the transform of the second space. You said each space has a transform. So the transform of the second space is the transform that belongs to (is used by) the second space. I don't know how to make it any plainer or more specific.

    Again, if you don't understand how transforms work, that is, what transforms actually do, then you should study them more. Sit down with a good book on 2D or 3D graphics, learn how simply transforms like translation work, make some drawings on graph paper, and learn the basic mathematics. If you don't understand how transforms work, how do you expect to use them effectively? You can't expect to understand what strings are (sequences of characters) without knowing what characters are.
     
  5. namanhams thread starter macrumors regular

    Joined:
    Jun 3, 2009
    #5
    Uhm. I'm not sure i know what you mean.

    So for the first layer, if we apply an inverse transform, it's equivalent to setting the transform of the first layer to identity transform. Am i right ?

    "So the transform of the second space is the transform that belongs to (is used by) the second space"

    Of course it is. Then what do you mean by applying this transform to 2nd layer ? It's already the transform of the 2nd layer, rite ?


    It would be helpful if you can give some hint regarding my question : how to convert the coordinate of a 3D point between 2 space ?
     
  6. chown33, Jul 26, 2012
    Last edited: Jul 26, 2012

    chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #6
    Learn the mathematics of transforms. If you understand that, you can answer the question yourself, simply by working through the inverse transform and the 2nd transform manually. If you don't understand the mathematics at a practical level, nothing I can say is going to help you understand them better than studying them. You may think there's an easy answer, but there isn't. Understanding the mathematics of transforms is essential to understanding transforms.

    There's only one simplification I know of: if you understand 2D transforms at a practical level, then 3D transforms are easy to grasp. Since 2D transforms are simpler (fewer elements in a transform) and easier to draw on graph paper, start by learning exactly how 2D transforms work. After mastering them, move on to 3D transforms.
     
  7. namanhams thread starter macrumors regular

    Joined:
    Jun 3, 2009
    #7
    Ok i know mathematics and i know what transform and transformation matrix is.
    What you say is right, but i need some hint to this question.
     
  8. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #8
    I think chown33 has given you more than just hints, he's given you pseudo-code. It's now up to you to convert that pseudo-code into real code.
     
  9. namanhams thread starter macrumors regular

    Joined:
    Jun 3, 2009
    #9
    Actually i have found a way, but not that straight forward.
    It's because we need to take into account the anchorPoint and anchorPointZ of the CALayer also.
     

Share This Page