Results 1 to 6 of 6

Thread: Hard Math Problem!

  1. #1
    wossname
    Guest

    Red face Hard Math Problem!

    I have a small universe, with the 3 standard dimensions: X,Y and Z.

    Given these things:
    - The (x,y,z) coordinates of the "camera"
    - the direction that the camera is pointing
    - the (x,y,z) coordinate of a point in space

    Can someone tell me the maths expression that will resolve this info into an (x,y) coordinate, so I can plot it on a picturebox.

    My brain is aching, please help!

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    You need to use some linear algebra for this kind of thing, what you're basically looking for is a projection matrix (I think that's what it's called). I don't know too much about it myself but there are a lot of articles on this kind of translation at www.gamedev.net , since it's the sort of thing that 3D games use a lot of. www.flipcode.com has some good maths resources for this sort of stuff too.
    Harry.

    "From one thing, know ten thousand things."

  3. #3
    Zaei
    Guest
    What are you programming this in? GDI, OGL, D3D, Other? If its D3D8, there is a function in the D3DX library called D3DXVec3Project(...) that will do what you want. OGL has a similar function, although i dont know what its called. Search for "Project". If its GDI, you are going to have some fun playing with vector calculus.

    Z.

  4. #4
    wossname
    Guest
    Oh dear, I knew someone would ask me that. I'm using PocketC on the PalmOS platform! All I have to work with are the standard math expressions: Cos() Atn() etc...

    Its a black/white LCD display on my Palm IIIx handheld, so I'm looking for simple solutions really.

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6
    New Member
    Join Date
    Dec 2000
    Location
    Kingswood, UK
    Posts
    6
    Depends if the camera is always upright, or whether it rolls as well.

    The maths for a rolling camera is well tricky, but I can give you the bits for upright no sweat.

    Assuming x for horizontal, y for vertical & z for lateral,

    Using X,Y for final screen,
    x1,y1,z1 for camera pos,
    x2,y2,z2 for object pos,
    and ang for camera angle

    X = (x2 - x1) * Cos(ang) + (z2 - z1) * Sin(ang)
    Y = (y2 - y1)

    This assumes no perpective

    With perspective,

    Z = (x2 -x2) * Cos(ang) + (z2 - z1) * Sin(ang)

    X = ((x2 - x1) * Cos(ang) + (z2 - z1) * Sin(ang)) * Log(Z)
    Y = (y2 - y1) * Log(Z)


    This is in maths speak and not code, gotta leave some work for you to do

Posting Permissions

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



Click Here to Expand Forum to Full Width