Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8080339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:22:59+00:00 2026-06-05T16:22:59+00:00

I’m rusty a bit here. I have a vector (camDirectionX, camDirectionY, camDirectionZ) that represents

  • 0

I’m rusty a bit here.

I have a vector (camDirectionX, camDirectionY, camDirectionZ) that represents my camera direction of view.
I have a (camX, camY, camZ) that is my camera position.

Then, I have an object placed at (objectX, objectY, objectZ)

How can I calculate, from the camera point of view, the azimut & elevation of my object ??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:23:00+00:00Added an answer on June 5, 2026 at 4:23 pm

    The first thing I would do, to simplify the problem, is transform the coordinate space so the camera is at (0, 0, 0) and pointing straight down one of the axes (so the direction is say (0, 0, 1)). Translating so the camera is at (0, 0, 0) is pretty trivial, so I won’t go into that. Rotating so that the camera direction is (0, 0, 1) is a little trickier…

    One way of doing it is to construct the full orthonormal basis of the camera, then stick that in a rotation matrix and apply it. The “orthonormal basis” of the camera is a fancy way of saying the three vectors that point forward, up, and right from the camera. They should all be at 90 degrees to each other (which is what the ortho bit means), and they should all be of length 1 (which is what the normal bit means).

    You can get these vectors with a bit of cross-product trickery: the cross product of two vectors is perpendicular (at 90 degrees) to both.

    To get the right-facing vector, we can just cross-product the camera direction vector with (0, 1, 0) (a vector pointing straight up). You’ll need to normalise the vector you get out of the cross-product.

    To get the up vector of the camera, we can cross product the camera direction vector with the right-facing vector we just calculated. Assuming both input vectors are normalised, this shouldn’t need normalising.

    We now have the orthonormal basis of the camera. If we stick these vectors into the rows of a 3×3 matrix, we get a rotation matrix that will transform our coordinate space so the camera is pointing straight down one of the axes (which one depends on the order you stick the vectors in).

    It’s now fairly easy to calculate the azimuth and elevation of the object.

    To get the azimuth, just do an atan2 on the x/z coordinates of the object.

    To get the elevation, project the object coordinates onto the x/z plane (just set the y coordinate to 0), then do:

    acos(dot(normalise(object coordinates), normalise(projected coordinates)))
    

    This will always give a positive angle — you probably want to negate it if the object’s y coordinate is less than 0.

    The code for all of this will look something like:

    fwd = vec3(camDirectionX, camDirectionY, camDirectionZ)
    cam = vec3(camX, camY, camZ)
    obj = vec3(objectX, objectY, objectZ)
    
    # if fwd is already normalised you can skip this
    fwd = normalise(fwd)
    
    # translate so the camera is at (0, 0, 0)
    obj -= cam
    
    # calculate the orthonormal basis of the camera
    right = normalise(cross(fwd, (0, 1, 0)))
    up = cross(right, fwd)
    
    # rotate so the camera is pointing straight down the z axis
    # (this is essentially a matrix multiplication)
    obj = vec3(dot(obj, right), dot(obj, up), dot(obj, fwd))
    
    azimuth = atan2(obj.x, obj.z)
    
    proj = vec3(obj.x, 0, obj.z)
    elevation = acos(dot(normalise(obj), normalise(proj)))
    if obj.y < 0:
        elevation = -elevation
    

    One thing to watch out for is that the cross-product of your original camera vector with (0, 1, 0) will return a zero-length vector when your camera is facing straight up or straight down. To fully define the orientation of the camera, I’ve assumed that it’s always “straight”, but that doesn’t mean anything when it’s facing straight up or down — you need another rule.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have a view passing on information from a database: def serve_article(request, id): served_article
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.