How to make transformation matrix for new origin + xyz-axis (vectors)?

Discussion in 'General Math' started by Erwin Moller, Dec 6, 2011.

  1. Erwin Moller

    Erwin Moller Guest


    I am new in this group, so if this question is not suitable in here,
    kindly direct me to a better group.

    I am writing a 3D package with a friend in Javascript, just for the fun
    of it. We are able programmers, but not-so-able mathematicians. ;-)
    We refuse to use a ready-to-go lib, like Sylvester, because we *want* to
    re-invent the wheel and write everything from scratch. That way we are
    sure we understand everything we are doing.

    We have set up a "world" using positionvectors to point to points in our
    world. We can draw triangles with colors (and later surfaces from
    images) in that world.
    Now we need a way to look at the world.

    Hereunder I use PV and V. PV means Position Vector, V means Vector, but
    they both are just vectors of course, but it is easier to treat them
    different for us so the PV is a point, and a V is a direction (and length).
    Now we want to look at our world from a certain position.
    We defined:

    - PV-eye: The Eye positionvector (Where is the eye?).
    - PV-eyeLook: A positionvector that represents the place the Eye looks at.
    - V-eyeLook: the direction the eye looks at. (Simply calculated by
    subtracting PV-eyeLook from PV-eye)
    - V-eyeRight: The rightdirection according to eye-axis.
    - V-eyeUp: The updirection according to eye-axis.

    We made V-eyeLook, V-eyeRight and V-eyeUp unitvectors (length 1).
    We also made sure they are also perpendicular to each other.

    The problem:
    We need a way to transform points expressed in the world-axis to our
    World-axis uses:



    and origin 0,0,0 of course.

    And the Eye-axis are also defined with 3 vectors (V-eyeLook, V-eyeRight
    and V-eyeUp) and have their origin in PV-eye.




    What we would like is to learn how to express any World-coordinate in
    Eye-coordinates, preferably using a Matrix that takes care of the
    transformation and translation.

    For example:
    The World-axis x must become V-eyeRight
    The World-axis y must become V-eyeUp
    The World-axis z must become V-eyeLook

    We understand that a 4x4 matrix that uses an extra w can do the trick,
    but I cannot find any online resource that explains in detail.
    Kahn academy helped a little but didn't exactly crack this puzzle.
    We have found solutions and such, but we want to understand the how and
    why before implementing.
    I expect this is standard material to learn for students working with 3D.

    Can anybody help or point us to a great online resource on the subject?

    Thanks for your time, and sorry for the lengthy post.

    Erwin Moller
    Erwin Moller, Dec 6, 2011
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.