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?
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:if you use different reference frame or axis orientations then change it accordingly ...
I suspect you use 4x4 homogenous transform matrices
for representing coordinate systems and also to hold your view-port so look here:
constructing the view-port
You need
X,Y,Z
axis vectors andO
origin position.O
you already have (at least you think) andZ
axis is the ray direction so you should have it too. Now just computeX,Y
as alignment to something (else the view will rotate around the ray) I use NEH for that so:To make it a valid view_port you have to:
You need inverse matrix computation for that
if you want the whole thing
Then you also want to add the Sun/Earth position computation in that case look here:
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: