1

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?

Spektre
  • 49,595
  • 11
  • 110
  • 380
user2177232
  • 683
  • 1
  • 7
  • 12
  • Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it. – lxg Sep 15 '14 at 13:05
  • edited answer added [edit1] azimutal to cartesian equations because yours are wrong – Spektre Sep 16 '14 at 12:54

1 Answers1

0
  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:

    enter image description here

    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:

  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:

  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:

Community
  • 1
  • 1
Spektre
  • 49,595
  • 11
  • 110
  • 380
  • @user2177232 that depends on what the coordinates are for. For astro bodies you have azimut,elevation,distance (in this case it is distance from geolocation of observer and the body Moon for example) but you want to view something from azimutal heading only so the distance is just distance between observer geolocation (on Earth or whatever surface) and the camera. so you have to set it your self. with perspective camera the distance is also the zoom factor so you set it so the view covers what you want (see bullet 5) – Spektre Sep 17 '14 at 07:41
  • what is the dist value(world coordinate system) in first point – user2177232 Sep 17 '14 at 07:42
  • @user2177232 that depends solely on what the azimutal coordinates are for !!! In your case what are you looking at? for example some object size `h1` and you want it to bee viewed as `h0` size on screen then `distance=z0*h1/h0` where z0 is Z_near of your camera frustrum (focal point) see that link in bullet 5 for more info ... can not be more specific without any more info from your side – Spektre Sep 17 '14 at 11:17
  • is it distance to be the constant for all hours in a day..? can i take earth radius as distance of viewpoint from earth origin – user2177232 Sep 22 '14 at 05:16
  • @user2177232 if your world contains the earth ellipsoid/sphere then yes the distance is earth radius at your viewed geolocation + some altitude to fit the object to screen. if your world is local geolocation plane than no earth distance needed. the distance is variable for changing geolocation and ellipsoid (equatoreal and polar radiuses are different) but the altitude will be the same I think (unless your viewing are is not changing). Start coding and you will see how it looks like... then you will know if it is what you want or need a bit tweaking – Spektre Sep 22 '14 at 07:19
  • is it projection_matrix means object position as (view.O=ground position - (distance*Ray.Dir);) – user2177232 Sep 22 '14 at 07:37
  • @user2177232 no projection_matrix just hold the projection transfomation matrix. which adds perspective to the view (more distant objects are smaller on the screen) this matrix does not affect position nor orientation of view. origin of view is negative to what it was before inversion – Spektre Sep 22 '14 at 08:22