How to find view point coordinates?

2019-08-14 15:40发布

问题:

I have azimuth , elevation and direction vector of the sun.. i want to place a view point on sun ray direction with some distance. Can anyone describe or provide a link to a resource that will help me understand and implement the required steps?

I used cartesian coordinate system to find direction vector from azimuth and elevation.and then for find viewport origin.image for this question

x = distance
y = distance* tan azimuth
z = distance * tan elevation.

i want to find that distance value... how?

回答1:

  1. azimutal coordinate system is referencing to NEH (geometric North East High(Up)) reference frame !!!

    in your link to image it is referencing to -Y axis which is not true unless you are not rendering the world but doing some nonlinear graph-plot projection so which one it is?

    btw here ECEF/WGS84 and NEH you can find out how to compute NEH for WGS84

    As I can see you have bad computation between coordinates so just to be clear this is how it looks like:

    on the left is global Earth view and one NEH computed for its position (its origin). In the middle is surface aligned side view and on the right is surface aligned top view. Blue magenta green are input azimutal coordinates, Brown are x,y,z cartesian projections (where the coordinate is on its axis) so:

    Dist'= Dist *cos(Elev  );
    z    = Dist *sin(Elev  );
    x    = Dist'*cos(Azimut);
    y    =-Dist'*sin(Azimut);
    

    if you use different reference frame or axis orientations then change it accordingly ...

  2. I suspect you use 4x4 homogenous transform matrices

    for representing coordinate systems and also to hold your view-port so look here:

    • transform matrix anatomy
  3. constructing the view-port

    You need X,Y,Z axis vectors and O origin position. O you already have (at least you think) and Z axis is the ray direction so you should have it too. Now just compute X,Y as alignment to something (else the view will rotate around the ray) I use NEH for that so:

    view.Z=Ray.Dir // ray direction
    view.Y=NEH.Z // NEH up vector
    view.X=view.Y x view.Z // cross product make view.X axis perpendicular to Y ansd Z
    view.Y=view.Z x view.X // just to make all three axises perpendicular to each other
    view.O=ground position - (distance*Ray.Dir);
    

    To make it a valid view_port you have to:

    view = inverse(view)*projection_matrix;
    

    You need inverse matrix computation for that

  4. if you want the whole thing

    Then you also want to add the Sun/Earth position computation in that case look here:

    • complete Earth-Sun position by Kepler's equation
  5. The distance

    Now that is clear what is behind you just need to set the distance if you want to set it to Sun then it will be distance=1.0 AU; (astronomical unit) but that is huge distance and if you have perspective your earth will be very small instead use some closer distance to match your view size look here:

    • How to position the camera so that the object always has the same size